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"), reduce_fn: OptionalReg[def[dtype: DType, width: SIMDLength](SIMD[dtype, width], SIMD[dtype, width]) thin -> SIMD[dtype, width]] = 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: DeviceContext)

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.
  • ​reduce_fn (OptionalReg[def[dtype: DType, width: SIMDLength](SIMD[dtype, width], SIMD[dtype, width]) thin -> SIMD[dtype, width]]): Reduction function to apply: none (default), add, mul, max, min. When set, every update is folded in atomically, in unspecified order — the atomic runs on all updates, not only detected duplicates, since duplicate index vectors can only be known at runtime. Without a reduce_fn, duplicates leave an unspecified winner instead.
  • ​_trace_description (StringSpan[ImmStaticOrigin]): A description of the function, used for profiling and tracing.

Args:

Was this page helpful?