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_elements
def scatter_elements[input_type: DType, indices_type: DType, //, *, atomic_update_fn: OptionalReg[def[dtype: DType](MutPointer[Scalar[dtype], *?, address_space=*?], Scalar[dtype]) thin -> None] = None](input: TileTensor[input_type, Engine=input.Engine, linear_idx_type=input.linear_idx_type], indices: TileTensor[indices_type, Engine=indices.Engine, address_space=indices.address_space, linear_idx_type=indices.linear_idx_type], updates: TileTensor[input_type, Engine=updates.Engine, address_space=updates.address_space, linear_idx_type=updates.linear_idx_type], _axis: Int, output: TileTensor[input_type, Engine=output.Engine, linear_idx_type=output.linear_idx_type], ctx: DeviceContext)
Implements ONNX ScatterElements op which is equivalent to Pytorch scatter.
Parameters:
- input_type (
DType): Element type ofinput,updates, andoutput. - indices_type (
DType): Element type ofindices(must beint32orint64). - atomic_update_fn (
OptionalReg[def[dtype: DType](MutPointer[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_addfor addition or_atomic_reduce[reduce_fn]for a binary reduction. Without a callable, duplicate indices leave an unspecified winner.
Args:
- input (
TileTensor[input_type, Engine=input.Engine, linear_idx_type=input.linear_idx_type]): Source tensor copied intooutputbefore scattering. - indices (
TileTensor[indices_type, Engine=indices.Engine, address_space=indices.address_space, linear_idx_type=indices.linear_idx_type]): Indices along_axisselecting where updates land inoutput. - updates (
TileTensor[input_type, Engine=updates.Engine, address_space=updates.address_space, linear_idx_type=updates.linear_idx_type]): Values to scatter intooutputat positions given byindices. - _axis (
Int): Axis along which to scatter; must be in[-rank, rank). - output (
TileTensor[input_type, Engine=output.Engine, linear_idx_type=output.linear_idx_type]): Output tensor, same shape asinput, receiving scattered updates. - ctx (
DeviceContext): Device context for execution.