TanhGrad算子样例
概述
样例概述:本样例介绍了利用ATVC实现TanhGrad单算子并验证了调试调优相关功能验证。
- 算子功能:TanhGrad
- 使用的ATVC模板:Elementwise
- 调用方式:Kernel直调
样例支持AI处理器型号
- Ascend 910C
- Ascend 910B
算子描述
算子数学计算公式:z=dy∗(1−y2)z = dy * (1 - y ^ 2)
算子规格:
| 算子类型(OpType) | TanhGrad | |||
| 算子输入 | ||||
| name | shape | data type | format | |
| dy | 8 * 1024 | float | ND | |
| y | 8 * 1024 | float | ND | |
| 算子输出 | ||||
| z | 8 * 1024 | float | ND | |
| 核函数名 | TanhGrad | |||
目录结构
| 文件名 | 描述 |
|---|---|
| tanh_grad.cpp | Tanh算子代码实现以及调用样例 |
算子基本功能验证
执行命令如下:
cd ./ops_templates/atvc/examples
bash run_examples.sh tanh_grad
算子调试调优
样例提供的主要调试调优方式如下:
- 使用
ATVC::Host::EleWiseTilingHyperParam构建超参对ATVC::Host::CalcEleWiseTiling()接口实现Tiling调优 - 使用
--run-mode=debug_print进行DFX信息打印: 执行命令如下:
cd ./ops_templates/atvc/examples
bash run_examples.sh tanh_grad --run-mode=debug_print
- 使用
--run-mode=profiling开启Profiling,获取性能数据: 执行命令如下:
cd ./ops_templates/atvc/examples
bash run_examples.sh tanh_grad --run-mode=profiling
更多详细的调试调优介绍参考ATVC开发指南的ATVC的调试调优功能章节