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).