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

reduce_sum

def reduce_sum[dtype: DType, InputFn: def[width: Int, alignment: Int, rank: Int](IndexList[rank]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, OutputFn: def[width: SIMDLength, rank: Int](IndexList[rank], SIMD[dtype, width]) -> None & RegisterPassable & ImplicitlyCopyable, /, target: StringSpan[ImmStaticOrigin], *, reduce_dim: Int](input_fn: InputFn, output_fn: OutputFn, input_shape: Coord, context: Optional[DeviceContext] = None) where (eq InputFn.dtype, dtype) where (eq OutputFn.dtype, dtype)

Sums input values along reduce_dim via the Row free-form body layer: one ReduceSum phase plus a per-row emit.

input_fn / output_fn are value-based closures (a type parameter bound to a callable trait + a value argument), not comptime capturing[_] parameters.