diff --git a/frameworks/native/neural_network_core/backend_manager.h b/frameworks/native/neural_network_core/backend_manager.h index 5e25e87f523435dc80b6b340e2813e10e73ceccc..2f6297c87e5593f0185b0d634d4b03031faf2abc 100644 --- a/frameworks/native/neural_network_core/backend_manager.h +++ b/frameworks/native/neural_network_core/backend_manager.h @@ -41,11 +41,15 @@ public: static BackendManager& GetInstance() { - if (dlopen("libneural_network_runtime_ext.so", RTLD_NOLOAD) == nullptr) { - LOGI("dlopen libneural_network_runtime_ext.so."); - void* libHandle = dlopen("libneural_network_runtime_ext.so", RTLD_NOW | RTLD_GLOBAL); - if (libHandle == nullptr) { - LOGW("Failed to dlopen libneural_network_runtime_ext.so."); + // if libneural_network_runtime.so loaded + if (dlopen("libneural_network_runtime.so", RTLD_NOLOAD) != nullptr) { + // if libneural_network_runtime_ext.so not loaded, try to dlopen it + if (dlopen("libneural_network_runtime_ext.so", RTLD_NOLOAD) == nullptr) { + LOGI("dlopen libneural_network_runtime_ext.so."); + void* libHandle = dlopen("libneural_network_runtime_ext.so", RTLD_NOW | RTLD_GLOBAL); + if (libHandle == nullptr) { + LOGW("Failed to dlopen libneural_network_runtime_ext.so."); + } } } static BackendManager instance;