Skip to content

wasi_nn_openvino.c: remove the tensor layout adjustment logic #4308

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yamt
Copy link
Collaborator

@yamt yamt commented Jun 2, 2025

the logic in question seems like an attempt to work around some application bugs.
my wild guess is that it was for classification-example. cf. bytecodealliance/wasmtime#10867

because wasi-nn api doesn't provide a way for users to express their intended layout, it seems impossible to "fix" it here without risking to break other applications.

btw, i suspect the condition
"if (wasi_nn_tensor->dimensions->size == 4 || ov_dims[1] == 3)" in the code in question was meant
"if (wasi_nn_tensor->dimensions->size == 4 && ov_dims[1] == 3)". this commit fixes it by removing it.

after this change, the classification-example mentioned above produces similar inferences as with wasmtime.
(i used the fixed version of tensor.bgr mentioned in bytecodealliance/wasmtime#10867)

wasm-micro-runtime with this commit:

Found results, sorted top 5: [InferenceResult(963, 0.71130574), InferenceResult(762, 0.07070772), InferenceResult(909, 0.036355656), InferenceResult(926, 0.015456188), InferenceResult(567, 0.015344019)]

wasmtime:

Found results, sorted top 5: [InferenceResult(963, 0.7113058), InferenceResult(762, 0.070707425), InferenceResult(909, 0.036355816), InferenceResult(926, 0.01545616), InferenceResult(567, 0.015344027)]

wasm-micro-runtime without this commit:

Found results, sorted top 5: [InferenceResult(505, 0.097339325), InferenceResult(459, 0.053065795), InferenceResult(849, 0.03836019), InferenceResult(582, 0.036462624), InferenceResult(725, 0.030435428)]

the logic in question seems like an attempt to work around
some application bugs.
my wild guess is that it was for classification-example.
cf. bytecodealliance/wasmtime#10867

because wasi-nn api doesn't provide a way for users to express
their intended layout, it seems impossible to "fix" it here
without risking to break other applications.

btw, i suspect the condition
"if (wasi_nn_tensor->dimensions->size == 4 || ov_dims[1] == 3)"
in the code in question was meant
"if (wasi_nn_tensor->dimensions->size == 4 && ov_dims[1] == 3)".
this commit fixes it by removing it.

after this change, the classification-example mentioned above
produces similar inferences as with wasmtime.
(i used the fixed version of tensor.bgr mentioned in
bytecodealliance/wasmtime#10867)

wasm-micro-runtime with this commit:
```
Found results, sorted top 5: [InferenceResult(963, 0.71130574), InferenceResult(762, 0.07070772), InferenceResult(909, 0.036355656), InferenceResult(926, 0.015456188), InferenceResult(567, 0.015344019)]
```

wasmtime:
```
Found results, sorted top 5: [InferenceResult(963, 0.7113058), InferenceResult(762, 0.070707425), InferenceResult(909, 0.036355816), InferenceResult(926, 0.01545616), InferenceResult(567, 0.015344027)]
```

wasm-micro-runtime without this commit:
```
Found results, sorted top 5: [InferenceResult(505, 0.097339325), InferenceResult(459, 0.053065795), InferenceResult(849, 0.03836019), InferenceResult(582, 0.036462624), InferenceResult(725, 0.030435428)]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant