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 struct
SerialReducer
struct SerialReducer
Single-participant Reducer for CPU's serial / cooperative tier. Nothing to combine across (one worker per output), so sum/max/min/generic are identity. Routing cpu_rowwise.pjoin through it rather than skipping the call still invokes the monoid's own pjoin body, which may do per-state finalization (e.g. ReduceSum horizontally reducing its SIMD-wide accumulator into the scalar acc field exposed to bodies).
Implemented traitsβ
AnyType,
Copyable,
Deinitable,
ImplicitlyCopyable,
Movable,
Reducer,
RegisterPassable,
TrivialRegisterPassable
Methodsβ
__init__β
def __init__() -> Self
Initializes the stateless single-participant reducer.
sumβ
def sum[dtype: DType](self, val: Scalar[dtype]) -> Scalar[dtype]
Returns val unchanged β nothing to sum across on CPU.
Parameters:
- βdtype (
DType): The scalar dtype.
Args:
- βval (
Scalar[dtype]): The participant's value.
Returns:
Scalar[dtype]: val unchanged.
maxβ
def max[dtype: DType](self, val: Scalar[dtype]) -> Scalar[dtype]
Returns val unchanged β nothing to combine across on CPU.
Parameters:
- βdtype (
DType): The scalar dtype.
Args:
- βval (
Scalar[dtype]): The participant's value.
Returns:
Scalar[dtype]: val unchanged.
minβ
def min[dtype: DType](self, val: Scalar[dtype]) -> Scalar[dtype]
Returns val unchanged β nothing to combine across on CPU.
Parameters:
- βdtype (
DType): The scalar dtype.
Args:
- βval (
Scalar[dtype]): The participant's value.
Returns:
Scalar[dtype]: val unchanged.
genericβ
def generic[S: ReduceOp](self, mut state: S)
No-op cross-thread combine β one worker per output on CPU.
Parameters:
- βS (
ReduceOp): The monoid type.
Args:
- βstate (
S): The monoid state (left unchanged).