sum

Contents

sum#

Reduces the input by the sum of values across the specified axes.

template<typename InType, int D>
__MATX_INLINE__ auto matx::sum(const InType &in, const int (&dims)[D])#

Compute sum of input along axes

Returns a tensor representing the sum of all items in the reduction

Template Parameters:
  • InType – Input data type

  • D – Num of dimensions to reduce over

Parameters:
  • in – Input data to reduce

  • dims – Array containing dimensions to reduce over

Returns:

Operator with reduced values of sum-reduce computed

template<typename InType>
__MATX_INLINE__ auto matx::sum(const InType &in)#

Compute sum of input

Returns a tensor representing the sum of all items in the reduction

Template Parameters:
  • InType – Input data type

  • D – Number of right-most dimensions to reduce over

Parameters:

in – Input data to reduce

Returns:

Operator with reduced values of sum-reduce computed

Examples#

// Reduce a 4D tensor into a 0D by taking the sum of all elements
(t0 = sum(t4)).run(exec);
// Reduce a 3D tensor into a 2D by taking the sum of the last dimension
(b = sum(a, {2})).run(exec);