SetDeqScale
Function Usage
Sets the value of the DEQSCALE register.
Prototype
- Used in the s322f16 scenario of the AddDeqRelu and Cast instructions
1__aicore__ inline void SetDeqScale(half scale)
- Used in the CastDeq (isVecDeq=false) scenario
1__aicore__ inline void SetDeqScale(float scale, int16_t offset, bool signMode)
- Used in the CastDeq (isVecDeq=true) scenario.
1 2
template <typename T> __aicore__ inline void SetDeqScale(const LocalTensor<T>& vdeqTensor, const VdeqInfo& vdeqInfo)
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
scale (half) |
Input |
Data of the half type. |
||
scale (float) |
Input |
Data of the float type. Used by the CastDeq (isVecDeq=false) instruction to set the value of the DEQSCALE register. |
||
offset |
Input |
Data of the int16_t type, indicating an offset of the s9 type. Only the first nine bits of the input parameter are valid. Used in the CastDeq (isVecDeq=false) scenario. |
||
signMode |
Input |
Whether the quantization result contains a sign. The value is of the Boolean type. Used in the CastDeq (isVecDeq=false) scenario. |
||
vdeqTensor |
Input |
Used in the CastDeq (isVecDeq=true) scenario. A 128-byte quantized tensor is input. The type is LocalTensor, and the supported TPosition is VECIN, VECCALC, or VECOUT. The start address of the LocalTensor must be 32-byte aligned. The supported data type is uint64_t. |
||
vdeqInfo |
Input |
Data structure for storing the quantized tensor information. The structure contains 16 groups of quantization parameters of the quantized tensor.
|
Returns
None
Availability
Constraints
None
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | AscendC::LocalTensor<int8_t> dstLocal; AscendC::LocalTensor<int16_t> srcLocal; AscendC::LocalTensor<uint64_t> tmpBuffer; uint32_t srcSize = 256; // Cast AscendC::LocalTensor<half> castDstLocal; AscendC::LocalTensor<int32_t> castSrcLocal; half scale = 1.0; AscendC::SetDeqScale(scale); AscendC::Cast(castDstLocal, castSrcLocal, AscendC::RoundMode::CAST_NONE, srcSize); // CastDeq float scale = 1.0; int16_t offset = 0; bool signMode = true; AscendC::SetDeqScale(scale, offset, signMode); AscendC::CastDeq<int8_t, int16_t, false, false>(dstLocal, srcLocal, srcSize); // CastVdeq float vdeqScale[16] = { 0 }; int16_t vdeqOffset[16] = { 0 }; bool vdeqSignMode[16] = { 0 }; for (int i = 0; i < 16; i++) { vdeqScale[i] = 1.0; vdeqOffset[i] = 0; vdeqSignMode[i] = true; } AscendC::VdeqInfo vdeqInfo(vdeqScale, vdeqOffset, vdeqSignMode); AscendC::SetDeqScale<uint64_t>(tmpBuffer, vdeqInfo); AscendC::CastDeq<int8_t, int16_t, true, false>(dstLocal, srcLocal, srcSize); |