CANN/asc-devkit LocalTensor简介
LocalTensor简介【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkitLocalTensor用于存放AI Core中Local Memory内部存储的数据支持逻辑位置TPosition为VECIN、VECOUT、VECCALC、A1、A2、B1、B2、CO1、CO2。需要包含的头文件#include kernel_operator.h原型定义template typename T class LocalTensor : public BaseLocalTensorT { public: // PrimT用于在T传入为TensorTrait类型时萃取TensorTrait中的LiteType基础数据类型 using PrimType PrimTT; __aicore__ inline LocalTensorT() {}; #if defined(ASCENDC_CPU_DEBUG) ASCENDC_CPU_DEBUG 1 ~LocalTensor(); explicit LocalTensorT(TBuffAddr address); LocalTensorT(const LocalTensorT other); LocalTensorT operator (const LocalTensorT other); PrimType* GetPhyAddr(const uint32_t offset) const; PrimType* GetPhyAddr() const; __inout_pipe__(S) PrimType GetValue(const uint32_t offset) const; __inout_pipe__(S) PrimType operator()(const uint32_t offset) const; template typename CAST_T __aicore__ inline LocalTensorCAST_T ReinterpretCast() const; template typename T1 __inout_pipe__(S) void SetValue(const uint32_t index, const T1 value) const; LocalTensor operator[](https://gitcode.com/cann/asc-devkit/blob/f35dfef9af78af31a0418d6061f7969c5ffc6990/docs/api/context/const uint32_t offset?utm_sourcegitcode_repo_files) const; template typename T1 void SetAddrWithOffset(LocalTensorT1 src, uint32_t offset); inline void Print(); inline void Print(uint32_t len); int32_t ToFile(const std::string fileName) const; #else __aicore__ inline uint64_t GetPhyAddr() const; __aicore__ inline uint64_t GetPhyAddr(const uint32_t offset) const; __aicore__ inline __inout_pipe__(S) PrimType GetValue(const uint32_t index) const; __aicore__ inline __inout_pipe__(S) __ubuf__ PrimType operator()(const uint32_t offset) const; template typename CAST_T __aicore__ inline LocalTensorCAST_T ReinterpretCast() const; template typename T1 __aicore__ inline __inout_pipe__(S) void SetValue(const uint32_t index, const T1 value) const; __aicore__ inline LocalTensor operator[](https://gitcode.com/cann/asc-devkit/blob/f35dfef9af78af31a0418d6061f7969c5ffc6990/docs/api/context/const uint32_t offset?utm_sourcegitcode_repo_files) const; template typename T1 [[deprecated(NOTICE: SetAddrWithOffset has been deprecated and will be removed in the next version. Please do not use it!)]] __aicore__ inline void SetAddrWithOffset(LocalTensorT1 src, uint32_t offset); #endif __aicore__ inline LocalTensorT(AscendC::TPosition pos, uint32_t addr, uint32_t tieSize); __aicore__ inline int32_t GetPosition() const; __aicore__ inline void SetSize(const uint32_t size); __aicore__ inline uint32_t GetSize() const; [[deprecated(NOTICE: GetLength has been deprecated and will be removed in the next version. Please do not use it!)]] __aicore__ inline uint32_t GetLength() const; __aicore__ inline void SetBufferLen(uint32_t dataLen); __aicore__ inline void SetUserTag(const TTagType tag); __aicore__ inline TTagType GetUserTag() const; ... __aicore__ inline void SetShapeInfo(const ShapeInfo shapeInfo); __aicore__ inline ShapeInfo GetShapeInfo() const; ... };模板参数表 1模板参数说明参数名描述T类型T可以支持基础数据类型以及TensorTrait类型但需要遵循使用此LocalTensor接口的数据类型支持情况。特别地针对根据指定的逻辑位置/地址/长度返回Tensor对象的构造函数类型T仅支持基础数据类型。【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考