Language bindings for Hardware Device and EP Compatibility APIs#28128
Language bindings for Hardware Device and EP Compatibility APIs#28128adrianlizarraga merged 7 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds C++, C# and Python language projections for the new Hardware Device + EP compatibility APIs (device enumeration + querying EP/device incompatibility details), along with unit tests validating the new bindings.
Changes:
- Added Python pybind11 globals for
get_hardware_devices,get_hardware_device_ep_incompatibility_details, and exposedOrtDeviceEpIncompatibilityReason. - Extended C++ C++-API wrappers (
Ort::Env) to enumerate hardware devices and retrieveDeviceEpIncompatibilityDetails. - Added C# projections + native delegate bindings for the new APIs and corresponding tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/test/python/onnxruntime_test_python_ep_compatibility.py | Adds Python tests for device enumeration, incompatibility details, and enum values. |
| onnxruntime/test/framework/hardware_device_compatibility_test.cc | Adds C++ API unit tests for the new Ort::Env hardware-device methods. |
| onnxruntime/python/onnxruntime_pybind_state.cc | Adds Python bindings for hardware device enumeration/incompatibility queries and exposes the new reason enum. |
| include/onnxruntime/core/session/onnxruntime_cxx_inline.h | Implements inline C++ API wrappers for the new Env/device APIs and details accessors. |
| include/onnxruntime/core/session/onnxruntime_cxx_api.h | Declares new C++ wrapper types and Ort::Env methods for hardware device compatibility APIs. |
| csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/EpCompatibilityTests.cs | Adds C# tests for device enumeration and incompatibility details. |
| csharp/src/Microsoft.ML.OnnxRuntime/OrtHardwareDevice.shared.cs | Exposes OrtHardwareDevice.Handle internally for interop calls. |
| csharp/src/Microsoft.ML.OnnxRuntime/OrtEnv.shared.cs | Adds C# projections for new APIs and a disposable wrapper for incompatibility details + flags enum. |
| csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs | Adds native delegate bindings/function pointers for the new C API calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3e63595 to
aa844ec
Compare
Replace C API calls with direct internal calls to GetEnv() for get_hardware_devices and get_hardware_device_ep_incompatibility_details. Use OrtPybindThrowIfError for proper Python exception types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use bitmask comparison for UNKNOWN enum value in Python test to avoid platform/compiler sign brittleness - Replace strlen(notes) == 0 with *notes == '\0' to avoid implicit cstring dependency in C++ tests - Use checked((int)numDevices) in C# OrtEnv to prevent silent truncation on 64-bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @xhan65, you may need to sync with the latest main branch to get some CI to pass. |
…ojection # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
Hmmm I synced to main but this Linux_TRT_Minimal_CUDA_Test_CI test still keeps failing... Is it a known issue? I don't think my change would cause it to fail. |
Hi, I don't think it is a problem with your PR. We're investigating internally. |
### Description This change includes c++, c# and python language projections for the GetHardwareDeviceEpIncompatibilityDetails and related APIs added #26922 ### Motivation and Context - GetNumHardwareDevices / GetHardwareDevices — enumerate hardware devices (CPU, GPU, NPU) available on the system - GetHardwareDeviceEpIncompatibilityDetails — check known incompatibility issues between a device and an execution provider - DeviceEpIncompatibilityDetails_GetReasonsBitmask / GetNotes / GetErrorCode / Release — access and manage incompatibility detail results - OrtDeviceEpIncompatibilityReason enum — standard incompatibility reason flags ### Testing Added python, c++ and c# tests and verified that they passed. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
This change includes c++, c# and python language projections for the GetHardwareDeviceEpIncompatibilityDetails and related APIs added #26922
Motivation and Context
provider
incompatibility detail results
Testing
Added python, c++ and c# tests and verified that they passed.