Skip to content

SetFixPipeConfig

产品支持情况​

  • Ascend 950PR&950DT系列产品:支持
  • Atlas A3系列产品:支持
  • Atlas A2系列产品:支持
  • Atlas 200I/500 A2推理产品:支持
  • Atlas推理系列产品AI Core:不支持
  • Atlas推理系列产品Vector Core:不支持
  • Atlas训练系列产品:不支持
  • KirinX90处理器系列产品:支持
  • Kirin9020处理器系列产品:支持
  • Kirin9030处理器系列产品:支持
  • Kirin9050处理器系列产品:支持

功能说明​

DataCopy数据搬运(L0C Buffer->GM、L0C Buffer->L1 Buffer)过程中进行随路量化时,通过调用该接口设置量化的参数。

函数原型​

C++
template <typename T>
__aicore__ inline void SetFixPipeConfig(const LocalTensor<T>& reluPre, const LocalTensor<T>& quantPre, bool isUnitFlag = false)

template <typename T, bool setRelu = false>
__aicore__ inline void SetFixPipeConfig(const LocalTensor<T>& preData, bool isUnitFlag = false)

参数说明​

表1 模板参数说明

参数名描述
T操作数的数据类型。
setRelu针对设置一个tensor的情况,setRelu当前仅支持设置为false,即只支持设置随路quantPre系数。

表2 参数说明

参数名称输入/输出含义
reluPre输入源操作数,ReLU操作时参与计算的tensor,类型为LocalTensor,支持的物理内存为Fixpipe Buffer(TPosition为C2PIPE2GM),为后续的功能扩展做保留,传入一个空LocalTensor即可。
quantPre输入源操作数,quant tensor,量化操作时参与计算的tensor,类型为LocalTensor,支持的物理内存为Fixpipe Buffer(TPosition为C2PIPE2GM)。
isUnitFlag输入unitFlag清空标志位,类型为bool。如果设为true,L0C Buffer中所有内存块的单元标志位都会设为0。旨在消除之前操作中unitFlag产生的多余影响。
preData输入支持设置一个tensor,通过开关控制是ReLU tensor还是Quant tensor,支持的物理内存为Fixpipe Buffer(TPosition为C2PIPE2GM)。当前仅支持传入quant tensor。对于单独设置unitFlag清空标志位isUnitFlag的场景,支持的物理地址为L0C Buffer(TPosition设置为CO1)。

数据类型​

支持的数据类型为:uint64_t。

返回值说明​

无

约束说明​

量化参数不能为inf/nan和非规格化数。

quantPre和reluPre必须是Fixpipe Buffer上的tensor。

调用示例​

完整示例可参考data_copy_l0c2gm。

C++
__aicore__ inline void SetFPC(const LocalTensor <int32_t>& reluPreTensor, const LocalTensor <int32_t>& quantPreTensor)
{
 
    AscendC::LocalTensor<uint64_t> workA1 = inQueueDeqA1.AllocTensor<uint64_t>();
    uint16_t deqSize = 128; // deq tensor的size
    AscendC::DataCopy(workA1, deqGlobal, deqSize); // deqGlobal为量化系数的gm地址
    AscendC::LocalTensor<uint64_t> deqFB = inQueueDeqFB.AllocTensor<uint64_t>(); // deq tensor在Fix上的地址
    uint16_t fbufBurstLen = deqSize / 128;  // l1->fix, burst_len unit is 128Bytes
    AscendC::DataCopyParams dataCopyParams(1, fbufBurstLen, 0, 0);
    AscendC::DataCopy(deqFB, workA1, dataCopyParams); // 通过DataCopy搬入C2PIPE2GM。
    AscendC::SetFixPipeConfig(deqFB); // 设置量化tensor
    AscendC::PipeBarrier<PIPE_FIX>();
}

免责声明:本站内容由 asc-devkit 仓 master 分支自动编译生成,属于持续开发版本,可能存在缺陷,仅供预览与参考。如需稳定及商用资料,请查阅官方 昇腾社区。