microsoft / microsoft/onnxruntime

Catching errors due to input datatype mismatch [Web]

Open
#15,683 1 comment 0 reactions 0 assignees View on GitHub
api:Javascript contributions welcome platform: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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.