Mojo function
gather
gather[type: DType, indices_type: DType, //, *, axis: Int, target: StringSlice[StaticConstantOrigin] = __init__[__mlir_type.!kgen.string]("cpu")](output: NDBuffer[type, rank, origin, shape, strides], input: NDBuffer[type, rank, origin, shape, strides], indices: NDBuffer[indices_type, rank, origin, shape, strides], *, context: DeviceContext)
Gather operation as defined in https://github.com/onnx/onnx/blob/main/docs/Operators.md#Gather.
Note that this is NOT the same as the default PyTorch gather (which is equivalent to https://github.com/onnx/onnx/blob/main/docs/Operators.md#gatherelements).
gather[type: DType, indices_type: DType, //, *, axis: Int, target: StringSlice[StaticConstantOrigin] = __init__[__mlir_type.!kgen.string]("cpu")](output: NDBuffer[type, rank, origin, shape, strides], input: NDBuffer[type, rank, origin, shape, strides], indices: NDBuffer[indices_type, rank, origin, shape, strides], *, context: DeviceContextPtr = DeviceContextPtr())
Gather operation as defined in https://github.com/onnx/onnx/blob/main/docs/Operators.md#Gather.
Note that this is NOT the same as the default PyTorch gather (which is equivalent to https://github.com/onnx/onnx/blob/main/docs/Operators.md#gatherelements).
gather[*, type: DType, indices_type: DType, input_fn: fn[Int, Int](Index[$1]) capturing -> SIMD[type, $0], indices_fn: fn[Int, Int](Index[$1]) capturing -> SIMD[indices_type, $0], output_fn: fn[Int, Int](Index[$1], SIMD[type, $0]) capturing -> None, prefetch_fn: OptionalReg[fn[Int, Int](Index[$0], Index[$1]) capturing -> None] = OptionalReg[fn[Int, Int](Index[$0], Index[$1]) capturing -> None]({:i1 0, 1}), target: StringSlice[StaticConstantOrigin] = __init__[__mlir_type.!kgen.string]("cpu"), single_thread_blocking_override: Bool = False](axis: Axis, input_shape: Index[size, element_type=element_type], indices_shape: Index[size, element_type=element_type], output_shape: Index[size, element_type=element_type], *, context: DeviceContext)
Gather operation as defined in https://github.com/onnx/onnx/blob/main/docs/Operators.md#Gather.
Note that this is NOT the same as the default PyTorch gather (which is equivalent to https://github.com/onnx/onnx/blob/main/docs/Operators.md#gatherelements).
gather[*, type: DType, indices_type: DType, input_fn: fn[Int, Int](Index[$1]) capturing -> SIMD[type, $0], indices_fn: fn[Int, Int](Index[$1]) capturing -> SIMD[indices_type, $0], output_fn: fn[Int, Int](Index[$1], SIMD[type, $0]) capturing -> None, prefetch_fn: OptionalReg[fn[Int, Int](Index[$0], Index[$1]) capturing -> None] = OptionalReg[fn[Int, Int](Index[$0], Index[$1]) capturing -> None]({:i1 0, 1}), target: StringSlice[StaticConstantOrigin] = __init__[__mlir_type.!kgen.string]("cpu"), single_thread_blocking_override: Bool = False](axis: Axis, input_shape: Index[size, element_type=element_type], indices_shape: Index[size, element_type=element_type], output_shape: Index[size, element_type=element_type], *, context: DeviceContextPtr = DeviceContextPtr())
Gather operation as defined in https://github.com/onnx/onnx/blob/main/docs/Operators.md#Gather.
Note that this is NOT the same as the default PyTorch gather (which is equivalent to https://github.com/onnx/onnx/blob/main/docs/Operators.md#gatherelements).
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!