代码拉取完成,页面将自动刷新
AscendC 自定义算子入Onnx网络示例教程: 以leakyrelu单算子离线推理为例 推理平台:Ascend310P3
└── OnnxInvocation // 通过onnx网络调用的方式调用LeakyReluCustom算子
└── leaky_relu.py // 生成单算子onnx模型的文件
1.在LeakyReluCustom目录下执行编译操作,编译出算子run包
2.安装在LeakyReluCustom/build_out/目录下生成的自定义算子run包。
1.获取单算子onnx模型, 该模型参考leaky_relu.py生成
wget https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/AscendC/leaky_relu.onnx
2.onnx模型转换为om模型
For Ascend310P3:
atc --model=./leaky_relu.onnx --framework=5 --soc_version=Ascend310P3 --output=./leaky_relu --input_shape="X:8,16,1024" --input_format=ND
若出现: start compile Ascend C operator LeakyReluCustom. kernel name is leaky_relu_custom compile Ascend C operator: LeakyReluCustom success! 打印,表明进入了AscendC算子编译
若出现: ATC run success, welcome to the next use 表明离线om模型转换成功
3.执行离线推理 可使用https://gitee.com/ascend/tools/tree/master/msame 工具进行推理验证
时间 | 更新事项 |
---|---|
2023/5/15 | 更新目录结构 |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。