For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/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: StringSlice[ImmStaticOrigin] = StringSlice("cpu"), reduce_fn: OptionalReg[def[dtype: DType, width: SIMDLength](SIMD[dtype, width], SIMD[dtype, width]) thin -> SIMD[dtype, width]] = None, *, _trace_description: StringSlice[ImmStaticOrigin] = StringSlice("scatter_nd")](data: TileTensor[output_type, Storage=data.Storage, linear_idx_type=data.linear_idx_type], indices: TileTensor[indices_type, Storage=indices.Storage, linear_idx_type=indices.linear_idx_type], updates: TileTensor[output_type, Storage=updates.Storage, linear_idx_type=updates.linear_idx_type], output: TileTensor[output_type, Storage=output.Storage, 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 (
StringSlice[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 (
StringSlice[ImmStaticOrigin]): A description of the function, used for profiling and tracing.
Args:
- βdata (
TileTensor[output_type, Storage=data.Storage, linear_idx_type=data.linear_idx_type]): Tensor of rank data_rank >= 1. - βindices (
TileTensor[indices_type, Storage=indices.Storage, linear_idx_type=indices.linear_idx_type]): Tensor of rank indices_rank containing indices for the scatter operation. - βupdates (
TileTensor[output_type, Storage=updates.Storage, linear_idx_type=updates.linear_idx_type]): Tensor containing values to update output tensor based on indices tensor. - βoutput (
TileTensor[output_type, Storage=output.Storage, linear_idx_type=output.linear_idx_type]): Tensor of rank data_rank, shaped the same as data tensor. - βcontext (
DeviceContext): Pointer to DeviceContext.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!