microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a6012b383e329c194ba2a3e21368a409800eb8ab

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/new_operator.md

27lines · modecode

1# Add a Custom Operator in ONNXRuntime-Extensions
2
3Before implement a custom operator, you get the ONNX model with one or more ORT custom operators, created by ONNX converters, [ONNX-Script](https://github.com/microsoft/onnx-script), or [ONNX model API](https://onnx.ai/onnx/api/helper.html) and etc..
4
5
6## 1. Generate the C++ template code of the Custom operator from the ONNX Model (optional)
7 python -m onnxruntime-extensions.cmd --cpp-gen <model_path> <repository_dir>`
8If you are familiar with the ONNX model detail, you create the custom operator C++ classes directly.
9
10
11## 2. Implement the CustomOp Kernel Compute method in the generated C++ files.
12the custom operator kernel C++ code exmaple can be found [operators](../operators/) folder, like [KernelGaussianBlur](../operators/cv2/gaussian_blur.hpp). All C++ APIs that can be used in the kernel implmentation are listed below
13
14* [ONNXRuntime Custom API docs](https://onnxruntime.ai/docs/api/c/struct_ort_custom_op.html)
15* the third libraries API docs intergrated in ONNXRuntime Extensions the can be used in C++ code
16 - OpenCV API docs https://docs.opencv.org/4.x/
17 - Google SentencePiece Library docs https://github.com/google/sentencepiece/blob/master/doc/api.md
18 - dlib(matrix and ML library) C++ API docs http://dlib.net/algorithms.html
19 - BlingFire Library https://github.com/microsoft/BlingFire
20 - Google RE2 Library https://github.com/google/re2/wiki/CplusplusAPI
21 - JSON library https://json.nlohmann.me/api/basic_json/
22
23## 3. Build and Test
24- The unit tests can be implemented as Python or C++, check [test](../test) folder for more examples
25- Check [build-package](./development.md) on how to build the different langauage package to be used for production.
26
27Please check the [contribution](../README.md#contributing) to see if it is possible to contribute the custom operator to onnxruntime-extensions.
28