SetDeqScale
产品支持情况
功能说明
设置DEQSCALE寄存器的值。
函数原型
-
用于AddDeqRelu/Cast/CastDeq的s322f16场景
__aicore__ inline void SetDeqScale(half scale) -
用于CastDeq(isVecDeq=false)的场景
__aicore__ inline void SetDeqScale(float scale, int16_t offset, bool signMode) -
用于CastDeq(isVecDeq=true)的场景
template <typename T> __aicore__ inline void SetDeqScale(const LocalTensor<T>& vdeq, const VdeqInfo& vdeqInfo)
参数说明
表 1 模板参数说明
表 2 参数说明
|
Ascend 950PR/Ascend 950DT:用于AddDeqRelu/CastDeq/Cast的s322f16场景。 Atlas A3 训练系列产品/Atlas A3 推理系列产品,用于AddDeqRelu/Cast/CastDeq的s322f16场景。 Atlas A2 训练系列产品/Atlas A2 推理系列产品,用于AddDeqRelu/Cast/CastDeq的s322f16场景。 |
||
|
用于CastDeq(isVecDeq=false)场景设置DEQSCALE寄存器的值。 |
||
|
用于CastDeq(isVecDeq=false)的场景,设置offset。 |
||
|
用于CastDeq(isVecDeq=false)的场景,设置signMode。 |
||
用于CastDeq(isVecDeq=true)的场景,输入量化tensor,大小为128Byte。 类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
存储量化tensor信息的数据结构,结构体内包含量化tensor中的16组量化参数 const uint8_t VDEQ_TENSOR_SIZE = 16; |
返回值说明
无
约束说明
无
调用示例
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);