Commit 5834bfe
authored
Add API to access config entries from KernelInfo (#26589)
## 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.1 parent 4870d45 commit 5834bfe
File tree
7 files changed
+59
-1
lines changed- include/onnxruntime/core/session
- onnxruntime
- core/session
- test/framework
7 files changed
+59
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6591 | 6591 | | |
6592 | 6592 | | |
6593 | 6593 | | |
| 6594 | + | |
| 6595 | + | |
| 6596 | + | |
| 6597 | + | |
| 6598 | + | |
| 6599 | + | |
| 6600 | + | |
| 6601 | + | |
| 6602 | + | |
| 6603 | + | |
| 6604 | + | |
| 6605 | + | |
| 6606 | + | |
| 6607 | + | |
| 6608 | + | |
| 6609 | + | |
| 6610 | + | |
6594 | 6611 | | |
6595 | 6612 | | |
6596 | 6613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2768 | 2768 | | |
2769 | 2769 | | |
2770 | 2770 | | |
| 2771 | + | |
| 2772 | + | |
2771 | 2773 | | |
2772 | 2774 | | |
2773 | 2775 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2822 | 2822 | | |
2823 | 2823 | | |
2824 | 2824 | | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
2825 | 2832 | | |
2826 | 2833 | | |
2827 | 2834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
758 | 773 | | |
759 | 774 | | |
760 | 775 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4237 | 4237 | | |
4238 | 4238 | | |
4239 | 4239 | | |
| 4240 | + | |
4240 | 4241 | | |
4241 | 4242 | | |
4242 | 4243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
754 | 757 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
| |||
143 | 154 | | |
144 | 155 | | |
145 | 156 | | |
| 157 | + | |
| 158 | + | |
146 | 159 | | |
147 | 160 | | |
148 | 161 | | |
| |||
0 commit comments