DeQue【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况Ascend 950PR/Ascend 950DT支持Atlas A3 训练系列产品/Atlas A3 推理系列产品支持Atlas A2 训练系列产品/Atlas A2 推理系列产品支持Atlas 200I/500 A2 推理产品支持Atlas 推理系列产品AI Core支持Atlas 推理系列产品Vector Core不支持Atlas 训练系列产品支持Kirin X90支持Kirin 9030支持功能说明头文件路径为basic_api/kernel_tpipe.h。将Tensor从队列中取出用于后续处理。函数原型无需指定源和目的位置non-inplace接口将入队的LocalTensor地址从队列中取出赋值给新创建的Tensor并返回。template typename T __aicore__ inline LocalTensorT DeQue()inplace接口通过出参的方式返回可以减少Tensor反复创建的开销具体使用指导可参考Tensor原地操作。template typename T __aicore__ inline void DeQue(LocalTensorT tensor)需要指定源和目的位置通过TQueBind绑定VECIN和VECOUT可实现VECIN和VECOUT内存复用如下接口用于存在Vector计算的场景下实现复用在出队时需要指定源和目的位置不存在Vector计算的场景下可直接调用LocalTensorT DeQue()出队接口。template TPosition srcUserPos, TPosition dstUserPos, typename T __aicore__ inline LocalTensorT DeQue()参数说明表1模板参数说明参数名说明TTensor的数据类型支持的类型请见LocalTensor相关描述。srcUserPos用户指定队列的src position当前只支持如下通路GM-UBVECIN/VECOUT-GM。dstUserPos用户指定队列的dst position当前只支持如下通路GM-UBVECIN/VECOUT-GM。表2参数说明参数名称输入/输出含义tensor输出inplace接口需要通过出参的方式返回Tensor。约束说明对空队列执行DeQue是一种异常行为会在CPU调测时报错。non-inplace接口和指定源和目的位置的接口需要将TQueBind的depth模板参数设置为非零值inplace接口需要将TQueBind的depth模板参数设置为0。返回值说明non-inplace接口和指定源和目的位置的接口返回值为从队列中取出的LocalTensorinplace接口没有返回值。调用示例// 接口: DeQue Tensor AscendC::TPipe pipe; AscendC::TQueAscendC::TPosition::VECOUT, 4 que; int num 4; int len 1024; pipe.InitBuffer(que, num, len); AscendC::LocalTensorhalf tensor1 que.AllocTensorhalf(); que.EnQue(tensor1); AscendC::LocalTensorhalf tensor2 que.DeQuehalf(); // 将tensor从VECOUT的Queue中搬出 // 接口: DeQue Tensor指定特定的Src/Dst position AscendC::TPipe pipe; AscendC::TQueBindAscendC::TPosition::VECIN, AscendC::TPosition::VECOUT, 1 que; int num 4; int len 1024; pipe.InitBuffer(que, num, len); AscendC::LocalTensorhalf tensor1 que.AllocTensorhalf(); que.EnQueAscendC::TPosition::GM, AscendC::TPosition::VECIN, half(tensor1); // 将tensor从VECIN的Queue中搬出 AscendC::LocalTensorhalf tensor2 que.DeQueAscendC::TPosition::GM, AscendC::TPosition::VECIN, half(); // inplace接口 AscendC::TPipe pipe; AscendC::TQueAscendC::TPosition::VECOUT, 0 que; int num 2; int len 1024; pipe.InitBuffer(que, num, len); AscendC::LocalTensorhalf tensor1; que.AllocTensorhalf(tensor1); que.EnQue(tensor1); que.DeQuehalf(tensor1); // 将tensor从VECOUT的Queue中搬出 que.FreeTensorhalf(tensor1);【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考