microsoft / microsoft/onnxruntime

[Feature Request] Report error codes that represent critical errors, such as device-removal

Open
#26,648 2 comments 1 reaction 0 assignees View on GitHub
ep:WebNN feature request
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the feature request

**Is there any plan to report more specific error code values for critical errors such as “device-removal” , “device-reset” and “out of memory”?**

I looked into the ORT repo, I found that the [OrtErrorCode](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/include/onnxruntime/core/session/onnxruntime_c_api.h#L254) values returned by ORT API like `ORT_FAIL`and `ORT_RUNTIME_EXCEPTION` are somewhat general.
1. [OrtModelEditorAPI::CreateSessionFromModel](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/onnxruntime/core/session/model_editor_c_api.cc#L258) method tries to catch all exceptions and converts them to `ORT_FAIL`at [1](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/onnxruntime/core/session/model_editor_c_api.cc#L279)
2. [InferenceSession::Run](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/onnxruntime/core/session/inference_session.cc#L2904) method tries to catch all exceptions and converts them to `ORT_FAIL`at [2](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/onnxruntime/core/session/inference_session.cc#L3063) or `ORT_RUNTIME_EXCEPTION`at [3](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/onnxruntime/core/session/inference_session.cc#L3067)

**Relevant issue**: https://github.com/microsoft/onnxruntime/issues/26606

/cc @fdwr @RafaelCintron @huningxin @skottmckay

### Describe scenario use case

For our WebNN implementation in Chrome browser, we handle the [OrtErrorCode](https://github.com/microsoft/onnxruntime/blob/615c22bf6ba5d259c49484416d0a87a91d936e13/include/onnxruntime/core/session/onnxruntime_c_api.h#L254) values from ORT API, but we don’t know which values should be treated as critical errors, such as
“device-removal” , “device-reset” and “out of memory”, as defined at [DXGI_ERROR](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/dxgi-error). For these errors, WebNN needs to destroy the context and may even decide to kill the Chrome GPU process.

Contributor guide

Open the contributing guide

Research direction

Start with include/onnxruntime/core/session/onnxruntime_c_api.h and trace the error handling in onnxruntime/core/session/model_editor_c_api.cc and onnxruntime/core/session/inference_session.cc. Review related issue 26606 and the referenced DXGI_ERROR values to understand the required critical-error behavior. Done should be defined by a clear way for WebNN to distinguish device removal, device reset, and out-of-memory failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.