IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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_elementwise_fn_wrapper

def gather_elementwise_fn_wrapper[dtype: DType, indices_type: DType, InputFnType: def[width: Int, rank: Int, element_alignment: Int](IndexList[rank]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, IndicesFnType: def[width: Int, rank: Int](IndexList[rank]) -> SIMD[indices_type, width] & RegisterPassable & ImplicitlyCopyable, OutputFnType: def[width: SIMDLength, rank: Int, element_alignment: Int](IndexList[rank], SIMD[dtype, width]) -> None & RegisterPassable & ImplicitlyCopyable, *, simd_width: Int, prefetch_fn: OptionalReg[def[input_rank: Int, indices_rank: Int](IndexList[input_rank], IndexList[indices_rank]) capturing thin -> None] = None, target: StringSpan[ImmStaticOrigin] = StringSpan("cpu"), element_alignment: Int = Int(1)](input_fn: InputFnType, indices_fn: IndicesFnType, output_fn: OutputFnType, axis: Axis, input_shape: IndexList[element_type=input_shape.element_type], indices_shape: IndexList[element_type=indices_shape.element_type], output_shape: IndexList[element_type=output_shape.element_type], coords: IndexList[element_type=coords.element_type], error_index_ptr: OptionalReg[Pointer[Int, MutAnyOrigin]] = None) where identical(InputFnType.dtype, dtype) where identical(IndicesFnType.indices_type, indices_type) where identical(OutputFnType.dtype, dtype)

Performs a single elementwise gather step for one output coordinate.

Loads the gather index from indices at the coordinate derived from coords, normalizes it against the input axis size, reads the corresponding value from input, and stores it into output at the original coordinate. On CPU, out-of-bounds indices are recorded through error_index_ptr for later reporting; on GPU, a debug assert traps instead.

Parameters:

Args: