Skip to content

Commit 938a3fe

Browse files
committed
use GetSessionOptionsConfigEntries to get provider options
1 parent f73420f commit 938a3fe

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

plugin_execution_providers/tensorrt/tensorrt_execution_provider.cc

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#define ORT_EP_UTILS_ORT_GRAPH_TO_PROTO_IMPL
1313
#include "ort_graph_to_proto.h"
1414

15-
#include "ep_abi_utils.h"
1615
//#include "tensorrt_execution_provider_utils.h"
1716
#include "tensorrt_execution_provider.h"
1817
#include "cuda_allocator.h"
@@ -1968,27 +1967,30 @@ TensorrtExecutionProvider::TensorrtExecutionProvider(TensorrtExecutionProviderFa
19681967
// the session option configurations with the key prefix "ep.<lowercase_ep_name>.".
19691968
std::string key_prefix = "ep." + lowercase_ep_name + ".";
19701969

1971-
/*
1972-
// Get provider options as key-value pair strings
1970+
// Get all the provider options as session config from sesson
19731971
ProviderOptions provider_options;
1974-
for (const auto& [key, value] : config_options_map) {
1975-
if (key.rfind(key_prefix, 0) == 0) {
1976-
provider_options[key.substr(key_prefix.size())] = value;
1972+
1973+
// Get the provider options from all the config entries in session option
1974+
OrtKeyValuePairs* key_value_pairs = nullptr;
1975+
ort_api.GetSessionOptionsConfigEntries(&session_options, &key_value_pairs);
1976+
1977+
const char* const* keys = nullptr;
1978+
const char* const* values = nullptr;
1979+
size_t num_entries = 0;
1980+
ort_api.GetKeyValuePairs(key_value_pairs, &keys, &values, &num_entries);
1981+
1982+
for (size_t i = 0; i < num_entries; ++i) {
1983+
const char* key = keys[i];
1984+
1985+
// only gets ep provider options
1986+
if (strncmp(key, key_prefix.c_str(), key_prefix.size()) == 0) {
1987+
std::string key_str = key;
1988+
const char* value = values[i];
1989+
provider_options[key_str.substr(key_prefix.size())] = value;
19771990
}
19781991
}
1979-
*/
19801992

1981-
// Get all the provider options as session config from sesson
1982-
ProviderOptions provider_options;
1983-
int has_session_config_entry = 0;
1984-
std::string provider_option = key_prefix + "trt_engine_cache_enable";
1985-
auto status = ort_api.HasSessionConfigEntry(&session_options, provider_option.c_str(), & has_session_config_entry);
1986-
if (has_session_config_entry) {
1987-
char* value = nullptr;
1988-
size_t size = 0;
1989-
status = ort_api.GetSessionConfigEntry(&session_options, provider_option.c_str(), value, &size);
1990-
provider_options[provider_option.substr(key_prefix.size())] = value;
1991-
}
1993+
ort_api.ReleaseKeyValuePairs(key_value_pairs);
19921994

19931995
// Provider options to TensorrtExecutionProviderInfo
19941996
info_ = TensorrtExecutionProviderInfo::FromProviderOptions(provider_options);

0 commit comments

Comments
 (0)