Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ghfund4_b52
ONNX
Commits
c47062fc
Commit
c47062fc
authored
May 13, 2025
by
ghfund4_b52
Browse files
Update readme.md
parent
b3e3ac37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
readme.md
readme.md
+21
-4
No files found.
readme.md
View file @
c47062fc
...
@@ -2,11 +2,15 @@
...
@@ -2,11 +2,15 @@
# Custom Op ONNXRuntime
# Custom Op ONNXRuntime
## Purpose
## Purpose
`Adding the custom operator implementation and registering it in ONNX Runtime`
`Adding the custom operator implementation and registering it in ONNX Runtime`
## 环境配置
## 环境配置
### Docker(方法一)
### Docker(方法一)
拉取镜像:
拉取镜像:
```
plaintext
```
plaintext
...
@@ -20,6 +24,7 @@ docker run --shm-size 16g --network=host --name=test --privileged --device=/dev/
...
@@ -20,6 +24,7 @@ docker run --shm-size 16g --network=host --name=test --privileged --device=/dev/
```
```
### Dockerfile(方法二)
### Dockerfile(方法二)
```
```
cd ./docker
cd ./docker
docker build --no-cache -t customop:test .
docker build --no-cache -t customop:test .
...
@@ -28,16 +33,20 @@ docker run --shm-size 16g --network=host --name=video_ort --privileged --device=
...
@@ -28,16 +33,20 @@ docker run --shm-size 16g --network=host --name=video_ort --privileged --device=
```
```
## 使用
## 使用
### 编译工程
### 编译工程
```
```
git clone http://developer.sourcefind.cn/codes/modelzoo/customop_onnxruntime.git
git clone http://developer.sourcefind.cn/codes/modelzoo/customop_onnxruntime.git
cd customop_onnxruntime
cd customop_onnxruntime
python model.py // 生成模型
python model.py // 生成模型
(model换成自己算子的模型)
bash compile.sh // 编译生成算子库
bash compile.sh // 编译生成算子库
```
```
### 运行示例
### 运行示例
1.
目录
1.
目录
```
```
rocm_custom_op
rocm_custom_op
├── compile.sh // 编译脚本
├── compile.sh // 编译脚本
...
@@ -45,7 +54,7 @@ rocm_custom_op
...
@@ -45,7 +54,7 @@ rocm_custom_op
├── custom_op_library.h
├── custom_op_library.h
├── docker
├── docker
├── include
├── include
├── model.py // 创建自定义模型
├── model.py // 创建自定义模型
(需要改名)
├── readme.md
├── readme.md
├── rocm_ops.cc // 调用自定义算子
├── rocm_ops.cc // 调用自定义算子
├── rocm_ops.h
├── rocm_ops.h
...
@@ -54,14 +63,16 @@ rocm_custom_op
...
@@ -54,14 +63,16 @@ rocm_custom_op
```
```
2.
执行步骤
2.
执行步骤
```
```
python test.py // 测试模型
python test.py // 测试模型
```
```
3.
备注
3.
备注
```
```
1.在model.py中,定义了一个add.onnx模型。如需重新定义模型,请修改该文件。
1.在model.py中,定义了一个add.onnx模型。如需重新定义模型,请修改该文件。
2.在compile.sh中,选项--offload-arch=gfx9
06
,请将gfx9
06
替换为本机适配的rocm架构(可用rocminfo | grep gfx查看)。
2.在compile.sh中,选项--offload-arch=gfx9
28
,请将gfx9
28
替换为本机适配的rocm架构(可用rocminfo | grep gfx查看)。
3.若需测试别的自定义算子,修改内容如下:
3.若需测试别的自定义算子,修改内容如下:
3.1 修改rocm_ops.hip,重新实现自定义算子
3.1 修改rocm_ops.hip,重新实现自定义算子
3.2 修改rocm_ops.cc, 修改对自定义算子的调用
3.2 修改rocm_ops.cc, 修改对自定义算子的调用
...
@@ -70,18 +81,24 @@ python test.py // 测试模型
...
@@ -70,18 +81,24 @@ python test.py // 测试模型
```
```
## result
## result
无
无
### 精度
### 精度
无
无
## 应用场景
## 应用场景
### 功能
### 功能
添加ORT custom op
添加ORT custom op
## 源码仓库及问题反馈
## 源码仓库及问题反馈
-
http://developer.sourcefind.cn/codes/modelzoo/customop_onnxruntime.git
-
http://developer.sourcefind.cn/codes/modelzoo/customop_onnxruntime.git
## 参考资料
## 参考资料
-
https://github.com/microsoft/onnxruntime
-
https://github.com/microsoft/onnxruntime
-
https://onnxruntime.ai/docs/extensions/add-op.html
-
https://onnxruntime.ai/docs/extensions/add-op.html
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment