ncarray::ReductionTraits
ncarray::ReductionTraits
Section titled “ncarray::ReductionTraits”Definition
Section titled “Definition”template<class Traits, typename T>concept= requires(ssize_t idx, T val, typename Traits::template AccumT<T> a, typename Traits::template AccumT<T> b, typename Traits::template AccumT<T> res, typename Traits::template AccumT<T>* dest, typename Traits::template AccumT<T> aval) { typename Traits::template AccumT<T>; { Traits::template identity<T>() }; { Traits::template fill<T>() }; { Traits::template transform<T>(idx, val) }; { Traits::template reduce<T>(a, b) }; { Traits::template store<T>(res, 0.0) }; { Traits::template atomic<T>(dest, aval) }; };Detailed Description
Section titled “Detailed Description”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. A dual_atomic function may be needed as well. The atomic function is used for a generalized atomic reduction on GPU.