From b2e9345708dde8db7285196920fb4902e0016254 Mon Sep 17 00:00:00 2001 From: wangchuanxia Date: Sat, 6 Jan 2024 18:31:41 +0800 Subject: [PATCH 1/2] fix dlopen stuck Signed-off-by: wangchuanxia --- frameworks/native/backend_manager.cpp | 3 +-- frameworks/native/backend_manager.h | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frameworks/native/backend_manager.cpp b/frameworks/native/backend_manager.cpp index 0d89213..2675d4e 100644 --- a/frameworks/native/backend_manager.cpp +++ b/frameworks/native/backend_manager.cpp @@ -16,7 +16,6 @@ #include "backend_manager.h" #include -#include "common/log.h" #include "cpp_type.h" namespace OHOS { @@ -131,4 +130,4 @@ bool BackendManager::IsValidBackend(std::shared_ptr backend) const return true; } } // NeuralNetworkCore -} // OHOS \ No newline at end of file +} // OHOS diff --git a/frameworks/native/backend_manager.h b/frameworks/native/backend_manager.h index 32d3fa5..3312af0 100644 --- a/frameworks/native/backend_manager.h +++ b/frameworks/native/backend_manager.h @@ -16,6 +16,7 @@ #ifndef NEURAL_NETWORK_CORE_BACKEND_MANAGER_H #define NEURAL_NETWORK_CORE_BACKEND_MANAGER_H +#include #include #include #include @@ -25,6 +26,7 @@ #include #include "backend.h" +#include "common/log.h" namespace OHOS { namespace NeuralNetworkRuntime { @@ -39,6 +41,13 @@ 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."); + } + } static BackendManager instance; return instance; } -- Gitee From 02a936b8dc2074143ed6e7c683c35d95fa6c78e4 Mon Sep 17 00:00:00 2001 From: wangchuanxia Date: Sat, 6 Jan 2024 18:38:47 +0800 Subject: [PATCH 2/2] fix dlopen stuck Signed-off-by: wangchuanxia --- frameworks/native/backend_manager.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/native/backend_manager.h b/frameworks/native/backend_manager.h index 3312af0..d5fb00a 100644 --- a/frameworks/native/backend_manager.h +++ b/frameworks/native/backend_manager.h @@ -43,11 +43,11 @@ public: { 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."); - } - } + 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; return instance; } -- Gitee