当前位置: 首页 > news >正文

CANN/asc-devkit LocalTensor简介

LocalTensor简介

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

LocalTensor用于存放AI Core中Local Memory(内部存储)的数据,支持逻辑位置TPosition为VECIN、VECOUT、VECCALC、A1、A2、B1、B2、CO1、CO2。

需要包含的头文件

#include "kernel_operator.h"

原型定义

template <typename T> class LocalTensor : public BaseLocalTensor<T> { public: // PrimT用于在T传入为TensorTrait类型时萃取TensorTrait中的LiteType基础数据类型 using PrimType = PrimT<T>; __aicore__ inline LocalTensor<T>() {}; #if defined(ASCENDC_CPU_DEBUG) && ASCENDC_CPU_DEBUG == 1 ~LocalTensor(); explicit LocalTensor<T>(TBuffAddr& address); LocalTensor<T>(const LocalTensor<T>& other); LocalTensor<T> operator = (const LocalTensor<T>& 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 LocalTensor<CAST_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_source=gitcode_repo_files) const; template <typename T1> void SetAddrWithOffset(LocalTensor<T1> &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 LocalTensor<CAST_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_source=gitcode_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(LocalTensor<T1> &src, uint32_t offset); #endif __aicore__ inline LocalTensor<T>(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),仅供参考

http://www.jsqmd.com/news/797473/

相关文章:

  • 别再复制粘贴了!手把手教你用C语言实现USB数据包的CRC-16校验(附完整源码和测试用例)
  • 文科生适合学数据分析吗?哪些岗位更友好
  • 推荐一个免费在线音频编辑器,像剪映一样好用
  • 如何快速掌握B站字幕下载工具:面向初学者的完整指南
  • 2025-2026年淮安注册公司联系电话推荐:精选服务与联系指南 - 品牌推荐
  • 上海国产化软件测评怎么过 关键看这三点
  • 银灿IS903主控U盘量产翻车实录:从检测VID/PID到成功修复的避坑指南
  • 影刀RPA实现指纹浏览器下拼多多店群自动化
  • SleeperX:重新定义Mac电源管理的5个智能控制维度
  • 在唯与阿之间守住边界,老子之问给 SAP RAP 开发的一盏灯
  • 别再只会看图表了!Grafana面板调试的10个隐藏技巧(附Graph/Stat/Gauge面板实战)
  • 书匠策AI实测手记:我用48小时“跑“完了大学四年都没搞明白的课程论文写作全流程
  • CentOS7 图形化桌面 + EasyConnect 一站式部署指北
  • PyTorch DataLoader的collate_fn:从默认行为到自定义,搞定不规则数据集的完整指南
  • 2026龙山源公墓及长三角优质墓园推荐指南 - 速递信息
  • 如何在OpenDAN上配置本地LLM模型:LLaMa完整安装指南
  • FactoryIO仿真入门:手把手教你用Python Modbus库实现‘Sort by Weight’分拣控制
  • 2026年5月扭矩传感器十大品牌厂家重磅发布,东莞南力精准驭扭动力核心 - 品牌速递
  • 【信息科学与工程学】【解决方案体系】第五十篇 社交平台系统工程模型01
  • 如何告别手动抢购?Campus-imaotai智能预约系统全解析
  • 数字多媒体哪家品牌更值得关注 - 品牌排行榜
  • 暗黑破坏神2存档编辑器:5分钟打造你的完美游戏角色
  • 从眨眼到打哈欠:手把手教你用Dlib和OpenCV实现驾驶员疲劳检测(Python实战)
  • 2025-2026年淮安注册公司联系电话推荐:靠谱选择与使用须知 - 品牌推荐
  • 树莓派串口实战:从电平差异到Python控制LED
  • RK3588+TRL8367s 四网口千兆交换机调试
  • EPSON RC+ 7.0 编程初体验:从编译报错‘Jump daiji’到第一个动起来的虚拟机械臂
  • 拆解一个开源示波器:跟着Scopefun原理图,手把手学模拟前端与ADC选型
  • 保姆级避坑指南:用ESP32驱动ILI9341触摸屏跑LVGL,从接线到Demo一气呵成
  • ElevenLabs企业API网关配置黄金法则:5步实现毫秒级语音响应+零P99抖动,附LinkedIn实测压测报告(含JMeter脚本)