Move unloading back to the OrtEnv as there are multiple Environments created during a session.

Remove some library dependencies for tests.
This commit is contained in:
Ryan Hill 2021-04-28 01:32:34 -07:00
parent 92be95d082
commit 42d744b51b
5 changed files with 14 additions and 20 deletions

View file

@ -396,17 +396,17 @@ endif()
set (onnxruntime_test_providers_dependencies ${onnxruntime_EXTERNAL_DEPENDENCIES})
if(onnxruntime_USE_CUDA)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cuda onnxruntime_providers_shared)
endif()
#if(onnxruntime_USE_CUDA)
# list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_cuda onnxruntime_providers_shared)
#endif()
if(onnxruntime_USE_DNNL)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_dnnl onnxruntime_providers_shared)
endif()
#if(onnxruntime_USE_DNNL)
# list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_dnnl onnxruntime_providers_shared)
#endif()
if(onnxruntime_USE_OPENVINO)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_openvino onnxruntime_providers_shared)
endif()
#if(onnxruntime_USE_OPENVINO)
# list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_openvino onnxruntime_providers_shared)
#endif()
if(onnxruntime_USE_NNAPI_BUILTIN)
list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_nnapi)

View file

@ -74,8 +74,6 @@ class Environment {
return shared_allocators_;
}
~Environment();
private:
ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Environment);

View file

@ -985,7 +985,6 @@ std::unique_ptr<IAllocator> CreateCUDAPinnedAllocator(int16_t device_id, const c
}
std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory_Cuda(const OrtCUDAProviderOptions* provider_options) {
LOGS_DEFAULT(ERROR) << "Trying to load CUDA provider (RyanHill)";
if (auto provider = s_library_cuda.Get())
return provider->CreateExecutionProviderFactory(provider_options);

View file

@ -3,7 +3,6 @@
#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)
@ -235,11 +234,4 @@ 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

View file

@ -10,6 +10,7 @@
#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
@ -39,6 +40,10 @@ 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,