Skip to content

wasi-nn: support all tensor types for ONNX inputs - #15056

Open
ChihweiLHBird wants to merge 1 commit into
bytecodealliance:mainfrom
ChihweiLHBird:wasi-nn-onnx-input-types
Open

ChihweiLHBird wants to merge 1 commit into
bytecodealliance:mainfrom
ChihweiLHBird:wasi-nn-onnx-input-types

Conversation

@ChihweiLHBird

Copy link
Copy Markdown
Contributor

The ONNX backend can decode only f32 input tensors. For other types, compute returns UnsupportedTensorType, so models that take i64 token IDs cannot run.

This change decodes input tensors of all seven wasi-nn tensor types with one generic helper. For f16 and bf16, it turns on the half feature of ort and adds half as a dependency. half 2.4.1 is already in Cargo.lock, so no new crate comes in. The setup step now also accepts models with f16 and bf16 tensors. The change also removes bytes_to_f32_vec, which has no users now.

Outputs are still f32 only. That can be a follow-up.

CI does not run the wasi-nn tests. To run the new unit tests:

cargo test -p wasmtime-wasi-nn --features onnx-download --lib

The ONNX backend can decode only `f32` input tensors. For other types,
`compute` returns `UnsupportedTensorType`, so models that take `i64`
token IDs cannot run.

This change decodes input tensors of all seven wasi-nn tensor types.
For `f16` and `bf16`, it uses the `half` crate through the `half`
feature of `ort`. The setup step now also accepts models with these
types. The change also removes `bytes_to_f32_vec`, which has no users
now.
@ChihweiLHBird
ChihweiLHBird requested review from a team as code owners October 29, 2026 06:42
@ChihweiLHBird
ChihweiLHBird requested review from fitzgen and rvolosatovs and removed request for a team October 29, 2026 06:42
@ChihweiLHBird

Copy link
Copy Markdown
Contributor Author

CC: @rahulchaphalkar

@ChihweiLHBird

Copy link
Copy Markdown
Contributor Author

CC: @alexcrichton

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant