c4696245创建于 2025年11月15日历史提交
文件最后提交记录最后更新时间
7 个月前
7 个月前
7 个月前
7 个月前
7 个月前
README.md

ReluWithReduceSum算子样例

概述

样例概述:本样例介绍了利用ATVC实现ReduceSum+Elementwise算子并完成功能验证,此算子精度适用遵循reduce的精度范围。

  • 算子功能:ReduceSum算子前置添加Add和后置添加Relu自定义算子
  • 使用的ATVC模板:带前后Elementwise计算的Reduce模板
  • 调用方式:Kernel直调

样例支持AI处理器型号

  • Ascend 910C
  • Ascend 910B

算子描述

该自定义算子数学计算公式为:

y={0if reduceSum(x + 1) < 0reduceSum(x+1)if reduceSum(x + 1) ≥ 0 y = \begin{cases} 0& \text{if reduceSum(x + 1) < 0}\\ reduceSum(x + 1)& \text{if reduceSum(x + 1) ≥ 0} \end{cases}

算子规格:

算子类型(OpType)ReluWithReduceSum
算子输入
nameshapedata typeformat
x8 * 1024floatND
算子输出
y1 * 1024floatND
核函数名ReluWithReduceSum

目录结构

文件名 描述
relu_with_reduce_sum.cpp 算子代码实现以及调用样例
relu_with_reduce_sum.h 算子代码实现头文件
pre_compute_add_with_reduce_sum.h 前置Elementwise计算
post_compute_relu_with_reduce_sum.h 后置Elementwise计算

算子运行

在ascendc-api-adv代码仓目录下执行:

cd ./ops_templates/atvc/examples
bash run_examples.sh relu_with_reduce_sum