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 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:

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:

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:

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:

Args:

  • state (S): The monoid state (left unchanged).