-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Et 4299 try onnx runtime #1041
Et 4299 try onnx runtime #1041
Conversation
bert/Cargo.toml
Outdated
@@ -14,6 +14,7 @@ lindera-core = "0.25.0" | |||
lindera-dictionary = "0.25.0" | |||
lindera-tokenizer = "0.25.0" | |||
ndarray = { workspace = true, features = ["serde"] } | |||
onnxruntime = {version = ">=0.0.2", features = ["model-fetching"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a dev-dependency
examples, tests, benchmarks have access to dev dependencies.
let attention_mask = token_reshaper(tokens.get_attention_mask()); | ||
let type_ids = token_reshaper(tokens.get_type_ids()); | ||
let in_tensor = vec![token_ids, attention_mask, type_ids]; | ||
let outputs: Vec<OrtOwnedTensor<f32, _>> = session.run(in_tensor)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depending internal details of OrtOwnedTensor<f32, _>
and session.run(in_tensor)?
the compiler could theoretically be able to deduce that output
is not used session
(besides costing time) has no side effects and then end up eliminating the while loop 🙃
practically this is impossible to happen as session
will call C-FFI so the compiler doesn't know anymore that it doesn't have side effects etc.
still because of this you want to to pass unused output of benchmarks through std::hint::black_box
(similar const input values, but we don't have them here)
libraries like criterion
do that for you, but aren't supper trivial to use
Wrt. the issues with running it and The rust crate What that means is that the runtime must be preinstalled in the computer where you want to run it in a compatible version. E.g. when build on my system |
Wrt. running it on ARM:
|
I think you can find a prebuild blob of the microsoft onnxruntime here: https://github.com/microsoft/onnxruntime/releases/tag/v1.15.1 only issue the rust bindings seem to be servely outdated, but it might still be ABI compatible idk. we would have to try out |
was integrated in different PR AFIK |
Implements script responsible for running onnxruntime and tract comparison in the examples folder