Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/onnxruntime/core/session/onnxruntime_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6074,6 +6074,18 @@ struct OrtApi {
* \since Version 1.23
*/
ORT_API2_STATUS(GetTensorData, _In_ const OrtValue* value, _Outptr_ const void** out);

/** \brief Get Session configuration entries.
*
* \param[in] options The session options.
* \param[out] out A pointer to a newly created OrtKeyValuePairs instance.
*
* An OrtKeyValuePairs instance containing all session configuration entries.
* Note: the user should call OrtApi::ReleaseKeyValuePairs.
*
* \since Version 1.23.
*/
ORT_API2_STATUS(GetSessionOptionsConfigEntries, _In_ const OrtSessionOptions* options, _Outptr_ OrtKeyValuePairs** out);
};

/*
Expand Down
15 changes: 15 additions & 0 deletions onnxruntime/core/session/abi_session_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,21 @@
API_IMPL_END
}

ORT_API_STATUS_IMPL(OrtApis::GetSessionOptionsConfigEntries, _In_ const OrtSessionOptions* options, _Outptr_ OrtKeyValuePairs** out) {
API_IMPL_BEGIN
if (options == nullptr) {
return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "options is nullptr");
}
auto& config_options = options->value.config_options.GetConfigOptionsMap();
auto kvps = std::make_unique<OrtKeyValuePairs>();

Check warning on line 287 in onnxruntime/core/session/abi_session_options.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Add #include <memory> for make_unique<> [build/include_what_you_use] [4] Raw Output: onnxruntime/core/session/abi_session_options.cc:287: Add #include <memory> for make_unique<> [build/include_what_you_use] [4]
for (auto& kv : config_options) {
kvps->Add(kv.first.c_str(), kv.second.c_str());
}
*out = reinterpret_cast<OrtKeyValuePairs*>(kvps.release());
return nullptr;
API_IMPL_END
}

ORT_API_STATUS_IMPL(OrtApis::AddInitializer, _Inout_ OrtSessionOptions* options, _In_z_ const char* name,
_In_ const OrtValue* val) {
API_IMPL_BEGIN
Expand Down
2 changes: 2 additions & 0 deletions onnxruntime/core/session/onnxruntime_c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3632,6 +3632,8 @@ static constexpr OrtApi ort_api_1_to_23 = {
&OrtApis::ReleaseSharedAllocator,

&OrtApis::GetTensorData,

&OrtApis::GetSessionOptionsConfigEntries,
};

// OrtApiBase can never change as there is no way to know what version of OrtApiBase is returned by OrtGetApiBase.
Expand Down
2 changes: 2 additions & 0 deletions onnxruntime/core/session/ort_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,6 @@ ORT_API_STATUS_IMPL(ReleaseSharedAllocator, _In_ OrtEnv* env, _In_ const OrtEpDe
_In_ OrtDeviceMemoryType mem_type);

ORT_API_STATUS_IMPL(GetTensorData, _In_ const OrtValue* value, _Outptr_ const void** out);

ORT_API_STATUS_IMPL(GetSessionOptionsConfigEntries, _In_ const OrtSessionOptions* options, _Outptr_ OrtKeyValuePairs** out);
} // namespace OrtApis
Loading