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 module

monoids

Concrete reduction monoids conforming to algorithm.reduce_op.ReduceOp.

These are the production monoids that the rowwise kernels use. They live here, next to their only callers, so the graph compiler can read them from a package it scans for registrations.

Each is registered under its MO op's name with a temporary .tmp suffix (e.g. mo.reduce.add.tmp), because the plain name still belongs to the hand-written kernel. The suffix goes away when the reduction moves to the graph compiler.

Structs​

  • ​ArgMax: Argmax reduction monoid: tracks the (value, axis-index) pair with the largest value. Ties break to the lower index.
  • ​ArgMin: Argmin reduction monoid: mirrors ArgMax with </ge comparison (see ArgMax for the algorithm + design notes).
  • ​MinMax: Fused min+max reduction monoid: tracks both min(self, x) and max(self, x) in one state. Cuts the axis walk in half vs running separate ReduceMin + ReduceMax.
  • ​OnlineLogSumExp: Online (flash-style) log-sum-exp monoid (Milakov & Gimelshein, 2018) — the reduction half of softmax.
  • ​ReduceMax: Max reduction monoid: (self, x) -> max(self, x).
  • ​ReduceMin: Min reduction monoid: (self, x) -> min(self, x).
  • ​ReduceProduct: Product reduction monoid: (self, x) -> self * x.
  • ​ReduceSum: Sum reduction monoid: (self, x) -> self + x.
  • ​Welford: Welford's online mean/variance monoid (Welford 1962, Chan et al. 1979 for the combine) — the reduction half of layer_norm / group_norm.

Was this page helpful?