Skip to content

Conversation

wcy123
Copy link
Contributor

@wcy123 wcy123 commented Jul 3, 2025

Description

Add a new ORT API GetSessionOptionConfigEntries.

Motivation and Context

#24887 allows plugin-EPs to interface with ORT using a binary stable interface. #24445 allows an EP to handle the extraction of EP options from the session option configurations. For an EP like VitisAI EP to comply with the requirements,

it is necessary for a plugin-EPs to access all config entries in a session option.

    OrtKeyValuePairs * kvps = nullptr;
    auto status = GetSessionOptionConfigEntries(session_option, &kvps);
    if(status) {
        throw status;
    }
    std::unique_ptr<OrtKeyValuePairs, void (*)(OrtKeyValuePairs*)>
        config_entries(kvps,
                       ort_api.ReleaseKeyValuePairs);
    const char* const* keys = nullptr;
    const char* const* values = nullptr;
    size_t num_keys = 0;
    // Get keys and values from the config entries
    Ort::GetApi().GetKeyValuePairs(config_entries.get(), &keys, &values, &num_keys);

    for (size_t i = 0; i < num_keys; ++i) {
        // process keys[i] and values[i]
    }

@HectorSVC HectorSVC requested review from Copilot, skottmckay and yuslepukhin and removed request for Copilot July 3, 2025 15:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new C API GetSessionOptionConfigEntries to expose all session configuration entries via OrtKeyValuePairs.

  • Declares the new API in ort_apis.h and onnxruntime_c_api.h
  • Registers it in the ort_api_1_to_23 dispatch table
  • Implements the API in abi_session_options.cc

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
onnxruntime/core/session/ort_apis.h Declares GetSessionOptionConfigEntries
onnxruntime/core/session/onnxruntime_c_api.cc Adds function pointer to the API dispatch table
onnxruntime/core/session/abi_session_options.cc Implements the new C API
include/onnxruntime/core/session/onnxruntime_c_api.h Documents the new API in the public header
Comments suppressed due to low confidence (2)

include/onnxruntime/core/session/onnxruntime_c_api.h:6078

  • Update the \since version to match the new API release (should be 1.23 instead of 1.22).
   * \since Version 1.22.

include/onnxruntime/core/session/onnxruntime_c_api.h:6080

  • [nitpick] Consider adding or updating unit tests to cover GetSessionOptionConfigEntries for various session options to ensure correct behavior.
  OrtKeyValuePairs*(ORT_API_CALL* GetSessionOptionConfigEntries)(_In_ const OrtSessionOptions* options);

@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@chilo-ms
Copy link
Contributor

chilo-ms commented Jul 3, 2025

Do we want to make it more flexible by adding an additional key's prefix as a parameter, so that EP can get more useful session configs back, ex: "ep.vitis_ep.XXX", instead of all the session configs?
If key's prefix is provided as nullptr, return all the session configs.

@wcy123 wcy123 force-pushed the add-session-option-get-all-config-entries branch 2 times, most recently from 359f5e5 to e159be3 Compare July 4, 2025 01:29
@wcy123
Copy link
Contributor Author

wcy123 commented Jul 4, 2025

Do we want to make it more flexible by adding an additional key's prefix as a parameter, so that EP can get more useful session configs back, ex: "ep.vitis_ep.XXX", instead of all the session configs? If key's prefix is provided as nullptr, return all the session configs.

VitisAI EP would handle some other configuration entries, i.e. "ep.shared_ep_context", "ep.context_file_path", "ep.stop_share_ep_contexts" etc. Additionally it would be easy for an EP plugin to filter out the prefix, soreturning all session configuration could be fine.

@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@wcy123 wcy123 force-pushed the add-session-option-get-all-config-entries branch from c8e3728 to f9dfcd3 Compare July 7, 2025 02:48
@wcy123 wcy123 force-pushed the add-session-option-get-all-config-entries branch from f9dfcd3 to 0301055 Compare July 7, 2025 03:07
@HectorSVC
Copy link
Contributor

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,Windows x64 QNN CI Pipeline

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

Copy link
Contributor

@HectorSVC HectorSVC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@HectorSVC HectorSVC merged commit c00f690 into microsoft:main Jul 7, 2025
84 of 85 checks passed
daijh pushed a commit to daijh/onnxruntime that referenced this pull request Jul 10, 2025
### Description

Add a new ORT API `GetSessionOptionConfigEntries`.

### Motivation and Context

microsoft#24887 allows plugin-EPs to interface with ORT using a binary stable interface. microsoft#24445 allows an EP to handle the extraction of EP options from the session option configurations. For an EP like VitisAI EP to comply with the requirements,

it is necessary for a plugin-EPs to access all config entries in a session option.

```c++
    OrtKeyValuePairs * kvps = nullptr;
    auto status = GetSessionOptionConfigEntries(session_option, &kvps);
    if(status) {
        throw status;
    }
    std::unique_ptr<OrtKeyValuePairs, void (*)(OrtKeyValuePairs*)>
        config_entries(kvps,
                       ort_api.ReleaseKeyValuePairs);
    const char* const* keys = nullptr;
    const char* const* values = nullptr;
    size_t num_keys = 0;
    // Get keys and values from the config entries
    Ort::GetApi().GetKeyValuePairs(config_entries.get(), &keys, &values, &num_keys);

    for (size_t i = 0; i < num_keys; ++i) {
        // process keys[i] and values[i]
    }
```
qti-yuduo pushed a commit to CodeLinaro/onnxruntime that referenced this pull request Aug 8, 2025
### Description

Add a new ORT API `GetSessionOptionConfigEntries`.

### Motivation and Context

microsoft#24887 allows plugin-EPs to interface with ORT using a binary stable interface. microsoft#24445 allows an EP to handle the extraction of EP options from the session option configurations. For an EP like VitisAI EP to comply with the requirements,

it is necessary for a plugin-EPs to access all config entries in a session option.

```c++
    OrtKeyValuePairs * kvps = nullptr;
    auto status = GetSessionOptionConfigEntries(session_option, &kvps);
    if(status) {
        throw status;
    }
    std::unique_ptr<OrtKeyValuePairs, void (*)(OrtKeyValuePairs*)>
        config_entries(kvps,
                       ort_api.ReleaseKeyValuePairs);
    const char* const* keys = nullptr;
    const char* const* values = nullptr;
    size_t num_keys = 0;
    // Get keys and values from the config entries
    Ort::GetApi().GetKeyValuePairs(config_entries.get(), &keys, &values, &num_keys);

    for (size_t i = 0; i < num_keys; ++i) {
        // process keys[i] and values[i]
    }
```
sanketkaleoss pushed a commit to sanketkaleoss/onnxruntime that referenced this pull request Aug 11, 2025
### Description

Add a new ORT API `GetSessionOptionConfigEntries`.

### Motivation and Context

microsoft#24887 allows plugin-EPs to interface with ORT using a binary stable interface. microsoft#24445 allows an EP to handle the extraction of EP options from the session option configurations. For an EP like VitisAI EP to comply with the requirements,

it is necessary for a plugin-EPs to access all config entries in a session option.

```c++
    OrtKeyValuePairs * kvps = nullptr;
    auto status = GetSessionOptionConfigEntries(session_option, &kvps);
    if(status) {
        throw status;
    }
    std::unique_ptr<OrtKeyValuePairs, void (*)(OrtKeyValuePairs*)>
        config_entries(kvps,
                       ort_api.ReleaseKeyValuePairs);
    const char* const* keys = nullptr;
    const char* const* values = nullptr;
    size_t num_keys = 0;
    // Get keys and values from the config entries
    Ort::GetApi().GetKeyValuePairs(config_entries.get(), &keys, &values, &num_keys);

    for (size_t i = 0; i < num_keys; ++i) {
        // process keys[i] and values[i]
    }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants