From e1ad88a798617a42e1ed20c3c8360c10555cb8e8 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Tue, 13 May 2025 12:15:57 +0200 Subject: [PATCH 3/5] Replace exception throwing code by abort, and remove try/catch --- .../core/optimizer/stft_decomposition.cc | 3 +- .../core/session/provider_bridge_ort.cc | 44 ++++--------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/onnxruntime/core/optimizer/stft_decomposition.cc b/onnxruntime/core/optimizer/stft_decomposition.cc index 5c09e5225a..7d8c75025d 100644 --- a/onnxruntime/core/optimizer/stft_decomposition.cc +++ b/onnxruntime/core/optimizer/stft_decomposition.cc @@ -31,7 +31,8 @@ constexpr static ONNX_NAMESPACE::TensorProto_DataType GetDataType() { } else if constexpr (std::is_same::value) { return ONNX_NAMESPACE::TensorProto_DataType_INT64; } else { - throw std::logic_error("Invalid data type requested for STFT decomposition"); + abort(); + //throw std::logic_error("Invalid data type requested for STFT decomposition"); } } diff --git a/onnxruntime/core/session/provider_bridge_ort.cc b/onnxruntime/core/session/provider_bridge_ort.cc index 042598535e..9bed2cfcbc 100644 --- a/onnxruntime/core/session/provider_bridge_ort.cc +++ b/onnxruntime/core/session/provider_bridge_ort.cc @@ -1701,11 +1701,9 @@ struct ProviderSharedLibrary { static ProviderSharedLibrary s_library_shared; -bool InitProvidersSharedLibrary() try { +bool InitProvidersSharedLibrary() { s_library_shared.Ensure(); return true; -} catch (const std::exception&) { - return false; } struct ProviderLibrary { @@ -1716,7 +1714,6 @@ struct ProviderLibrary { Provider& Get() { std::lock_guard lock{mutex_}; - try { if (!provider_) { s_library_shared.Ensure(); @@ -1730,10 +1727,6 @@ struct ProviderLibrary { provider_->Initialize(); } return *provider_; - } catch (const std::exception&) { - Unload(); // If anything fails we unload the library and rethrow - throw; - } } void Unload() { @@ -2050,11 +2043,8 @@ ProviderInfo_OpenVINO* GetProviderInfo_OpenVINO() { return reinterpret_cast(s_library_openvino.Get().GetInfo()); } -ProviderInfo_TensorRT* TryGetProviderInfo_TensorRT() try { +ProviderInfo_TensorRT* TryGetProviderInfo_TensorRT() { return reinterpret_cast(s_library_tensorrt.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_TensorRT& GetProviderInfo_TensorRT() { @@ -2064,11 +2054,8 @@ ProviderInfo_TensorRT& GetProviderInfo_TensorRT() { ORT_THROW("TensorRT Provider not available, can't get interface for it"); } -ProviderInfo_CUDA* TryGetProviderInfo_CUDA() try { +ProviderInfo_CUDA* TryGetProviderInfo_CUDA() { return reinterpret_cast(s_library_cuda.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_CUDA& GetProviderInfo_CUDA() { @@ -2078,11 +2065,8 @@ ProviderInfo_CUDA& GetProviderInfo_CUDA() { ORT_THROW("CUDA Provider not available, can't get interface for it"); } -ProviderInfo_CUDA* TryGetProviderInfo_CUDA_Test() try { +ProviderInfo_CUDA* TryGetProviderInfo_CUDA_Test() { return reinterpret_cast(s_library_cuda_test.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_CUDA& GetProviderInfo_CUDA_Test() { @@ -2092,11 +2076,8 @@ ProviderInfo_CUDA& GetProviderInfo_CUDA_Test() { ORT_THROW("CUDA Provider not available, can't get interface for it"); } -ProviderInfo_CANN* TryGetProviderInfo_CANN() try { +ProviderInfo_CANN* TryGetProviderInfo_CANN() { return reinterpret_cast(s_library_cann.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_CANN& GetProviderInfo_CANN() { @@ -2106,11 +2087,8 @@ ProviderInfo_CANN& GetProviderInfo_CANN() { ORT_THROW("CANN Provider not available, can't get interface for it"); } -ProviderInfo_Dnnl* TryGetProviderInfo_Dnnl() try { +ProviderInfo_Dnnl* TryGetProviderInfo_Dnnl() { return reinterpret_cast(s_library_dnnl.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_Dnnl& GetProviderInfo_Dnnl() { @@ -2120,11 +2098,8 @@ ProviderInfo_Dnnl& GetProviderInfo_Dnnl() { ORT_THROW("oneDNN Provider not available, can't get interface for it"); } -ProviderInfo_ROCM* TryGetProviderInfo_ROCM() try { +ProviderInfo_ROCM* TryGetProviderInfo_ROCM() { return reinterpret_cast(s_library_rocm.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_ROCM& GetProviderInfo_ROCM() { @@ -2134,11 +2109,8 @@ ProviderInfo_ROCM& GetProviderInfo_ROCM() { ORT_THROW("ROCM Provider not available, can't get interface for it"); } -ProviderInfo_MIGraphX* TryGetProviderInfo_MIGraphX() try { +ProviderInfo_MIGraphX* TryGetProviderInfo_MIGraphX() { return reinterpret_cast(s_library_migraphx.Get().GetInfo()); -} catch (const std::exception& exception) { - LOGS_DEFAULT(ERROR) << exception.what(); - return nullptr; } ProviderInfo_MIGraphX& GetProviderInfo_MIGraphX() { -- 2.49.0