Skip to content
fn

gather_op

→TensorImplPtr
int gather_op(const int & a, const int & indices, int axis)

Python wrappers

Public Python APIs implemented by this engine symbol.

Gather elements from a at index positions along a single axis.

For each location in the output, looks up the value of a at the index given by indices along axis, holding all other axes fixed.

Parameters

aTensorImplPtr
Source tensor.
indicesTensorImplPtr
Integer index tensor of the same rank as a. Along every axis other than axis, the shape must match a.
axisint
Axis along which to gather.

Returns

TensorImplPtr

Tensor of shape indices.shape and dtype of a.

Notes

Backward is a scatter-add: the incoming gradient is added back into a zero tensor of the input shape at the positions specified by indices. Duplicate indices accumulate, matching NumPy / reference framework semantics.