mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Move unloading of shared providers into Environment
This commit is contained in:
parent
784743e1a1
commit
41144546d9
5 changed files with 26 additions and 12 deletions
|
|
@ -74,6 +74,8 @@ class Environment {
|
|||
return shared_allocators_;
|
||||
}
|
||||
|
||||
~Environment();
|
||||
|
||||
private:
|
||||
ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Environment);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<uint32_t, uint64_t, int32_t, int64_t, ALL_IEEE_FLOAT_DATA_TYPES>();
|
||||
const auto k_hfd_datatypes =
|
||||
BuildKernelDefConstraints<ALL_IEEE_FLOAT_DATA_TYPES>();
|
||||
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<uint32_t, uint64_t, int32_t, int64_t, ALL_IEEE_FLOAT_DATA_TYPES>();
|
||||
const auto k_hfd_datatypes = BuildKernelDefConstraints<ALL_IEEE_FLOAT_DATA_TYPES>();
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<onnxruntime::Environment> 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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue