Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chilo-ms committed Sep 21, 2023
1 parent 8c38ebd commit 53fc69e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions onnxruntime/python/onnxruntime_pybind_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,14 @@ std::unique_ptr<IExecutionProvider> CreateExecutionProviderInstance(
if (Env::Default().GetEnvironmentVar("ORT_TENSORRT_UNAVAILABLE").empty()) {
auto it = provider_options_map.find(type);
if (it != provider_options_map.end()) {
std::unique_ptr<OrtTensorRTProviderOptionsV2> trt_options;
OrtTensorRTProviderOptionsV2 trt_options;
if (auto* tensorrt_provider_info = TryGetProviderInfo_TensorRT()) {
// Please note the last argument of UpdateProviderOptions() which is 'string_copy' is set to false, it means
// the const char* member of the OrtTensorRTProviderOptionsV2 is actually pointing to the string array that is maintained by ProviderOptionsMap instance.
// Make sure the ProviderOptionsMap instance stays alive for the lifetime of TRT EP. Also, in this case, we don't need to worry about deallocate those string array
// since it's not maintained by OrtTensorRTPRoviderOptionsV2 instance.
tensorrt_provider_info->UpdateProviderOptions(trt_options.get(), it->second, false);
if (std::shared_ptr<IExecutionProviderFactory> tensorrt_provider_factory = onnxruntime::TensorrtProviderFactoryCreator::Create(trt_options.get())) {
tensorrt_provider_info->UpdateProviderOptions(&trt_options, it->second, false);
if (std::shared_ptr<IExecutionProviderFactory> tensorrt_provider_factory = onnxruntime::TensorrtProviderFactoryCreator::Create(&trt_options)) {
return tensorrt_provider_factory->CreateProvider();
}
} else {
Expand Down

0 comments on commit 53fc69e

Please sign in to comment.