WA issues with dynamic protobuf usage in Fes (#20612)
This commit is contained in:
parent
ec2ae003aa
commit
361b250fc4
@ -20,21 +20,6 @@ class FrontEndManager::Impl {
|
|||||||
std::mutex m_loading_mutex;
|
std::mutex m_loading_mutex;
|
||||||
std::vector<PluginInfo> m_plugins;
|
std::vector<PluginInfo> m_plugins;
|
||||||
|
|
||||||
// Note, static methods below are required to create an order of initialization of static variables
|
|
||||||
// e.g. if users (not encouraged) created ov::Model globally, we need to ensure proper order of initialization
|
|
||||||
|
|
||||||
/// \return map of shared object per frontend <frontend_name, frontend_so_ptr>
|
|
||||||
static std::unordered_map<std::string, std::shared_ptr<void>>& get_shared_objects_map() {
|
|
||||||
static std::unordered_map<std::string, std::shared_ptr<void>> shared_objects_map;
|
|
||||||
return shared_objects_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \return Mutex to guard access the shared object map
|
|
||||||
static std::mutex& get_shared_objects_mutex() {
|
|
||||||
static std::mutex shared_objects_map_mutex;
|
|
||||||
return shared_objects_map_mutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Impl() {
|
Impl() {
|
||||||
search_all_plugins();
|
search_all_plugins();
|
||||||
@ -46,10 +31,6 @@ public:
|
|||||||
auto fe_obj = std::make_shared<FrontEnd>();
|
auto fe_obj = std::make_shared<FrontEnd>();
|
||||||
fe_obj->m_shared_object = std::make_shared<FrontEndSharedData>(plugin.get_so_pointer());
|
fe_obj->m_shared_object = std::make_shared<FrontEndSharedData>(plugin.get_so_pointer());
|
||||||
fe_obj->m_actual = plugin.get_creator().m_creator();
|
fe_obj->m_actual = plugin.get_creator().m_creator();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(get_shared_objects_mutex());
|
|
||||||
get_shared_objects_map().emplace(plugin.get_creator().m_name, fe_obj->m_shared_object);
|
|
||||||
|
|
||||||
return fe_obj;
|
return fe_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +145,7 @@ private:
|
|||||||
{".xml", {"ir", "ir"}},
|
{".xml", {"ir", "ir"}},
|
||||||
{".onnx", {"onnx", "onnx"}},
|
{".onnx", {"onnx", "onnx"}},
|
||||||
{".pb", {"tf", "tensorflow"}},
|
{".pb", {"tf", "tensorflow"}},
|
||||||
|
{".pbtxt", {"tf", "tensorflow"}},
|
||||||
{".tflite", {"tflite", "tensorflow_lite"}},
|
{".tflite", {"tflite", "tensorflow_lite"}},
|
||||||
{".pdmodel", {"paddle", "paddle"}},
|
{".pdmodel", {"paddle", "paddle"}},
|
||||||
// {".ts", {"pytorch", "pytorch"}},
|
// {".ts", {"pytorch", "pytorch"}},
|
||||||
|
@ -16,17 +16,32 @@
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <openvino/util/log.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "openvino/util/file_util.hpp"
|
#include "openvino/util/file_util.hpp"
|
||||||
|
#include "openvino/util/log.hpp"
|
||||||
#include "openvino/util/shared_object.hpp"
|
#include "openvino/util/shared_object.hpp"
|
||||||
#include "plugin_loader.hpp"
|
#include "plugin_loader.hpp"
|
||||||
|
|
||||||
using namespace ov;
|
using namespace ov;
|
||||||
using namespace ov::frontend;
|
using namespace ov::frontend;
|
||||||
|
|
||||||
|
// Note, static methods below are required to create an order of initialization of static variables
|
||||||
|
// e.g. if users (not encouraged) created ov::Model globally, we need to ensure proper order of initialization
|
||||||
|
|
||||||
|
/// \return map of shared object per frontend <frontend_name, frontend_so_ptr>
|
||||||
|
std::unordered_map<std::string, std::shared_ptr<void>>& ov::frontend::get_shared_objects_map() {
|
||||||
|
static std::unordered_map<std::string, std::shared_ptr<void>> shared_objects_map;
|
||||||
|
return shared_objects_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \return Mutex to guard access the shared object map
|
||||||
|
std::mutex& ov::frontend::get_shared_objects_mutex() {
|
||||||
|
static std::mutex shared_objects_map_mutex;
|
||||||
|
return shared_objects_map_mutex;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef OPENVINO_STATIC_LIBRARY
|
#ifdef OPENVINO_STATIC_LIBRARY
|
||||||
|
|
||||||
# include "ov_frontends.hpp"
|
# include "ov_frontends.hpp"
|
||||||
@ -131,6 +146,10 @@ bool PluginInfo::load() {
|
|||||||
m_load_failed = true;
|
m_load_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> guard(get_shared_objects_mutex());
|
||||||
|
get_shared_objects_map().emplace(get_creator().m_name, get_so_pointer());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <openvino/frontend/manager.hpp>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "openvino/frontend/manager.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static const char PathSeparator[] = ";";
|
static const char PathSeparator[] = ";";
|
||||||
@ -15,6 +20,9 @@ static const char PathSeparator[] = ":";
|
|||||||
namespace ov {
|
namespace ov {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
std::unordered_map<std::string, std::shared_ptr<void>>& get_shared_objects_map();
|
||||||
|
std::mutex& get_shared_objects_mutex();
|
||||||
|
|
||||||
/// \brief Internal data structure holding by each frontend. Includes library handle and extensions.
|
/// \brief Internal data structure holding by each frontend. Includes library handle and extensions.
|
||||||
class FrontEndSharedData {
|
class FrontEndSharedData {
|
||||||
friend inline void add_extension_to_shared_data(std::shared_ptr<void>& obj,
|
friend inline void add_extension_to_shared_data(std::shared_ptr<void>& obj,
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "common_test_utils/file_utils.hpp"
|
#include "common_test_utils/file_utils.hpp"
|
||||||
#include "openvino/op/relu.hpp"
|
#include "openvino/op/relu.hpp"
|
||||||
#include "openvino/op/swish.hpp"
|
#include "openvino/op/swish.hpp"
|
||||||
|
#include "openvino/runtime/core.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
using namespace ov::frontend;
|
using namespace ov::frontend;
|
||||||
@ -88,3 +89,30 @@ TEST_P(FrontendLibraryExtensionTest, verifyFunctions) {
|
|||||||
nodes.end());
|
nodes.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(FrontendLibraryExtensionTest, loadExtensionBeforeFrontend) {
|
||||||
|
// release all frontends internally
|
||||||
|
ov::shutdown();
|
||||||
|
|
||||||
|
const auto& lib_path = get_lib_path("test_builtin_extensions");
|
||||||
|
|
||||||
|
ov::Core core;
|
||||||
|
core.add_extension(lib_path);
|
||||||
|
|
||||||
|
auto model = core.read_model(m_param.m_modelName);
|
||||||
|
ASSERT_NE(nullptr, model);
|
||||||
|
|
||||||
|
const auto nodes = model->get_ops();
|
||||||
|
ASSERT_EQ(std::find_if(nodes.begin(),
|
||||||
|
nodes.end(),
|
||||||
|
[](const std::shared_ptr<ov::Node>& n) {
|
||||||
|
return ov::is_type<ov::op::v0::Relu>(n);
|
||||||
|
}),
|
||||||
|
nodes.end());
|
||||||
|
ASSERT_NE(std::find_if(nodes.begin(),
|
||||||
|
nodes.end(),
|
||||||
|
[](const std::shared_ptr<ov::Node>& n) {
|
||||||
|
return ov::is_type<ov::op::v4::Swish>(n);
|
||||||
|
}),
|
||||||
|
nodes.end());
|
||||||
|
}
|
||||||
|
8
thirdparty/dependencies.cmake
vendored
8
thirdparty/dependencies.cmake
vendored
@ -414,14 +414,14 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
|
|||||||
if(CMAKE_VERBOSE_MAKEFILE)
|
if(CMAKE_VERBOSE_MAKEFILE)
|
||||||
set(Protobuf_DEBUG ON)
|
set(Protobuf_DEBUG ON)
|
||||||
endif()
|
endif()
|
||||||
if(OV_VCPKG_BUILD)
|
|
||||||
set(protobuf_config CONFIG)
|
|
||||||
endif()
|
|
||||||
# try to find newer version first (major is changed)
|
# try to find newer version first (major is changed)
|
||||||
# see https://protobuf.dev/support/version-support/ and
|
# see https://protobuf.dev/support/version-support/ and
|
||||||
# https://github.com/protocolbuffers/protobuf/commit/d61f75ff6db36b4f9c0765f131f8edc2f86310fa
|
# https://github.com/protocolbuffers/protobuf/commit/d61f75ff6db36b4f9c0765f131f8edc2f86310fa
|
||||||
find_package(Protobuf 4.22.0 QUIET ${protobuf_config})
|
find_package(Protobuf 4.22.0 QUIET CONFIG)
|
||||||
if(NOT Protobuf_FOUND)
|
if(NOT Protobuf_FOUND)
|
||||||
|
if(OV_VCPKG_BUILD)
|
||||||
|
set(protobuf_config CONFIG)
|
||||||
|
endif()
|
||||||
# otherwise, fallback to existing default
|
# otherwise, fallback to existing default
|
||||||
find_package(Protobuf 3.20.3 REQUIRED ${protobuf_config})
|
find_package(Protobuf 3.20.3 REQUIRED ${protobuf_config})
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user