CANN/Ascend C固定管道配置API

📅 2026/7/15 15:34:24
CANN/Ascend C固定管道配置API
SetFixPipeConfig产品支持情况产品是否支持Ascend 950PR/Ascend 950DT√Atlas A3 训练系列产品 / Atlas A3 推理系列产品√Atlas A2 训练系列产品 / Atlas A2 推理系列产品√Atlas 200I/500 A2 推理产品√Atlas 推理系列产品 AI CorexAtlas 推理系列产品 Vector CorexAtlas 训练系列产品xKirin X90√Kirin 9030√功能说明DataCopyCO1-GM、CO1-A1过程中进行随路量化时通过调用该接口设置量化流程中tensor量化参数。函数原型template typename T __aicore__ inline void SetFixPipeConfig(const LocalTensorT reluPre, const LocalTensorT quantPre, bool isUnitFlag false) template typename T, bool setRelu false __aicore__ inline void SetFixPipeConfig(const LocalTensorT preData, bool isUnitFlag false)参数说明表 1模板参数说明参数名描述T操作数的数据类型。setRelu针对设置一个tensor的情况当setRelu为true时设置reluPre反之设置quantPre。setRelu当前仅支持设置为false。表 2参数说明参数名称输入/输出含义reluPre输入源操作数relu操作时参与计算的tensor类型为LocalTensor支持的TPosition为C2PIPE2GM。reluPre为预留参数暂未启用为后续的功能扩展做保留传入一个空LocalTensor即可。quantPre输入源操作数quant tensor量化操作时参与计算的tensor类型为LocalTensor支持的TPosition为C2PIPE2GM。isUnitFlag输入UnitFlag清空标志位默认值为false。通过以内存块为粒度实现精细化的数据同步从而有效降低同步延迟提升系统整体性能。当UnitFlag开关打开后 对于L0C中的每个内存块512B提供一个单元标志位用于指示该块是否可读或可写。false关闭UnitFlag配置。true打开UnitFlag配置。preData输入支持设置一个Tensor通过开关控制是relu Tensor还是quant Tensor支持的TPosition为C2PIPE2GM。当前仅支持传入quant Tensor。约束说明quantPre和reluPre必须是Fixpipe Buffer上的Tensor。返回值说明无调用示例完整示例可参考完整示例。__aicore__inline void SetFPC(const LocalTensor int32_t reluPreTensor, const LocalTensor int32_t quantPreTensor) { AscendC::LocalTensoruint64_t workA1 inQueueDeqA1.AllocTensoruint64_t(); uint16_t deqSize 128; // deq tensor的size AscendC::DataCopy(workA1, deqGlobal, deqSize); // deqGlobal为量化系数的gm地址 AscendC::LocalTensoruint64_t deqFB inQueueDeqFB.AllocTensoruint64_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::PipeBarrierPIPE_FIX(); }创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考