GetReduceMaxMinCount (ISASI)

Function Usage

Obtains the maximum/minimum values and the corresponding index values in the scenario where the ReduceMax and ReduceMin are consecutive.

Prototype

  • Obtain the maximum value, minimum value, and corresponding index value in the scenario where the ReduceMax and ReduceMin are consecutive.
    1
    2
    template <typename T>
    __aicore__ inline void GetReduceMaxMinCount(T &maxMinValue, T &maxMinIndex)
    
  • Obtains the maximum and minimum values in the scenario where the ReduceMax and ReduceMin values are consecutive.
    1
    2
    template <typename T>
    __aicore__ inline void GetReduceMaxMinCount(T &maxMinValue)
    

Parameters

Table 1 Template parameters

Parameter

Description

T

Data type of the ReduceMax/ReduceMin instruction. The value can be half or float.

Table 2 Parameters

Parameter

Input/Output

Description

maxMinValue

Input

Maximum/Minimum value of the ReduceMax/ReduceMin instruction.

maxMinIndex

Input

Index value corresponding to the maximum/minimum value of the ReduceMax/ReduceMin instruction.

Returns

Maximum/Minimum value of ReduceMax/ReduceMin in continuous scenarios and the corresponding index value.

Availability

Constraints

  • The maxMinIndex data is stored based on the ReduceMax/ReduceMin data type. For example, when ReduceMax/ReduceMin uses the half type, the maxMinIndex data is stored based on the half type. If the data is read in the half format, the value of maxMinIndex is incorrect, therefore, to read maxMinIndex, you need to use the reinterpret_cast method to convert it to the integer type. If the input data type is half, use reinterpret_cast<uint16_t>. If the input data type is float, use reinterpret_cast<uint32_t>.

Example

  1. Execute the ReduceMax instruction.
    1
    2
    3
    4
    5
    AscendC::LocalTensor<float> src;
    AscendC::LocalTensor<float> work;
    AscendC::LocalTensor<float> dst;
    int32_t mask = 64;
    AscendC::ReduceMax(dst, src, work, mask, 1, 8, true); // Continuous scenario, srcRepStride = 8 and calIndex = true
    
  2. Obtain the maximum/minimum value and the index value of the ReduceMax instruction.