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

CANN/asc-devkit向量减法ReLU函数

asc_sub_relu

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

产品支持情况

产品是否支持
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品

功能说明

按元素求差,再进行Relu计算(结果和0对比取较大值),并提供转换最终结果的数据类型的功能(s162s8、f322f16、f162s8)。计算公式如下:

$$ dst_i = Relu(src0_i -src1_i) $$

函数原型

  • 前n个数据计算

    __aicore__ inline void asc_sub_relu(__ubuf__ int16_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count) __aicore__ inline void asc_sub_relu(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) __aicore__ inline void asc_sub_relu(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_sub_relu(__ubuf__ int8_t* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) __aicore__ inline void asc_sub_relu(__ubuf__ half* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_sub_relu(__ubuf__ int8_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count)
  • 高维切分计算

    __aicore__ inline void asc_sub_relu(__ubuf__ int16_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_sub_relu(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_sub_relu(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_sub_relu(__ubuf__ int8_t* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_sub_relu(__ubuf__ half* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_sub_relu(__ubuf__ int8_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride)
  • 同步计算

    __aicore__ inline void asc_sub_relu_sync(__ubuf__ int16_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count) __aicore__ inline void asc_sub_relu_sync(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) __aicore__ inline void asc_sub_relu_sync(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_sub_relu_sync(__ubuf__ int8_t* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) __aicore__ inline void asc_sub_relu_sync(__ubuf__ half* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_sub_relu_sync(__ubuf__ int8_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count)

参数说明

参数名输入/输出描述
dst输出目的操作数(矢量)的起始地址。
src0输入源操作数(矢量)的起始地址。
src1输入源操作数(矢量)的起始地址。
count输入参与计算的元素个数。
repeat输入迭代次数。
dst_block_stride输入目的操作数单次迭代内不同DataBlock间地址步长。
src0_block_stride输入源操作数0单次迭代内不同DataBlock间地址步长。
src1_block_stride输入源操作数1单次迭代内不同DataBlock间地址步长。
dst_repeat_stride输入目的操作数相邻迭代间相同DataBlock的地址步长。
src0_repeat_stride输入源操作数0相邻迭代间相同DataBlock的地址步长。
src1_repeat_stride输入源操作数1相邻迭代间相同DataBlock的地址步长。

返回值说明

流水类型

PIPE_V

约束说明

  • dst、src0、src1的起始地址需要32字节对齐。
  • 操作数地址重叠约束请参考通用地址重叠约束。

调用示例

// 目的操作数和源操作数的数据类型一致 // total_length指参与计算的数据长度 constexpr uint32_t total_length = 128; __ubuf__ half src0[total_length]; __ubuf__ half src1[total_length]; __ubuf__ half dst[total_length]; asc_sub_relu(dst, src0, src1, total_length);
// 目的操作数和源操作数的数据类型不一致(s162s8) // total_length 指参与计算的数据长度 constexpr uint64_t total_length = 256; __ubuf__ int16_t src0[total_length]; __ubuf__ int16_t src1[total_length]; __ubuf__ int8_t dst[total_length]; asc_sub_relu(dst, src0, src1, total_length);

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

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

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

相关文章:

  • 我们只能要求手机在拍摄的时候呈现45度-----采用常用模型
  • Tacacs+协议报文解密与全流程实战抓包解析
  • Groundhog:基于Git仓库的开发者时间自动追踪工具
  • 大语言模型评测框架解析:从公平对比到工程选型实践
  • 视频技术演进:从模拟到数字的革命与压缩技术解析
  • FiveM服务器智能运维:基于CoPaw多智能体的自动化技能包实战
  • “内存对比工具V2.6版”的基础功能说明!
  • 人脸检测主流模型----第一名---占有率90%---MIT协议
  • 机器视觉(MV)与机器人视觉(RV)的本质区别(4)
  • 8.4.3 开始屏幕和任务栏的优化:StartAllBack 找回高效 Windows 11 使用体验
  • 别再傻傻切片了!PyTorch Tensor高级索引实战:用index_select、masked_select和gather提升数据处理效率
  • WebGLM:开源高效的网络增强问答系统架构解析与部署实践
  • 【Prometheus】 如何处理指标名称或标签中包含特殊字符的情况?
  • AI赋能区域创新评估:融合记分板与政策文本分析的协同框架与实践
  • Stable Mean Teacher for Semi-supervised Video Action Detection
  • Spring 第四天:AOP 面向切面编程与声明式事务管理
  • AI赋能风景园林设计:技术原理、实践案例与未来挑战
  • crawdad-openclaw:开源通用爬虫框架的设计、实战与工程化部署
  • Arm GNU工具链技术解析与实战应用指南
  • 大厂IT面试通关:简历优化+高频面试题拆解(2026最新版)
  • 机器学习在非洲传染病预测与监测中的实战应用
  • 三、进程概念(操作系统与进程(1))
  • Install ncdu Disk Usage Analyzer on Linux
  • ARM710a处理器架构与性能优化实战解析
  • 【C#】 HTTP 请求通讯实现指南
  • MCP TypeScript SDK 服务说明文档
  • STM32——OLED显示字符串
  • 量子自旋冰的Dirac弦约束与蒙特卡洛模拟研究
  • 告别配置烦恼:用CMake管理你的Qt + Eigen项目(附完整CMakeLists.txt)
  • 机器学习在非洲公共卫生疾病预测中的实战应用与技术解析