diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index 1b043e81f34..b9dda935678 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -38,6 +38,7 @@ #include "openvino/util/shared_object.hpp" #include "ov_plugins.hpp" #include "preprocessing/preprocessing.hpp" +#include "so_extension.hpp" #include "xml_parse_utils.h" ov::ICore::~ICore() = default; @@ -523,6 +524,7 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const { } } else { TryToRegisterLibraryAsExtensionUnsafe(desc.libraryLocation); + try_to_register_plugin_extensions(desc.libraryLocation); } return plugins.emplace(deviceName, plugin).first->second; @@ -1084,12 +1086,13 @@ void ov::CoreImpl::set_property_for_device(const ov::AnyMap& configMap, const st }); } } - -void ov::CoreImpl::add_extension(const std::vector& extensions) { - std::lock_guard lock(get_mutex()); +void ov::CoreImpl::add_extensions_unsafe(const std::vector& extensions) const { for (const auto& ext : extensions) { ov_extensions.emplace_back(ext); - if (auto op_base_ext = std::dynamic_pointer_cast(ext)) { + auto ext_obj = ext; + if (auto so_ext = std::dynamic_pointer_cast(ext_obj)) + ext_obj = so_ext->extension(); + if (auto op_base_ext = std::dynamic_pointer_cast(ext_obj)) { for (const auto& attached_ext : op_base_ext->get_attached_extensions()) { ov_extensions.emplace_back(attached_ext); } @@ -1097,6 +1100,11 @@ void ov::CoreImpl::add_extension(const std::vector& extensio } } +void ov::CoreImpl::add_extension(const std::vector& extensions) { + std::lock_guard lock(get_mutex()); + add_extensions_unsafe(extensions); +} + const std::vector& ov::CoreImpl::GetExtensions() const { return extensions; } diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hpp index a13f9fb6cd6..e59aceb4a26 100644 --- a/src/inference/src/dev/core_impl.hpp +++ b/src/inference/src/dev/core_impl.hpp @@ -22,6 +22,7 @@ #include "openvino/runtime/common.hpp" #include "openvino/runtime/icompiled_model.hpp" #include "openvino/runtime/threading/executor_manager.hpp" +#include "so_extension.hpp" namespace ov { @@ -143,7 +144,7 @@ private: mutable std::unordered_set opsetNames; // TODO: make extensions to be optional with conditional compilation mutable std::vector extensions; - std::vector ov_extensions; + mutable std::vector ov_extensions; std::map pluginRegistry; @@ -176,6 +177,17 @@ private: ov::AnyMap create_compile_config(const ov::Plugin& plugin, const ov::AnyMap& origConfig) const; + template > + void try_to_register_plugin_extensions(const std::basic_string& path) const { + try { + auto plugin_extensions = ov::detail::load_extensions(path); + add_extensions_unsafe(plugin_extensions); + } catch (const std::runtime_error&) { + // in case of shared library is not opened + } + } + void add_extensions_unsafe(const std::vector& extensions) const; + // Legacy API void AddExtensionUnsafe(const InferenceEngine::IExtensionPtr& extension) const; template >