IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo module

reduction

Implements SIMD reductions.

You can import these APIs from the algorithm package. For example:

from max.algorithm import map_reduce

Functions​

  • ​cumsum: Computes the cumulative sum of all elements in a buffer. dst[i] = src[i] + src[i-1] + ... + src[0].
  • ​map_reduce: Stores the result of calling input_gen_fn in dst and simultaneously reduce the result using a custom reduction function.
  • ​max: Computes the max across the input and output shape.
  • ​mean: Computes the mean across the input and output shape.
  • ​min: Computes the min across the input and output shape.
  • ​product: Computes the product across the input and output shape. This performs the product computation on the domain specified by input_shape, loading the inputs using the input_fn. The results are stored using the output_fn.
  • ​reduce: Computes a custom reduction of buffer elements.
  • ​reduce_boolean: Computes a bool reduction of buffer elements. The reduction will early exit if the continue_fn returns False.
  • ​sum: Computes the sum across the input and output shape.
  • ​variance: Given a mean, computes the variance of elements in a buffer.