Mojo function
gather
gather[dtype: DType, indices_type: DType, //, *, axis: Int, target: StringSlice[StaticConstantOrigin] = "cpu"](output: NDBuffer[dtype, rank, origin, shape, strides], input: NDBuffer[dtype, 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[dtype: DType, indices_type: DType, //, *, axis: Int, target: StringSlice[StaticConstantOrigin] = "cpu"](output: NDBuffer[dtype, rank, origin, shape, strides], input: NDBuffer[dtype, 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[*, dtype: DType, indices_type: DType, input_fn: fn[width: Int, rank: Int](IndexList[rank]) capturing -> SIMD[dtype, width], indices_fn: fn[width: Int, rank: Int](IndexList[rank]) capturing -> SIMD[indices_type, width], output_fn: fn[width: Int, rank: Int](IndexList[rank], SIMD[dtype, width]) capturing -> None, prefetch_fn: OptionalReg[fn[input_rank: Int, indices_rank: Int](IndexList[input_rank], IndexList[indices_rank]) capturing -> None] = OptionalReg[fn[input_rank: Int, indices_rank: Int](IndexList[input_rank], IndexList[indices_rank]) capturing -> None]({:i1 0, 1}), target: StringSlice[StaticConstantOrigin] = "cpu", single_thread_blocking_override: Bool = False](axis: Axis, input_shape: IndexList[size, element_type=element_type], indices_shape: IndexList[size, element_type=element_type], output_shape: IndexList[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[*, dtype: DType, indices_type: DType, input_fn: fn[width: Int, rank: Int](IndexList[rank]) capturing -> SIMD[dtype, width], indices_fn: fn[width: Int, rank: Int](IndexList[rank]) capturing -> SIMD[indices_type, width], output_fn: fn[width: Int, rank: Int](IndexList[rank], SIMD[dtype, width]) capturing -> None, prefetch_fn: OptionalReg[fn[input_rank: Int, indices_rank: Int](IndexList[input_rank], IndexList[indices_rank]) capturing -> None] = OptionalReg[fn[input_rank: Int, indices_rank: Int](IndexList[input_rank], IndexList[indices_rank]) capturing -> None]({:i1 0, 1}), target: StringSlice[StaticConstantOrigin] = "cpu", single_thread_blocking_override: Bool = False](axis: Axis, input_shape: IndexList[size, element_type=element_type], indices_shape: IndexList[size, element_type=element_type], output_shape: IndexList[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!