microsoft / microsoft/onnxruntime
Catching errors due to input datatype mismatch [Web]
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
### Describe the issue
ONNX web throws javascript errors for input type mismatch, however all such errors raise the same generic error: `Error: failed to call OrtRun(). error code = 2.`. If I look in logs I can see it logging more specific context for the error, eg.: `Unexpected input data type. Actual: (tensor(double)) , expected: (tensor(int64))`, but I am unable to get a handle to this context to surface it downstream.
Is it possible to recompile the WASM module to surface this more descriptive error context, or is there some workaround you can think of?
### To reproduce
```
import { InferenceSession } from 'onnxruntime-web';
var session = await InferenceSession.create(modelName)
try {
await session.run(wrongTypeInput)
} catch (error) {
console.log(`caught error: ${error}`)
}
```
In console:
```
Unexpected input data type. Actual: (tensor(double)) , expected: (tensor(int64))
caught error: Error: failed to call OrtRun(). error code = 2.
```
### Urgency
_No response_
### ONNX Runtime Installation
Released Package
### ONNX Runtime Version or Commit ID
1.15.0
### Execution Provider
WASM
Contributor guide
Research direction
Start with the onnxruntime-web InferenceSession.create and session.run flow, then trace how the WASM module reports the input datatype mismatch. Reproduce the example using wrongTypeInput and compare the logged context with the caught error. Done means the descriptive actual and expected tensor types are available to downstream JavaScript callers instead of only the generic OrtRun error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, wasm
- Domain
- machine-learning, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100