Skip to main content

module

reduction

Implements SIMD reductions.

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

from algorithm import map_reduce

Functions

  • map_reduce: Stores the result of calling input_gen_fn in dst and simultaneously reduce the result using a custom reduction function.
  • 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.
  • max: Computes the max element in a buffer.
  • min: Computes the min element in a buffer.
  • sum: Computes the sum of buffer elements.
  • product: Computes the product of the buffer elements.
  • mean: Computes the mean value of the elements in a buffer.
  • variance: Given a mean, computes the variance of elements in a buffer.
  • all_true: Returns True if all the elements in a buffer are True and False otherwise.
  • any_true: Returns True if any the elements in a buffer are True and False otherwise.
  • none_true: Returns True if none of the elements in a buffer are True and False otherwise.
  • argmax: Finds the indices of the maximum element along the specified axis.
  • argmin: Finds the indices of the maximum element along the specified axis.
  • reduce_shape: Compute the output shape of a pad operation, and assert the inputs are compatible.
  • cumsum: Computes the cumulative sum of all elements in a buffer. dst[i] = src[i] + src[i-1] + ... + src[0].