Skip to content

ReductionTraits

#include <ncarray/reductions.hh>
template<class Traits, typename T>
concept ReductionTraits

Defined in src/lib/ncarray/reductions.hh:81

Interface specifier for a valid reduction operation.

Traits adhering to this specification can be used for performing axis-aware reductions. In the case that the reduction accumulates into a type that is different from the desired output type, an additional dual_atomic function (not included in this concept) would be required for operation on GPU. See argmax/argmin or variance traits for examples.

The identity function returns the identity for the accumulator type.

The fill function will, in general, return the identity; however, if the output type is not the same as the accumulator type this may be different. For example, the argmax reduction accumulates key/value pairs (max and index). However, the output is just the index, so fill returns an integer, while identity returns the key/value pair.

The transform function converts an index and value into the acummulator type.

The reduce function performs the necessary comparisons/reductions on a single pair of elements.

The store function converts an accumulator type back to the output type.

The atomic function is used for a generalized atomic reduction on GPU.

  • A dual_atomic function may be needed as well.