reduce#
Reduces the input using a generic reduction operator and optionally store the indices of the reduction
-
template<typename InType, typename ReduceOp>
__MATX_INLINE__ auto matx::reduce(const InType &in, ReduceOp op, bool init = true)# Perform a reduction
Performs a reduction from tensor “in” into a 0D operator using reduction operation ReduceOp. Without axes, reductions are performed over the entire input operator.
- Template Parameters:
InType – Input data type
ReduceOp – Reduction operator type
- Parameters:
in – Input data to compute the reduce
op – Reduction operator
init – Initialize the data
-
template<typename InType, int D, typename ReduceOp>
__MATX_INLINE__ auto matx::reduce(const InType &in, const int (&dims)[D], ReduceOp op, bool init = true)# Perform a reduction
Performs a reduction from tensor “in” into a 0D operator using reduction operation ReduceOp. In general, the reductions are performed over the innermost dimensions, where the number of dimensions is the difference between the input and number of axes. For example, when axes is the same as the input rank, the reduction is performed over the entire tensor. For anything higher, the reduction is performed across the number of ranks below the input tensor that the output tensor is. For example, if the input tensor is a 4D tensor and the reduction is on a single axis, the reduction is performed across the innermost dimension of the input.
- Template Parameters:
InType – Input data type
D – Rank of dimension array
ReduceOp – Reduction operator type
- Parameters:
in – Input data to compute the reduce
dims – C-style array containing the dimensions to sum over
op – Reduction operator
init – Initialize the data