CANN/asc-devkit LocalMemAllocator简介
📅 2026/7/17 16:08:35
👁️ 阅读次数
📝 编程学习
LocalMemAllocator简介
【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit
LocalMemAllocator是在使用静态Tensor编程时用于内存管理的类,用户无需构建TPipe/TQue,而是直接创建LocalTensor对象(也可以直接通过LocalTensor构造函数进行构造)并开发算子,从而减少运行时的开销,实现更优的性能。
LocalMemAllocator仅支持在Ascend C静态Tensor编程方式中使用,不可以与TPipe等接口混用。
需要包含的头文件
#include "kernel_operator.h"原型定义
template<Hardware hard = Hardware::UB> class LocalMemAllocator { public: __aicore__ inline LocalMemAllocator(); __aicore__ inline uint32_t GetCurAddr() const; template <class DataType, uint32_t tileSize> LocalTensor<DataType> __aicore__ inline Alloc(); template <TPosition pos, class DataType, uint32_t tileSize> __aicore__ inline LocalTensor<DataType> Alloc(); template <class DataType> LocalTensor<DataType> __aicore__ inline Alloc(uint32_t tileSize); template <TPosition pos, class DataType> LocalTensor<DataType> __aicore__ inline Alloc(uint32_t tileSize); template <class DataType> LocalTensor<DataType> __aicore__ inline Alloc(); };模板参数
表1模板参数说明
【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
编程学习
技术分享
实战经验