onnxruntime
27d11c07 - [Framework] Report missing or unavailable execution backends (#33957)

Commit
3 days ago
[Framework] Report missing or unavailable execution backends (#33957) ## What changes Return a clear error when an operation has no assigned execution backend, or names a backend that is not registered, instead of failing while preparing data copies. This prevents cases where ops could not be assigned an ep from crashing the browser GPU process when ORT WebGPU is used as the backend for webnn. The error identifies the affected node. Unsupported operations return `NOT_IMPLEMENTED`; invalid backend names return `INVALID_ARGUMENT`. Validation happens before copy nodes are inserted. Valid CPU-assigned nodes keep their existing behavior. `ModifyGraph` now returns `Status` and reports graph modification through a `bool&` output parameter. Assignment checks run in its existing initial node scan, before collecting each node's copy requirements; there is no separate validation traversal in `ApplyImpl`. `ApplyImpl` propagates failures with `ORT_RETURN_IF_ERROR`. These are internal helper changes, with no public API/ABI change. The existing non-CPU-provider guard and subgraph recursion remain unchanged. ## Native tests **3 tests passed, with no skips, after the refactor.** They cover an unassigned node, an unavailable named backend, an unchanged valid CPU-assigned node, and successful CPU-to-GPU-to-CPU copy insertion with `modified == true`. Invalid assignments are tested after an earlier valid GPU-assigned node has been processed; node assignments and connections remain unchanged on failure. Regression-sensitivity checks used disposable faulty source copies with the unchanged tests. Dropping the modification flag, omitting a GPU-to-CPU copy, and changing an earlier valid node's assignment each failed the intended assertion. The production source was then rebuilt and all three tests rerun successfully. From an existing Release build configured with WebGPU: ```powershell cmake --build build\latest-webgpu\Release --target onnxruntime_test_all --parallel 8 Push-Location build\latest-webgpu\Release .\onnxruntime_test_all.exe --gtest_filter=TransformerTest.MemcpyTransformer* Pop-Location ``` The tests use a small test backend and do not depend on GPU hardware. --------- Co-authored-by: Sushanth Rajasankar <Sushanth.Rajasankar@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
Parents
Loading