|
12 | 12 | #define ORT_EP_UTILS_ORT_GRAPH_TO_PROTO_IMPL |
13 | 13 | #include "ort_graph_to_proto.h" |
14 | 14 |
|
15 | | -#include "ep_abi_utils.h" |
16 | 15 | //#include "tensorrt_execution_provider_utils.h" |
17 | 16 | #include "tensorrt_execution_provider.h" |
18 | 17 | #include "cuda_allocator.h" |
@@ -1968,27 +1967,30 @@ TensorrtExecutionProvider::TensorrtExecutionProvider(TensorrtExecutionProviderFa |
1968 | 1967 | // the session option configurations with the key prefix "ep.<lowercase_ep_name>.". |
1969 | 1968 | std::string key_prefix = "ep." + lowercase_ep_name + "."; |
1970 | 1969 |
|
1971 | | - /* |
1972 | | - // Get provider options as key-value pair strings |
| 1970 | + // Get all the provider options as session config from sesson |
1973 | 1971 | 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; |
1977 | 1990 | } |
1978 | 1991 | } |
1979 | | - */ |
1980 | 1992 |
|
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); |
1992 | 1994 |
|
1993 | 1995 | // Provider options to TensorrtExecutionProviderInfo |
1994 | 1996 | info_ = TensorrtExecutionProviderInfo::FromProviderOptions(provider_options); |
|
0 commit comments