-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[WASI-NN] Add support for a ONNXruntime backend using ort #7691
Conversation
@abrown please take a look when you have a minute. Thank you!! |
d205826
to
7201935
Compare
@devigned, I'll take a closer look next week. I will say I've been been changing the ground under your feet here (sorry 😁) with #7679; that PR will mean we have to move some of your tests over to As for the CI failures here: I think we can add a line to |
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.
Thanks for all the work to make this happen! This is going to be a great addition to Wasmtime. Let me know on Zulip if you need help working through the test refactoring, CI issues, etc.
crates/wasi-nn/examples/classification-component-onnx/src/lib.rs
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
pub fn f32_vec_to_bytes(data: Vec<f32>) -> Vec<u8> { |
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.
Maybe we should explain somewhere why we are forced to copy the tensor twice — at input and output.
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.
I'd like to find a better way of doing this rather than chunking from u8 to the type and size of the model input.
This is great, I have been testing different ONNX models and encountered a data type mismatch error for certain models, specifically at the wasi-nn compute function in bindings.rs. The error indicates a failure to parse ctx: GraphExecutionContext as i32:
As far as I can tell the ctx value is 0 when I pass it to compute, I've tried to cast it to f32, but the compiler expects a u32. Very possible I'm missing something obvious as I am fairly new to both WASM and Rust. But thought I would share. For some extra context, both models which have produced this error have been classification models (specifcially an xgboost and sklearn's SGDClassifier model) - Are there model types in ONNX format which we would never expect this to be compatible with? |
3324720
to
6c5022f
Compare
Is there any chance you could share code that reproduces this behavior, or create a branch with a failing test reproducing this behavior? |
@sunfishcode, I believe I need someone that is a trusted contributor to Wasmtime to approve the I'm not sure if the Also, if this is not how this stuff should work, please let me know :). |
4eb2d8a
to
c438db1
Compare
let's go baby |
GACK. MingGW!!! crazy amazing |
you having fun yet, @devigned ? |
Since this isn't intended to work everywhere just yet, it might be best to add a new builder on CI specifically dedicated to testing ONNX rather than trying to get it to work across all the platforms. If that works for you I'd recommend copying this to start, updating all the bits there (e.g. run on ubuntu, not on windows), and then be sure to add an entry down here to ensure we gate on it in CI. Also, what I might also recommend, if you add |
drinking booze all night now over here, best soap opera I've watched in years |
@alexcrichton, in 2b7a104 I'm reducing the set of triplets in which ONNX will run. I do not plan on pursuing riscv or s390 precompiled onnxruntime bins at this point. Are you good with the matrix-test approach or would you still prefer I break it out into another builder? |
7f7fca5
to
2b7a104
Compare
Nah if that works for you seems fine, just trying to save some CI headache. |
Signed-off-by: David Justice <david@devigned.com>
This change is the result of a long slog through the dependencies of the `ort` library. The only missing dependency is `compact_str`, which needs further discussion.
Signed-off-by: David Justice <david@devigned.com>
Signed-off-by: David Justice <david@devigned.com>
Signed-off-by: David Justice <david@devigned.com>
Signed-off-by: David Justice <david@devigned.com>
08c41f2
to
2416343
Compare
Signed-off-by: David Justice <david@devigned.com>
This change adds an ONNXruntime backend for WASI-NN. Since there is only one backend implemented, this will help to move the standardization of this proposal forward.
Also, the example usage of the ONNXruntime backend shows how to build a component using WASI-NN and ONNXruntime.