Skip to content

Conversation

@zpye
Copy link
Contributor

@zpye zpye commented Nov 17, 2025

Description

This PR adds a new API function KernelInfo_GetConfigEntries that allows custom operators to access all configuration entries from the OrtKernelInfo object during kernel construction.

Motivation and Context

Custom operators may need to access session configuration options to adjust their behavior. Previously, there was no way to retrieve all config entries from KernelInfo. This PR provides a convenient method to get all configuration key-value pairs that were set on the OrtSessionOptions.

Changes

API Additions

  • C API: Added KernelInfo_GetConfigEntries function to OrtApi (Version 1.24)

    • Takes an OrtKernelInfo* as input
    • Returns all config entries as OrtKeyValuePairs*
    • Properly documented with usage examples
  • C++ API: Added GetConfigEntries() method to KernelInfoImpl template class

    • Returns KeyValuePairs object
    • Follows existing C++ wrapper patterns

Implementation

  • Implemented in onnxruntime/core/session/custom_ops.cc
  • Iterates through config_options_map from OpKernelInfo
  • Creates and populates OrtKeyValuePairs with all configuration entries

Testing

  • Updated shape_inference_test.cc with test case
  • Verifies config entries can be retrieved in custom kernel constructor
  • Tests both existing and non-existing config keys

Files Changed

  • include/onnxruntime/core/session/onnxruntime_c_api.h - API declaration
  • include/onnxruntime/core/session/onnxruntime_cxx_api.h - C++ wrapper declaration
  • include/onnxruntime/core/session/onnxruntime_cxx_inline.h - C++ wrapper implementation
  • onnxruntime/core/session/custom_ops.cc - Core implementation
  • onnxruntime/core/session/onnxruntime_c_api.cc - API registration
  • onnxruntime/core/session/ort_apis.h - API header declaration
  • onnxruntime/test/framework/shape_inference_test.cc - Test coverage

API Version

This change is part of ORT API Version 1.24.

Breaking Changes

None. This is a backward-compatible addition to the API.

@yuslepukhin
Copy link
Member

/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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

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.

2 participants