argmax#
Returns both the maximum values and the indices of the maximum values across the input operator
-
template<typename InType, int D>
__MATX_INLINE__ auto matx::argmax(const InType &in, const int (&dims)[D])# Compute max reduction of an operator and returns value + index along specified axes
- 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 argmax-reduce computed
-
template<typename InType>
__MATX_INLINE__ auto matx::argmax(const InType &in)# Compute max reduction of an operator and returns value + index
- Template Parameters:
InType – Input data type
- Parameters:
in – Input data to reduce
- Returns:
Operator with reduced values of argmax-reduce computed
Examples#
auto t0 = make_tensor<TestType>({});
auto t0i = make_tensor<index_t>({});
auto t1o = make_tensor<TestType>({11});
t1o.SetVals({(T)1, (T)3, (T)8, (T)2, (T)9, (T)10, (T)6, (T)7, (T)4, (T)5, (T)11});
(mtie(t0, t0i) = argmax(t1o)).run(exec);
// Reduce a 4D tensor into a 2D tensor by collapsing the inner two dimensions. Both
// examples permute the dimensions before the reduction
(mtie(t2a, t2ai) = argmax(permute(t4,{2,3,0,1}))).run(exec);
(mtie(t2b, t2bi) = argmax(t4, {0,1})).run(exec);