onnxruntime
46273eae - [Plugin EP] Session options getters (#28377)

Commit
66 days ago
[Plugin EP] Session options getters (#28377) ## Description Add getter APIs for `MemPatternEnabled` and `ExecutionMode` session options to allow Execution Providers to query these settings. ### Motivation Plugin EPs need to inspect session option values in order to validate compatibility. For example, EPs whose memory is not byte-addressable (like DML and WebGPU) are incompatible with the memory pattern optimization, and some EPs do not support parallel execution mode. For example: https://github.com/microsoft/onnxruntime/blob/28bcc9cf304b3af4eece60700c09f2e2561ba655/onnxruntime/core/session/inference_session.cc#L901-L920 Currently, the C API only exposes setters (`EnableMemPattern`/`DisableMemPattern`, `SetSessionExecutionMode`) with no corresponding getters. This means plugin EPs loaded from shared libraries have no way to query these values and return an appropriate error status if the session options are incompatible. ### Changes Added two new C API functions (Version 1.27): - **`GetMemPatternEnabled`** — Returns whether the memory pattern optimization is enabled (1) or disabled (0). - **`GetSessionExecutionMode`** — Returns the current execution mode (`ORT_SEQUENTIAL` or `ORT_PARALLEL`). Both APIs also have corresponding C++ wrappers: - `bool SessionOptions::GetMemPatternEnabled() const` - `ExecutionMode SessionOptions::GetExecutionMode() const` ### Files Changed | File | Description | |------|-------------| | `include/onnxruntime/core/session/onnxruntime_c_api.h` | New C API declarations with documentation | | `onnxruntime/core/session/ort_apis.h` | Internal API declarations | | `onnxruntime/core/session/abi_session_options.cc` | Implementations | | `onnxruntime/core/session/onnxruntime_c_api.cc` | API table registration | | `include/onnxruntime/core/session/onnxruntime_cxx_api.h` | C++ wrapper declarations | | `include/onnxruntime/core/session/onnxruntime_cxx_inline.h` | C++ inline implementations | | `onnxruntime/test/shared_lib/test_session_options.cc` | Unit tests | ### Testing Added unit tests that verify: - `GetMemPatternEnabled`: default is enabled, disable returns false, re-enable returns true - `GetSessionExecutionMode`: default is `ORT_SEQUENTIAL`, set to `ORT_PARALLEL` and back
Parents
Loading