diff --git a/include/onnxruntime/core/session/environment.h b/include/onnxruntime/core/session/environment.h index 5f7f6e2ba1..d99c6713b9 100644 --- a/include/onnxruntime/core/session/environment.h +++ b/include/onnxruntime/core/session/environment.h @@ -74,6 +74,8 @@ class Environment { return shared_allocators_; } + ~Environment(); + private: ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Environment); diff --git a/onnxruntime/core/providers/cuda/math/variadic_elementwise_ops.cc b/onnxruntime/core/providers/cuda/math/variadic_elementwise_ops.cc index da1683f448..3ca37dfdd1 100644 --- a/onnxruntime/core/providers/cuda/math/variadic_elementwise_ops.cc +++ b/onnxruntime/core/providers/cuda/math/variadic_elementwise_ops.cc @@ -204,10 +204,20 @@ using MaxOp = VariadicElementwiseOp< variadic_elementwise_ops::Max, uint32_t, uint64_t, int32_t, int64_t, ALL_IEEE_FLOAT_DATA_TYPES>; -const auto k_uzilhfd_datatypes = - BuildKernelDefConstraints(); -const auto k_hfd_datatypes = - BuildKernelDefConstraints(); +struct Global { + Global() { + LOGS_DEFAULT(ERROR) << "LOGS_DEFAULT: Initializing CUDA provider globals..."; + } + + ~Global() { + LOGS_DEFAULT(ERROR) << "LOGS_DEFAULT: Destroying CUDA provider globals..."; + } +}; + +const Global GLOBAL; + +const auto k_uzilhfd_datatypes = BuildKernelDefConstraints(); +const auto k_hfd_datatypes = BuildKernelDefConstraints(); } // namespace diff --git a/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc b/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc index 565bfe56aa..4f6ef4bd2c 100644 --- a/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc +++ b/onnxruntime/core/providers/shared_library/provider_bridge_provider.cc @@ -12,7 +12,6 @@ #define _Ret_notnull_ #endif - #ifndef _Post_writable_byte_size_ #define _Post_writable_byte_size_(n) #endif @@ -26,8 +25,8 @@ ProviderHost* g_host = Provider_GetHost(); #ifdef _WIN32 // Override default new/delete so that we match the host's allocator _Ret_notnull_ _Post_writable_byte_size_(n) void* operator new(size_t n) { return Provider_GetHost()->HeapAllocate(n); } -void operator delete(void* p) { return Provider_GetHost()->HeapFree(p); } -void operator delete(void* p, size_t /*size*/) { return Provider_GetHost()->HeapFree(p); } +void operator delete(void* p) noexcept { return Provider_GetHost()->HeapFree(p); } +void operator delete(void* p, size_t /*size*/) noexcept { return Provider_GetHost()->HeapFree(p); } #endif namespace onnxruntime { diff --git a/onnxruntime/core/session/environment.cc b/onnxruntime/core/session/environment.cc index 25606dd644..a2c5b96e6d 100644 --- a/onnxruntime/core/session/environment.cc +++ b/onnxruntime/core/session/environment.cc @@ -3,6 +3,7 @@ #include "core/session/environment.h" #include "core/framework/allocatormgr.h" +#include "core/framework/provider_shutdown.h" #include "core/graph/constants.h" #include "core/graph/op.h" #if !defined(ORT_MINIMAL_BUILD) @@ -234,4 +235,11 @@ Internal copy node return status; } +Environment::~Environment() { +// We don't support any shared providers in the minimal build yet +#if !defined(ORT_MINIMAL_BUILD) + UnloadSharedProviders(); +#endif +} + } // namespace onnxruntime diff --git a/onnxruntime/core/session/ort_env.cc b/onnxruntime/core/session/ort_env.cc index c87e49ec1e..7346c38df3 100644 --- a/onnxruntime/core/session/ort_env.cc +++ b/onnxruntime/core/session/ort_env.cc @@ -10,7 +10,6 @@ #include "core/session/environment.h" #include "core/session/allocator_impl.h" #include "core/common/logging/logging.h" -#include "core/framework/provider_shutdown.h" #ifdef __ANDROID__ #include "core/platform/android/logging/android_log_sink.h" #else @@ -40,10 +39,6 @@ OrtEnv::OrtEnv(std::unique_ptr value1) } OrtEnv::~OrtEnv() { -// We don't support any shared providers in the minimal build yet -#if !defined(ORT_MINIMAL_BUILD) - UnloadSharedProviders(); -#endif } OrtEnv* OrtEnv::GetInstance(const OrtEnv::LoggingManagerConstructionInfo& lm_info,