流程主要包括算子分析、核函数定义、根据矢量编程范式实现算子类。
Sinh算子,输入x,输出y,数据类型float16,数据排布格式为ND,核函数名称为sinh_custom。
算子分析
算子表达式:y = (e^x + e^(-x)) / 2.0
使用的接口:数据搬运接口Datacopy,使用LocalTensor,需要用队列进行管理,Deque和Enque接口;数据计算接口:Exp、Add、Reciprocal、Muls。
核函数定义:在核函数实例化Sinh_custom类,然后用内置宏标识。
核函数实现

对于算子工程,用户需要先编写算子脚本,主要内容包含算子名称,输入和输出的数据类型和格式,创建好以后,使用msopgen工具生成算子工程:
${INSTALL_DIR}/python/site-packages/bin/msopgen gen -i $HOME/sample/add_custom.json -c ai_core-<soc_version> -lan cpp -out $HOME/sample/AddCustom
Host侧的Tiling实现如下:

Kernel侧需要动态获取tiling。

CMakePresets.json文件,需要修改Ascend所在的文件路径。
修改完成后,可以执行./build.sh进行编译了。
算子部署操作:
./custom_opp_<target os>_<target architecture>.run --install-path=<path>
流程主要包括算子分析、核函数定义、根据矢量编程范式实现算子类。
Sinh算子,输入x,输出y,数据类型float16,数据排布格式为ND,核函数名称为sinh_custom。
算子分析
算子表达式:y = (e^x + e^(-x)) / 2.0
使用的接口:数据搬运接口Datacopy,使用LocalTensor,需要用队列进行管理,Deque和Enque接口;数据计算接口:Exp、Add、Reciprocal、Muls。
核函数定义:在核函数实例化Sinh_custom类,然后用内置宏标识。
核函数实现
对于算子工程,用户需要先编写算子脚本,主要内容包含算子名称,输入和输出的数据类型和格式,创建好以后,使用msopgen工具生成算子工程:
${INSTALL_DIR}/python/site-packages/bin/msopgen gen -i $HOME/sample/add_custom.json -c ai_core-<soc_version> -lan cpp -out $HOME/sample/AddCustom
Host侧的Tiling实现如下:

Kernel侧需要动态获取tiling。
CMakePresets.json文件,需要修改Ascend所在的文件路径。
修改完成后,可以执行./build.sh进行编译了。
算子部署操作:
./custom_opp_<target os>_<target architecture>.run --install-path=<path>