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

scatter_nd_generator

def scatter_nd_generator[output_type: DType, indices_type: DType, //, oob_index_strategy: ScatterOobIndexStrategy = ScatterOobIndexStrategy.UNDEFINED, target: StringSpan[ImmStaticOrigin] = StringSpan("cpu"), atomic_update_fn: OptionalReg[def[dtype: DType](Pointer[Scalar[dtype], *?, address_space=*?], Scalar[dtype]) thin -> None] = None, *, _trace_description: StringSpan[ImmStaticOrigin] = StringSpan("scatter_nd")](data: TileTensor[output_type, Engine=data.Engine, linear_idx_type=data.linear_idx_type], indices: TileTensor[indices_type, Engine=indices.Engine, linear_idx_type=indices.linear_idx_type], updates: TileTensor[output_type, Engine=updates.Engine, linear_idx_type=updates.linear_idx_type], output: TileTensor[output_type, Engine=output.Engine, linear_idx_type=output.linear_idx_type], context: DeviceContextBase)

Implements ONNX ScatterND operation as defined in https://github.com/onnx/onnx/blob/main/docs/Operators.md#ScatterND.

Parameters:

  • ​output_type (DType): Type of data, updates, and output tensors.
  • ​indices_type (DType): Type of the indices tensor.
  • ​oob_index_strategy (ScatterOobIndexStrategy): Strategy to handle out of bounds indices.
  • ​target (StringSpan[ImmStaticOrigin]): Target cpu or cuda.
  • ​atomic_update_fn (OptionalReg[def[dtype: DType](Pointer[Scalar[dtype], *?, address_space=*?], Scalar[dtype]) thin -> None]): Callable that atomically applies an update to a destination pointer. Called for every update on CPU and GPU, in unspecified order. Use _atomic_add for addition or _atomic_reduce[reduce_fn] for a binary reduction. Without a callable, duplicate indices leave an unspecified winner.
  • ​_trace_description (StringSpan[ImmStaticOrigin]): A description of the function, used for profiling and tracing.

Args:

Was this page helpful?