Skip to content

How do we get ort to support a custom ONNX operator? #151

Answered by decahedron1
ksngc asked this question in Q&A
Discussion options

You must be logged in to vote

(3) how to write this same ONNX operator in ONNX Runtime via C++ and then run inference

What's the easiest way to do (3), but using this library (i.e., ort for Rust)?

You can achieve this by writing a custom operator library with the C++ API. See onnxruntime-extensions for an example of how this is done.

To then load the custom operator library in ort, enable ort's custom-ops feature:

[dependencies]
ort = { version = "2.0.0-rc.0", features = [ "custom-ops" ] } 

In your code, register your custom operator's library on the SessionBuilder:

let session = Session::builder()?
    .with_custom_ops_lib("my_ops_lib")?
    .with_model_from_file("example.onnx")?;

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by decahedron1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants