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
def reduce[params: ContextParams, //, TileFn: def[ws: Int, _r: Int](IndexList[_r]) -> None & ImplicitlyCopyable](row_coords: Coord, axis_size: Int, mut ctx: Context[params], tile_fn: TileFn)
Drives tile_fn over the reduce axis on the target backend, with no monoid state β pure per-tile iteration. See the state-carrying overload below for reduce phases.
Parameters:
- βparams (
ContextParams): Comptime dispatch parameters (target + tier). - βTileFn (
def[ws: Int, _r: Int](IndexList[_r]) -> None&ImplicitlyCopyable): The value-closure type oftile_fn.
Args:
- βrow_coords (
Coord): The current row's coords. - βaxis_size (
Int): Length of the reduce axis. - βctx (
Context[params]): The dispatch bundle. - βtile_fn (
TileFn): Per-tile callback; closes over input/output closures.
def reduce[State: ReduceOp, params: ContextParams, //, TileFn: def[ws: Int, _r: Int](mut State, IndexList[_r]) -> None & ImplicitlyCopyable](row_coords: Coord, axis_size: Int, mut ctx: Context[params], mut state: State, tile_fn: TileFn) where (eq TileFn.State, State)
Drives tile_fn over the reduce axis on the target backend.
See the CPU and GPU reduce impls for per-target tier semantics;
both call tile_fn[ws, _r] per axis tile, folding into state.
tile_fn is a value closure taking state as a mut argument
(not a capture β a captured accumulator can't be mutated through a
value closure).
Parameters:
- βState (
ReduceOp): The monoid type being accumulated. - βparams (
ContextParams): Comptime dispatch parameters (target + tier). - βTileFn (
def[ws: Int, _r: Int](mut State, IndexList[_r]) -> None&ImplicitlyCopyable): The value-closure type oftile_fn.
Args:
- βrow_coords (
Coord): The current row's coords. - βaxis_size (
Int): Length of the reduce axis. - βctx (
Context[params]): The dispatch bundle. - βstate (
State): The caller's monoid accumulator, threaded through bymutreference and mutated in place bytile_fn. - βtile_fn (
TileFn): Per-tile callback; closes over input closures and folds each tile intostate.