Remove test_execution_provider from training build

Only enable python atexit on windows
Remove assert on provider library exit
This commit is contained in:
Ryan Hill 2021-05-11 03:10:20 -07:00
parent fcb98063a2
commit 330339caa4
3 changed files with 12 additions and 3 deletions

View file

@ -1125,6 +1125,7 @@ endif()
# limit to only test on windows first, due to a runtime path issue on linux
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
AND NOT onnxruntime_ENABLE_TRAINING
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS"
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "Android")
AND NOT onnxruntime_BUILD_WEBASSEMBLY

View file

@ -886,8 +886,9 @@ struct ProviderSharedLibrary {
}
ProviderSharedLibrary() = default;
~ProviderSharedLibrary() { /*assert(!handle_);*/
} // We should already be unloaded at this point (disabled until Python shuts down deterministically)
~ProviderSharedLibrary() {
// assert(!handle_); // We should already be unloaded at this point (disabled until Python shuts down deterministically)
}
private:
void* handle_{};
@ -904,7 +905,7 @@ bool InitProvidersSharedLibrary() {
struct ProviderLibrary {
ProviderLibrary(const char* filename, bool unload = true) : filename_{filename}, unload_{unload} {}
~ProviderLibrary() {
assert(!handle_); // We should already be unloaded at this point
// assert(!handle_); // We should already be unloaded at this point (disabled until Python shuts down deterministically)
}
Provider* Get() {

View file

@ -2104,6 +2104,13 @@ PYBIND11_MODULE(onnxruntime_pybind11_state, m) {
const logging::Logger& default_logger = logging::LoggingManager::DefaultLogger();
LOGS(default_logger, WARNING) << "Init provider bridge failed.";
}
// It appears that only windows can safely unload the providers from python at this point
#ifdef _WIN32
atexit([] {
UnloadSharedProviders();
});
#endif
#endif
#ifdef ENABLE_TRAINING