SetFixPipeConfig
产 品 支 持 情 况
功 能 说 明
DataCopy(CO1->GM、CO1->A1)过 程 中 进 行 随 路 量 化 时,通 过 调 用 该 接 口 设 置 量 化 流 程 中tensor量 化 参 数。
函 数 原 型
Text
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 模 板 参 数 说 明
针 对 设 置 一 个tensor的 情 况,当setRelu为true时,设 置reluPre;反 之 设 置quantPre。setRelu当 前 仅 支 持 设 置 为false。 |
表 2 参 数 说 明
约 束 说 明
quantPre和reluPre必 须 是Fixpipe Buffer上 的Tensor。
返 回 值 说 明
无
调 用 示 例
完 整 示 例 可 参 考完 整 示 例。
Text
__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>();
}