GetCmpMask (ISASI)
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
√ |
|
x |
|
x |
Function Usage
Obtains the comparison result of the API Compare (Result Stored in Register).
The API Compare (Result Stored in Register) writes the comparison result to the CmpMask register. You can obtain the comparison result from the CmpMask register by calling the GetCmpMask API.
Prototype
1 2 | template<typename T> __aicore__ inline void GetCmpMask(const LocalTensor<T>& dst) |
Parameters
Parameter |
Description |
|---|---|
T |
Operand data type. |
Parameter |
Input/Output |
Description |
|---|---|---|
dst |
Output |
Comparison result of Compare (Result Stored in a Register). The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT. The start address of the LocalTensor must be 16-byte aligned. |
Returns
None
Restrictions
The space size of dst cannot be less than 128 bytes.
Examples
The result of the Compare (Result Stored in a Register) instruction is stored using data of the uint8_t type. Therefore, dstLocal uses the uint8_t type.
1 2 3 4 5 6 7 | AscendC::LocalTensor<float> src0Local; AscendC::LocalTensor<float> src1Local; AscendC::LocalTensor<uint8_t> dstLocal; uint64_t mask = 256 / sizeof(float); // 256 indicates the number of bytes processed in each iteration. The result is 64. AscendC::BinaryRepeatParams repeatParams = { 1, 1, 1, 8, 8, 8 }; AscendC::Compare(src0Local, src1Local, AscendC::CMPMODE::LT, mask, repeatParams); AscendC::GetCmpMask(dstLocal); // If mask is 0x40 and the comparison data type is float, only the 7th float element within each 32-byte iteration participates in the comparison. |
Output example: src0Local: [1, 2, 3, 4, 5, 6, 7, 8, 9, ...256] src1Local: [2, 3, 4, 5, 6, 7, 8, 9, ...257] Elements involved in comparison after masking src0Local: [1, 8, 16, ...256] src1Local: [2, 10, 18, ...257] GetCmpMask result: [256, 256, 256, 256, 256, 256, 256, 256]