From 0e50b648e9fdaafc65b00d6e37c8a294411270a2 Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 13 May 2024 07:55:12 +0000 Subject: [PATCH 01/12] initial tensorrt commit Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/provider.cc | 2 ++ sherpa-onnx/csrc/provider.h | 1 + sherpa-onnx/csrc/session.cc | 50 ++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/sherpa-onnx/csrc/provider.cc b/sherpa-onnx/csrc/provider.cc index 95bc18c5f..19d585976 100644 --- a/sherpa-onnx/csrc/provider.cc +++ b/sherpa-onnx/csrc/provider.cc @@ -24,6 +24,8 @@ Provider StringToProvider(std::string s) { return Provider::kXnnpack; } else if (s == "nnapi") { return Provider::kNNAPI; + } else if (s == "trt") { + return Provider::kTRT; } else { SHERPA_ONNX_LOGE("Unsupported string: %s. Fallback to cpu", s.c_str()); return Provider::kCPU; diff --git a/sherpa-onnx/csrc/provider.h b/sherpa-onnx/csrc/provider.h index 467e5dab5..ce772828e 100644 --- a/sherpa-onnx/csrc/provider.h +++ b/sherpa-onnx/csrc/provider.h @@ -18,6 +18,7 @@ enum class Provider { kCoreML = 2, // CoreMLExecutionProvider kXnnpack = 3, // XnnpackExecutionProvider kNNAPI = 4, // NnapiExecutionProvider + kTRT = 5, //TensorRTExecutionProvider }; /** diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index d0a697404..880affe6b 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -8,6 +8,7 @@ #include #include #include +// #include #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/provider.h" @@ -115,6 +116,55 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, #endif break; } + case Provider::kTRT: { + SHERPA_ONNX_LOGE("Came for TRT"); + std::vector option_keys = { + "device_id", + "trt_max_workspace_size", + "trt_max_partition_iterations", + "trt_min_subgraph_size", + "trt_fp16_enable", + "trt_int8_enable", + "trt_int8_use_native_calibration_table", + "trt_dump_subgraphs", + "trt_detailed_build_log", + // below options are strongly recommended ! + "trt_engine_cache_enable", + "trt_engine_cache_path", + "trt_timing_cache_enable", + "trt_timing_cache_path", + }; + std::vector option_values = { + "0", + "2147483648", + "10", + "5", + "0", + "0", + "0", + "1", + "1", + "1", + ".", + "1", + ".", // can be same as the engine cache folder + }; + std::vector available_providers = + Ort::GetAvailableProviders(); + if (std::find(available_providers.begin(), available_providers.end(), + "TensorrtExecutionProvider") != available_providers.end()) { + const auto& api = Ort::GetApi(); + + OrtTensorRTProviderOptionsV2* tensorrt_options; + Ort::ThrowOnError(api.CreateTensorRTProviderOptions(&tensorrt_options)); + + Ort::ThrowOnError(api.UpdateTensorRTProviderOptions(tensorrt_options, + option_keys.data(), option_values.data(), option_keys.size())); + + sess_opts.AppendExecutionProvider_TensorRT_V2(*tensorrt_options); + + } + } } return sess_opts; From b7148174739275dfc997af726be364245511239c Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 27 May 2024 05:29:21 +0000 Subject: [PATCH 02/12] fixing cpplint Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/provider.h | 2 +- sherpa-onnx/csrc/session.cc | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sherpa-onnx/csrc/provider.h b/sherpa-onnx/csrc/provider.h index ce772828e..c104d401a 100644 --- a/sherpa-onnx/csrc/provider.h +++ b/sherpa-onnx/csrc/provider.h @@ -18,7 +18,7 @@ enum class Provider { kCoreML = 2, // CoreMLExecutionProvider kXnnpack = 3, // XnnpackExecutionProvider kNNAPI = 4, // NnapiExecutionProvider - kTRT = 5, //TensorRTExecutionProvider + kTRT = 5, // TensorRTExecutionProvider }; /** diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 880affe6b..160c1d94b 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -147,7 +147,7 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, "1", ".", "1", - ".", // can be same as the engine cache folder + ".", // can be same as the engine cache folder }; std::vector available_providers = Ort::GetAvailableProviders(); @@ -159,10 +159,9 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, Ort::ThrowOnError(api.CreateTensorRTProviderOptions(&tensorrt_options)); Ort::ThrowOnError(api.UpdateTensorRTProviderOptions(tensorrt_options, - option_keys.data(), option_values.data(), option_keys.size())); + option_keys.data(), option_values.data(), option_keys.size())); sess_opts.AppendExecutionProvider_TensorRT_V2(*tensorrt_options); - } } } From 04ca04849c5aa386abc5f75029ae75e5470b5881 Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 3 Jun 2024 09:56:28 +0000 Subject: [PATCH 03/12] Clean Tenssort provider -- cleaner implementation -- releasing memory leak Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 113 ++++++++++++++++++++---------------- sherpa-onnx/csrc/session.h | 2 + 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 160c1d94b..5c6081e0c 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -54,6 +54,61 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, } break; } + case Provider::kTRT: { + + struct TrtPairs { + const char* op_keys; + const char* op_values; + }; + + std::vector trt_options = { + {"device_id","0"}, + {"trt_max_workspace_size","2147483648"}, + {"trt_max_partition_iterations","10"}, + {"trt_min_subgraph_size","5"}, + {"trt_fp16_enable","0"}, + {"trt_detailed_build_log","0"}, + {"trt_engine_cache_enable","1"}, + {"trt_engine_cache_path","."}, + {"trt_timing_cache_enable","1"}, + {"trt_timing_cache_path","."} + }; + + // ToDo : Trt configs + // "trt_int8_enable", + // "trt_int8_use_native_calibration_table", + // "trt_dump_subgraphs", + + std::vector option_keys,option_values; + for (const TrtPairs& pair : trt_options) { + option_keys.emplace_back(pair.op_keys); + option_values.emplace_back(pair.op_values); + } + + std::vector available_providers = + Ort::GetAvailableProviders(); + if (std::find(available_providers.begin(), available_providers.end(), + "TensorrtExecutionProvider") != available_providers.end()) { + const auto& api = Ort::GetApi(); + + OrtTensorRTProviderOptionsV2* tensorrt_options; + OrtStatus *statusC = api.CreateTensorRTProviderOptions( + &tensorrt_options); + OrtStatus *statusU = api.UpdateTensorRTProviderOptions( + tensorrt_options, option_keys.data(), option_values.data(), + option_keys.size()); + + if (statusC) { OrtStatusFailure(statusC,&os);} + else if(statusU) { OrtStatusFailure(statusU,&os);} + else { + auto *statusTrt = OrtSessionOptionsAppendExecutionProvider_Tensorrt( + sess_opts, 0); + if(statusTrt) { OrtStatusFailure(statusTrt,&os);} + } + + api.ReleaseTensorRTProviderOptions(tensorrt_options); + } + } case Provider::kCUDA: { if (std::find(available_providers.begin(), available_providers.end(), "CUDAExecutionProvider") != available_providers.end()) { @@ -116,56 +171,7 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, #endif break; } - case Provider::kTRT: { - SHERPA_ONNX_LOGE("Came for TRT"); - std::vector option_keys = { - "device_id", - "trt_max_workspace_size", - "trt_max_partition_iterations", - "trt_min_subgraph_size", - "trt_fp16_enable", - "trt_int8_enable", - "trt_int8_use_native_calibration_table", - "trt_dump_subgraphs", - "trt_detailed_build_log", - // below options are strongly recommended ! - "trt_engine_cache_enable", - "trt_engine_cache_path", - "trt_timing_cache_enable", - "trt_timing_cache_path", - }; - std::vector option_values = { - "0", - "2147483648", - "10", - "5", - "0", - "0", - "0", - "1", - "1", - "1", - ".", - "1", - ".", // can be same as the engine cache folder - }; - std::vector available_providers = - Ort::GetAvailableProviders(); - if (std::find(available_providers.begin(), available_providers.end(), - "TensorrtExecutionProvider") != available_providers.end()) { - const auto& api = Ort::GetApi(); - - OrtTensorRTProviderOptionsV2* tensorrt_options; - Ort::ThrowOnError(api.CreateTensorRTProviderOptions(&tensorrt_options)); - - Ort::ThrowOnError(api.UpdateTensorRTProviderOptions(tensorrt_options, - option_keys.data(), option_values.data(), option_keys.size())); - - sess_opts.AppendExecutionProvider_TensorRT_V2(*tensorrt_options); - } - } } - return sess_opts; } @@ -214,4 +220,13 @@ Ort::SessionOptions GetSessionOptions( return GetSessionOptionsImpl(config.num_threads, config.provider); } +void OrtStatusFailure(OrtStatus *status,std::ostringstream *os) { + const auto &api = Ort::GetApi(); + const char *msg = api.GetErrorMessage(status); + SHERPA_ONNX_LOGE( + "Failed to enable TensorRT : %s." + "Available providers: %s. Fallback to cuda", msg, os->str().c_str()); + api.ReleaseStatus(status); +} + } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/session.h b/sherpa-onnx/csrc/session.h index a4121436a..ac410fd92 100644 --- a/sherpa-onnx/csrc/session.h +++ b/sherpa-onnx/csrc/session.h @@ -47,6 +47,8 @@ Ort::SessionOptions GetSessionOptions(const AudioTaggingModelConfig &config); Ort::SessionOptions GetSessionOptions( const OfflinePunctuationModelConfig &config); +void OrtStatusFailure(OrtStatus *status,std::ostringstream *os); + } // namespace sherpa_onnx #endif // SHERPA_ONNX_CSRC_SESSION_H_ From 7f4b3c530c605c231702e5dff4c4ded6f5517731 Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 3 Jun 2024 10:42:44 +0000 Subject: [PATCH 04/12] adding comments Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 5c6081e0c..be40c879c 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -108,6 +108,8 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, api.ReleaseTensorRTProviderOptions(tensorrt_options); } + // Break is ommited here intentially so that + // if TRT not available, CUDA will be used } case Provider::kCUDA: { if (std::find(available_providers.begin(), available_providers.end(), From 93f6fdf441344d739deecb40543651bc0b266fb1 Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 3 Jun 2024 10:59:19 +0000 Subject: [PATCH 05/12] updating to static function Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 21 +++++++++++---------- sherpa-onnx/csrc/session.h | 2 -- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index be40c879c..5053db7fe 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -22,6 +22,16 @@ namespace sherpa_onnx { + +static void OrtStatusFailure(OrtStatus *status,std::ostringstream *os) { + const auto &api = Ort::GetApi(); + const char *msg = api.GetErrorMessage(status); + SHERPA_ONNX_LOGE( + "Failed to enable TensorRT : %s." + "Available providers: %s. Fallback to cuda", msg, os->str().c_str()); + api.ReleaseStatus(status); +} + static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, std::string provider_str) { Provider p = StringToProvider(std::move(provider_str)); @@ -108,7 +118,7 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, api.ReleaseTensorRTProviderOptions(tensorrt_options); } - // Break is ommited here intentially so that + // break; is ommited here intentially so that // if TRT not available, CUDA will be used } case Provider::kCUDA: { @@ -222,13 +232,4 @@ Ort::SessionOptions GetSessionOptions( return GetSessionOptionsImpl(config.num_threads, config.provider); } -void OrtStatusFailure(OrtStatus *status,std::ostringstream *os) { - const auto &api = Ort::GetApi(); - const char *msg = api.GetErrorMessage(status); - SHERPA_ONNX_LOGE( - "Failed to enable TensorRT : %s." - "Available providers: %s. Fallback to cuda", msg, os->str().c_str()); - api.ReleaseStatus(status); -} - } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/session.h b/sherpa-onnx/csrc/session.h index ac410fd92..a4121436a 100644 --- a/sherpa-onnx/csrc/session.h +++ b/sherpa-onnx/csrc/session.h @@ -47,8 +47,6 @@ Ort::SessionOptions GetSessionOptions(const AudioTaggingModelConfig &config); Ort::SessionOptions GetSessionOptions( const OfflinePunctuationModelConfig &config); -void OrtStatusFailure(OrtStatus *status,std::ostringstream *os); - } // namespace sherpa_onnx #endif // SHERPA_ONNX_CSRC_SESSION_H_ From 957996d83b43ea42cbc39fb698bcf3ee84e44977 Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 3 Jun 2024 16:48:03 +0000 Subject: [PATCH 06/12] cpp lint Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 5053db7fe..ca7e05ba7 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -23,7 +23,7 @@ namespace sherpa_onnx { -static void OrtStatusFailure(OrtStatus *status,std::ostringstream *os) { +static void OrtStatusFailure(OrtStatus *status, std::ostringstream *os) { const auto &api = Ort::GetApi(); const char *msg = api.GetErrorMessage(status); SHERPA_ONNX_LOGE( @@ -65,31 +65,29 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, break; } case Provider::kTRT: { - struct TrtPairs { const char* op_keys; const char* op_values; }; std::vector trt_options = { - {"device_id","0"}, - {"trt_max_workspace_size","2147483648"}, - {"trt_max_partition_iterations","10"}, - {"trt_min_subgraph_size","5"}, - {"trt_fp16_enable","0"}, - {"trt_detailed_build_log","0"}, - {"trt_engine_cache_enable","1"}, - {"trt_engine_cache_path","."}, - {"trt_timing_cache_enable","1"}, - {"trt_timing_cache_path","."} + {"device_id", "0"}, + {"trt_max_workspace_size", "2147483648"}, + {"trt_max_partition_iterations", "10"}, + {"trt_min_subgraph_size", "5"}, + {"trt_fp16_enable", "0"}, + {"trt_detailed_build_log", "0"}, + {"trt_engine_cache_enable", "1"}, + {"trt_engine_cache_path", "."}, + {"trt_timing_cache_enable", "1"}, + {"trt_timing_cache_path", "."} }; - // ToDo : Trt configs - // "trt_int8_enable", - // "trt_int8_use_native_calibration_table", - // "trt_dump_subgraphs", + // "trt_int8_enable" + // "trt_int8_use_native_calibration_table" + // "trt_dump_subgraphs" - std::vector option_keys,option_values; + std::vector option_keys, option_values; for (const TrtPairs& pair : trt_options) { option_keys.emplace_back(pair.op_keys); option_values.emplace_back(pair.op_values); @@ -108,12 +106,16 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, tensorrt_options, option_keys.data(), option_values.data(), option_keys.size()); - if (statusC) { OrtStatusFailure(statusC,&os);} - else if(statusU) { OrtStatusFailure(statusU,&os);} - else { + if (statusC) { + OrtStatusFailure(statusC, &os); + } else if (statusU) { + OrtStatusFailure(statusU, &os); + } else { auto *statusTrt = OrtSessionOptionsAppendExecutionProvider_Tensorrt( sess_opts, 0); - if(statusTrt) { OrtStatusFailure(statusTrt,&os);} + if (statusTrt) { + OrtStatusFailure(statusTrt, &os); + } } api.ReleaseTensorRTProviderOptions(tensorrt_options); From db321c1680d37e2c9eb3c76e4f6a00395901005e Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Mon, 3 Jun 2024 17:31:16 +0000 Subject: [PATCH 07/12] build errors fix attempt Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index ca7e05ba7..06b447c5b 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -106,17 +106,11 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, tensorrt_options, option_keys.data(), option_values.data(), option_keys.size()); - if (statusC) { - OrtStatusFailure(statusC, &os); - } else if (statusU) { - OrtStatusFailure(statusU, &os); - } else { - auto *statusTrt = OrtSessionOptionsAppendExecutionProvider_Tensorrt( + auto *statusTrt = OrtSessionOptionsAppendExecutionProvider_Tensorrt( sess_opts, 0); - if (statusTrt) { - OrtStatusFailure(statusTrt, &os); - } - } + if (statusC) { OrtStatusFailure(statusC, &os); } + if (statusU) { OrtStatusFailure(statusU, &os); } + if (statusTrt) { OrtStatusFailure(statusTrt, &os);} api.ReleaseTensorRTProviderOptions(tensorrt_options); } From b2085378645b32b91c0c96dfd8e11eb42fb36a75 Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Tue, 4 Jun 2024 07:45:19 +0000 Subject: [PATCH 08/12] stensorrt interface rewamp Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 06b447c5b..72f705376 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -105,12 +105,10 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, OrtStatus *statusU = api.UpdateTensorRTProviderOptions( tensorrt_options, option_keys.data(), option_values.data(), option_keys.size()); + sess_opts.AppendExecutionProvider_TensorRT_V2(*tensorrt_options); - auto *statusTrt = OrtSessionOptionsAppendExecutionProvider_Tensorrt( - sess_opts, 0); if (statusC) { OrtStatusFailure(statusC, &os); } if (statusU) { OrtStatusFailure(statusU, &os); } - if (statusTrt) { OrtStatusFailure(statusTrt, &os);} api.ReleaseTensorRTProviderOptions(tensorrt_options); } From 486c6872dfb9d69a21a6f8b23ed2f318ac3a85c1 Mon Sep 17 00:00:00 2001 From: Manix <50542248+manickavela29@users.noreply.github.com> Date: Wed, 5 Jun 2024 08:37:57 +0530 Subject: [PATCH 09/12] Update sherpa-onnx/csrc/session.cc Co-authored-by: Fangjun Kuang --- sherpa-onnx/csrc/session.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 72f705376..bb864463e 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -23,7 +23,7 @@ namespace sherpa_onnx { -static void OrtStatusFailure(OrtStatus *status, std::ostringstream *os) { +static void OrtStatusFailure(OrtStatus *status, const char *s) { const auto &api = Ort::GetApi(); const char *msg = api.GetErrorMessage(status); SHERPA_ONNX_LOGE( From e063d8c5aebdae30d872271939c7f7df8b48f81f Mon Sep 17 00:00:00 2001 From: Manix <50542248+manickavela29@users.noreply.github.com> Date: Wed, 5 Jun 2024 08:38:40 +0530 Subject: [PATCH 10/12] Update session.cc --- sherpa-onnx/csrc/session.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index bb864463e..7596d69ee 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -8,7 +8,6 @@ #include #include #include -// #include #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/provider.h" From f01c836c678ebc2c1e99bafaac8a26ef33513848 Mon Sep 17 00:00:00 2001 From: Manix <50542248+manickavela29@users.noreply.github.com> Date: Wed, 5 Jun 2024 08:39:21 +0530 Subject: [PATCH 11/12] Update sherpa-onnx/csrc/session.cc Co-authored-by: Fangjun Kuang --- sherpa-onnx/csrc/session.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 7596d69ee..52e1c2d77 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -111,7 +111,7 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, api.ReleaseTensorRTProviderOptions(tensorrt_options); } - // break; is ommited here intentially so that + // break; is omitted here intentionally so that // if TRT not available, CUDA will be used } case Provider::kCUDA: { From 62cd5033b5f0dcd87ecf6b9b1403820467e9a16f Mon Sep 17 00:00:00 2001 From: "manickavela1998@gmail.com" Date: Wed, 5 Jun 2024 03:37:30 +0000 Subject: [PATCH 12/12] fix bug Signed-off-by: manickavela1998@gmail.com --- sherpa-onnx/csrc/session.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sherpa-onnx/csrc/session.cc b/sherpa-onnx/csrc/session.cc index 52e1c2d77..431a6a761 100644 --- a/sherpa-onnx/csrc/session.cc +++ b/sherpa-onnx/csrc/session.cc @@ -27,7 +27,7 @@ static void OrtStatusFailure(OrtStatus *status, const char *s) { const char *msg = api.GetErrorMessage(status); SHERPA_ONNX_LOGE( "Failed to enable TensorRT : %s." - "Available providers: %s. Fallback to cuda", msg, os->str().c_str()); + "Available providers: %s. Fallback to cuda", msg, s); api.ReleaseStatus(status); } @@ -106,8 +106,8 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads, option_keys.size()); sess_opts.AppendExecutionProvider_TensorRT_V2(*tensorrt_options); - if (statusC) { OrtStatusFailure(statusC, &os); } - if (statusU) { OrtStatusFailure(statusU, &os); } + if (statusC) { OrtStatusFailure(statusC, os.str().c_str()); } + if (statusU) { OrtStatusFailure(statusU, os.str().c_str()); } api.ReleaseTensorRTProviderOptions(tensorrt_options); }