For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
gather_guards
def gather_guards[input_rank: Int, indices_rank: Int, output_rank: Int](axis: Axis, input_shape: DynamicCoord[.int64, input_rank], indices_shape: DynamicCoord[.int64, indices_rank], output_shape: DynamicCoord[.int64, output_rank])
Validates that the input, indices, and output shapes are compatible for a gather operation.
Parameters:
- input_rank (
Int): Rank of the input tensor. - indices_rank (
Int): Rank of the indices tensor. - output_rank (
Int): Rank of the output tensor.
Args:
- axis (
Axis): Axis along which the gather is performed; must be non-negative and less thaninput_shaperank. - input_shape (
DynamicCoord[.int64, input_rank]): Shape of the input tensor being gathered from. - indices_shape (
DynamicCoord[.int64, indices_rank]): Shape of the indices tensor. - output_shape (
DynamicCoord[.int64, output_rank]): Shape of the output tensor; must match the gather output shape derived frominput_shapeandindices_shape.
Raises:
If the axis is negative, out of range, or the output shape does not match the expected gather shape derived from the input and indices.