From d468c51ea77c1a9161cc624a81fa453f9777875c Mon Sep 17 00:00:00 2001 From: hualxie Date: Tue, 3 Mar 2026 11:01:33 +0800 Subject: [PATCH 1/3] increase kMaxValueLength to 8192 --- .../core/session/onnxruntime_session_options_config_keys.h | 2 +- onnxruntime/core/framework/config_options.h | 2 +- onnxruntime/test/shared_lib/test_session_options.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h b/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h index dcdd8fe88ec38..762e00debf49d 100644 --- a/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h +++ b/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h @@ -13,7 +13,7 @@ * The maximum length of the Config Key is 1024 * * The string format of a SessionOptions Config Value is defined individually for each Config. - * The maximum length of the Config Value is 2048 + * The maximum length of the Config Value is 8192 */ // Key for disable PrePacking, diff --git a/onnxruntime/core/framework/config_options.h b/onnxruntime/core/framework/config_options.h index 1c356d8cfca56..6c0d6741dd92f 100644 --- a/onnxruntime/core/framework/config_options.h +++ b/onnxruntime/core/framework/config_options.h @@ -18,7 +18,7 @@ struct ConfigOptions { // Maximum key/value string lengths specified in // core/session/onnxruntime_session_options_config_keys.h static constexpr size_t kMaxKeyLength = 1024; - static constexpr size_t kMaxValueLength = 4096; + static constexpr size_t kMaxValueLength = 8192; std::unordered_map configurations; diff --git a/onnxruntime/test/shared_lib/test_session_options.cc b/onnxruntime/test/shared_lib/test_session_options.cc index d12a586f662ac..8608f0d53745f 100644 --- a/onnxruntime/test/shared_lib/test_session_options.cc +++ b/onnxruntime/test/shared_lib/test_session_options.cc @@ -25,7 +25,7 @@ TEST(CApiTest, session_options_deterministic_compute) { TEST(CApiTest, session_options_oversized_affinity_string) { Ort::SessionOptions options; - std::string long_affinity_str(onnxruntime::kMaxStrLen + 1, '0'); + std::string long_affinity_str(onnxruntime::kMaxStrLen * 2 + 1, '0'); try { options.AddConfigEntry(kOrtSessionOptionsConfigIntraOpThreadAffinities, long_affinity_str.c_str()); ASSERT_TRUE(false) << "Creation of config should have thrown exception"; From d7cf6980fb64fba1005d9c2ce80d62d2222f2157 Mon Sep 17 00:00:00 2001 From: hualxie Date: Tue, 3 Mar 2026 15:42:39 +0800 Subject: [PATCH 2/3] apply suggestion --- onnxruntime/test/shared_lib/test_session_options.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/test/shared_lib/test_session_options.cc b/onnxruntime/test/shared_lib/test_session_options.cc index 8608f0d53745f..b43b1222fb927 100644 --- a/onnxruntime/test/shared_lib/test_session_options.cc +++ b/onnxruntime/test/shared_lib/test_session_options.cc @@ -25,7 +25,7 @@ TEST(CApiTest, session_options_deterministic_compute) { TEST(CApiTest, session_options_oversized_affinity_string) { Ort::SessionOptions options; - std::string long_affinity_str(onnxruntime::kMaxStrLen * 2 + 1, '0'); + std::string long_affinity_str(onnxruntime::ConfigOptions::kMaxValueLength + 1, '0'); try { options.AddConfigEntry(kOrtSessionOptionsConfigIntraOpThreadAffinities, long_affinity_str.c_str()); ASSERT_TRUE(false) << "Creation of config should have thrown exception"; From 0ae05ff1c3eb006aa34dbe9855af1d5806a6fc61 Mon Sep 17 00:00:00 2001 From: hualxie Date: Tue, 3 Mar 2026 17:22:51 +0800 Subject: [PATCH 3/3] bug fix --- onnxruntime/test/shared_lib/test_session_options.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onnxruntime/test/shared_lib/test_session_options.cc b/onnxruntime/test/shared_lib/test_session_options.cc index b43b1222fb927..ba58344e1e3e2 100644 --- a/onnxruntime/test/shared_lib/test_session_options.cc +++ b/onnxruntime/test/shared_lib/test_session_options.cc @@ -2,6 +2,7 @@ // Licensed under the MIT License. #include "core/common/common.h" +#include "core/framework/config_options.h" #include "core/graph/constants.h" #include "core/session/onnxruntime_cxx_api.h" #include "core/session/onnxruntime_session_options_config_keys.h" @@ -25,7 +26,7 @@ TEST(CApiTest, session_options_deterministic_compute) { TEST(CApiTest, session_options_oversized_affinity_string) { Ort::SessionOptions options; - std::string long_affinity_str(onnxruntime::ConfigOptions::kMaxValueLength + 1, '0'); + std::string long_affinity_str(ConfigOptions::kMaxValueLength + 1, '0'); try { options.AddConfigEntry(kOrtSessionOptionsConfigIntraOpThreadAffinities, long_affinity_str.c_str()); ASSERT_TRUE(false) << "Creation of config should have thrown exception";