题目:
参考 tensorflow 的 Sinh 算子,实现 Ascend C 算子 Sinh,算子命名为
SinhCustom,并完成 aclnn 算子调用。相关算法:sinh(x)=(exp(x)-exp(-x))/
2.0
要求:
1、完成 host 侧和 kernel 侧代码实现。
2、实现 sinh 功能,支持 float16 类型输入。
3、使用内核调试符方式调用算子测试通过
4、使用单算子 API 调用方式调用 SinhCustom 算子测试通过。
提交要求:
1、完成编程后,将上述实现的工程代码打包在 rar 包内提交,如
SinhCustom.rar。
作答步骤:
完成需要做以下几步:
1. 使用 msopgen 工具生成自定义算子工程模板。
2. 在生成的模板中,实现 SinhCustom 的 host 侧和 kernel 侧代码。
3. 编译和部署自定义算子包。
4. 使用内核调试符和单算子 API 调用方式测试算子。
5. 打包工程代码并提交。
步骤 1: 使用 msopgen 生成自定义算子工程模板
msopgen gen i add custom.json -c ai_core -an c -out SinhCustom
这里 custom.json 是一个定义算子的 JSON 文件,它应该包含 SinhCustom 的输
入、输出和属性定义。
步骤 2: 实现 host 侧和 kernel 侧代码