parameters: (op, grad)
return_statement: return [ops.IndexedSlices(values, indices, params_shape), None]
docstring: Gradient for gather op.
docstring_summary: Gradient for gather op.
docstring_tokens: Gradient for gather op .
function: def _GatherGrad(op, grad):
    """Gradient for gather op."""
    # Build appropriately shaped IndexedSlices
    # Walk graph back until the original handle is found.
    # TODO(apassos): more robust way of getting the shape.
    handle = op.inputs[0]
    while handle.op.type != "VarHandleOp":
      handle = handle.op.inputs[0]
    params_shape = ops.convert_to_tensor(
        tensor_shape.TensorShape(handle.op.get_attr("shape")))
    indices = op.inputs[1]
    size = array_ops.expand_dims(array_ops.size(indices), 0)
    values_shape = array_ops.concat([size, params_shape[1:]], 0)
    values = array_ops.reshape(grad, values_shape)
    indices = array_ops.reshape(indices, size)
    return [ops.IndexedSlices(values, indices, params_shape), None]
function_tokens: def _GatherGrad ( op , grad ) : # Build appropriately shaped IndexedSlices # Walk graph back until the original handle is found. # TODO(apassos): more robust way of getting the shape. handle = op . inputs [ 0 ] while handle . op . type != "VarHandleOp" : handle = handle . op . inputs [ 0 ] params_shape = ops . convert_to_tensor ( tensor_shape . TensorShape ( handle . op . get_attr ( "shape" ) ) ) indices = op . inputs [ 1 ] size = array_ops . expand_dims ( array_ops . size ( indices ) , 0 ) values_shape = array_ops . concat ( [ size , params_shape [ 1 : ] ] , 0 ) values = array_ops . reshape ( grad , values_shape ) indices = array_ops . reshape ( indices , size ) return [ ops . IndexedSlices ( values , indices , params_shape ) , None ]