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_sum
def gather_sum[dtype: DType, //](output: TileTensor[dtype, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type], input: TileTensor[dtype, Engine=input.Engine, address_space=input.address_space, linear_idx_type=input.linear_idx_type], indices: TileTensor[.int32, Engine=indices.Engine, address_space=indices.address_space, linear_idx_type=indices.linear_idx_type], ctx: DeviceContext)
Computes output[i, k] = Σ_j input[indices[i, j], k].
Dispatches to the CPU gather_reduce kernel on CPU targets and to
the elementwise GPU driver on GPU targets.
Args:
- output (
TileTensor[dtype, Engine=output.Engine, address_space=output.address_space, linear_idx_type=output.linear_idx_type]): Output tensor holding the reduced embeddings, shape [batch, embedding_dim] (rank 2) or [batch, 1, embedding_dim] (rank 3). - input (
TileTensor[dtype, Engine=input.Engine, address_space=input.address_space, linear_idx_type=input.linear_idx_type]): Source embedding table, shape [num_embeddings, embedding_dim]. - indices (
TileTensor[.int32, Engine=indices.Engine, address_space=indices.address_space, linear_idx_type=indices.linear_idx_type]): Multi-hot indices, shape [batch, multi_hot],int32. - ctx (
DeviceContext): Device context for kernel execution; the compiled builtin always supplies the placement device's context.