Remove plugins xml (#16470)

* Update core_impl.cpp

Add first implementation of register_compile_time_plugins (needs to depend on the actual CMake configuration as a next step).

* Update core.cpp

Check for missing plugins.xml

* Update core_impl.cpp

Avoid exception for missing plugins.xml

* Update core_impl.hpp

Add register_compile_time_plugins function definition

* Plugin loading based on CMake configuration

* Remove debug output command

* Unify static/dynamic plugin loading

* Add CMake option for plugins.xml that defaults to off

* Move GENERATE_PLUGINS_XML option to features.cmake

* Add missing brace

* Remove unnecessary #ifdef check

* Prepare to resolve conflicts

* Fix compile error

* Activate generation of plugins.xml in OpenVINODeveloperPackageConfig.cmake

* Fix CMake installation

* Plugin loading logic implemented in ie_core.cpp as well

* Fix format

* Small fixes

* Fixed code style

* Skip if xml file wasn't found

* Added function to find compiled plugins

* Generalize plugins hpp

* Use new API

* Fixed old core

* Fixed static build

---------

Co-authored-by: CSBVision <bjoern.boeken@csb.com>
This commit is contained in:
Ilya Churaev 2023-03-22 19:51:07 +04:00 committed by GitHub
parent 4561aa7109
commit c23a1170ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 191 additions and 118 deletions

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
foreach(var IE_DEVICE_MAPPING IE_PLUGINS_HPP_HEADER IE_PLUGINS_HPP_HEADER_IN) foreach(var IE_DEVICE_MAPPING OV_DYNAMIC IE_PLUGINS_HPP_HEADER IE_PLUGINS_HPP_HEADER_IN)
if(NOT DEFINED ${var}) if(NOT DEFINED ${var})
message(FATAL_ERROR "${var} is required, but not defined") message(FATAL_ERROR "${var} is required, but not defined")
endif() endif()
@ -19,20 +19,6 @@ foreach(dev_map IN LISTS IE_DEVICE_MAPPING)
list(GET dev_map 0 mapped_dev_name) list(GET dev_map 0 mapped_dev_name)
list(GET dev_map 1 actual_dev_name) list(GET dev_map 1 actual_dev_name)
# common
set(_IE_CREATE_PLUGIN_FUNC "CreatePluginEngine${actual_dev_name}")
set(_IE_CREATE_EXTENSION_FUNC "CreateExtensionShared${actual_dev_name}")
# declarations
set(IE_PLUGINS_DECLARATIONS "${IE_PLUGINS_DECLARATIONS}
IE_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_PLUGIN_FUNC});")
if(${actual_dev_name}_AS_EXTENSION)
set(IE_PLUGINS_DECLARATIONS "${IE_PLUGINS_DECLARATIONS}
IE_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_EXTENSION_FUNC});")
else()
set(_IE_CREATE_EXTENSION_FUNC "nullptr")
endif()
# definitions # definitions
set(dev_config "{") set(dev_config "{")
if(${mapped_dev_name}_CONFIG) if(${mapped_dev_name}_CONFIG)
@ -48,8 +34,28 @@ IE_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_EXTENSION_FUNC});")
endif() endif()
set(dev_config "${dev_config}}") set(dev_config "${dev_config}}")
if(NOT OV_DYNAMIC)
# common
set(_IE_CREATE_PLUGIN_FUNC "CreatePluginEngine${actual_dev_name}")
set(_IE_CREATE_EXTENSION_FUNC "CreateExtensionShared${actual_dev_name}")
# declarations
set(IE_PLUGINS_DECLARATIONS "${IE_PLUGINS_DECLARATIONS}
IE_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_PLUGIN_FUNC});")
if(${actual_dev_name}_AS_EXTENSION)
set(IE_PLUGINS_DECLARATIONS "${IE_PLUGINS_DECLARATIONS}
IE_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_EXTENSION_FUNC});")
else()
set(_IE_CREATE_EXTENSION_FUNC "nullptr")
endif()
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION} set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}
{ \"${mapped_dev_name}\", Value { ${_IE_CREATE_PLUGIN_FUNC}, ${_IE_CREATE_EXTENSION_FUNC}, ${dev_config} } },") { \"${mapped_dev_name}\", Value { ${_IE_CREATE_PLUGIN_FUNC}, ${_IE_CREATE_EXTENSION_FUNC}, ${dev_config} } },")
else()
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}
{ \"${mapped_dev_name}\", Value { \"${actual_dev_name}\", ${dev_config} } },")
endif()
endforeach() endforeach()
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION} set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}

View File

@ -227,6 +227,7 @@ macro(ie_register_plugins_dynamic)
# Combine all <device_name>.xml files into plugins.xml # Combine all <device_name>.xml files into plugins.xml
if(ENABLE_PLUGINS_XML)
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
COMMAND COMMAND
"${CMAKE_COMMAND}" "${CMAKE_COMMAND}"
@ -237,6 +238,7 @@ macro(ie_register_plugins_dynamic)
COMMENT COMMENT
"Registering plugins to plugins.xml config file" "Registering plugins to plugins.xml config file"
VERBATIM) VERBATIM)
endif()
endmacro() endmacro()
# #
@ -282,10 +284,6 @@ endfunction()
# ie_generate_plugins_hpp() # ie_generate_plugins_hpp()
# #
function(ie_generate_plugins_hpp) function(ie_generate_plugins_hpp)
if(BUILD_SHARED_LIBS)
return()
endif()
set(device_mapping) set(device_mapping)
set(device_configs) set(device_configs)
set(as_extension) set(as_extension)
@ -296,8 +294,13 @@ function(ie_generate_plugins_hpp)
message(FATAL_ERROR "Unexpected error, please, contact developer of this script") message(FATAL_ERROR "Unexpected error, please, contact developer of this script")
endif() endif()
# create device mapping: preudo device => actual device # create device mapping: pseudo device => actual device
list(GET name 0 device_name) list(GET name 0 device_name)
if(BUILD_SHARED_LIBS)
list(GET name 1 library_name)
ie_plugin_get_file_name(${library_name} library_name)
list(APPEND device_mapping "${device_name}:${library_name}")
else()
if(${device_name}_PSEUDO_PLUGIN_FOR) if(${device_name}_PSEUDO_PLUGIN_FOR)
list(APPEND device_mapping "${device_name}:${${device_name}_PSEUDO_PLUGIN_FOR}") list(APPEND device_mapping "${device_name}:${${device_name}_PSEUDO_PLUGIN_FOR}")
else() else()
@ -308,6 +311,7 @@ function(ie_generate_plugins_hpp)
if(${device_name}_AS_EXTENSION) if(${device_name}_AS_EXTENSION)
list(APPEND as_extension -D "${device_name}_AS_EXTENSION=ON") list(APPEND as_extension -D "${device_name}_AS_EXTENSION=ON")
endif() endif()
endif()
# add default plugin config options # add default plugin config options
if(${device_name}_CONFIG) if(${device_name}_CONFIG)
@ -330,6 +334,7 @@ function(ie_generate_plugins_hpp)
COMMAND COMMAND
"${CMAKE_COMMAND}" "${CMAKE_COMMAND}"
-D "IE_DEVICE_MAPPING=${device_mapping}" -D "IE_DEVICE_MAPPING=${device_mapping}"
-D "OV_DYNAMIC=${BUILD_SHARED_LIBS}"
-D "IE_PLUGINS_HPP_HEADER_IN=${plugins_hpp_in}" -D "IE_PLUGINS_HPP_HEADER_IN=${plugins_hpp_in}"
-D "IE_PLUGINS_HPP_HEADER=${ie_plugins_hpp}" -D "IE_PLUGINS_HPP_HEADER=${ie_plugins_hpp}"
${device_configs} ${device_configs}
@ -339,7 +344,7 @@ function(ie_generate_plugins_hpp)
"${plugins_hpp_in}" "${plugins_hpp_in}"
"${IEDevScripts_DIR}/plugins/create_plugins_hpp.cmake" "${IEDevScripts_DIR}/plugins/create_plugins_hpp.cmake"
COMMENT COMMENT
"Generate ie_plugins.hpp for static build" "Generate ie_plugins.hpp for build"
VERBATIM) VERBATIM)
# for some reason dependency on source files does not work # for some reason dependency on source files does not work

View File

@ -4,6 +4,11 @@
#pragma once #pragma once
#include <map>
#include <string>
#ifdef OPENVINO_STATIC_LIBRARY
#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "cpp_interfaces/interface/ie_iplugin_internal.hpp"
@IE_PLUGINS_DECLARATIONS@ @IE_PLUGINS_DECLARATIONS@
@ -14,10 +19,20 @@ struct Value {
std::map<std::string, std::string> m_default_config; std::map<std::string, std::string> m_default_config;
}; };
#else
struct Value {
std::string m_plugin_path;
std::map<std::string, std::string> m_default_config;
};
#endif
using Key = std::string; using Key = std::string;
using PluginsStaticRegistry = std::map<Key, Value>; using PluginsStaticRegistry = std::map<Key, Value>;
inline const std::map<Key, Value> getStaticPluginsRegistry() {
inline const std::map<Key, Value> getCompiledPluginsRegistry() {
@IE_PLUGINS_MAP_DEFINITION@ @IE_PLUGINS_MAP_DEFINITION@
return plugins_hpp; return plugins_hpp;
} }

View File

@ -94,6 +94,8 @@ ie_option (ENABLE_HETERO "Enables Hetero Device Plugin" ON)
ie_option (ENABLE_TEMPLATE "Enable template plugin" ON) ie_option (ENABLE_TEMPLATE "Enable template plugin" ON)
ie_dependent_option (ENABLE_PLUGINS_XML "Generate plugins.xml configuration file or not" OFF "NOT BUILD_SHARED_LIBS" OFF)
ie_dependent_option (GAPI_TEST_PERF "if GAPI unit tests should examine performance" OFF "ENABLE_TESTS;ENABLE_GAPI_PREPROCESSING" OFF) ie_dependent_option (GAPI_TEST_PERF "if GAPI unit tests should examine performance" OFF "ENABLE_TESTS;ENABLE_GAPI_PREPROCESSING" OFF)
ie_dependent_option (ENABLE_DATA "fetch models from testdata repo" ON "ENABLE_FUNCTIONAL_TESTS;NOT ANDROID" OFF) ie_dependent_option (ENABLE_DATA "fetch models from testdata repo" ON "ENABLE_FUNCTIONAL_TESTS;NOT ANDROID" OFF)

View File

@ -28,6 +28,9 @@ foreach(option IN LISTS ov_options)
endforeach() endforeach()
message(" ") message(" ")
# activate generation of plugins.xml
set(ENABLE_PLUGINS_XML ON)
# for samples in 3rd party projects # for samples in 3rd party projects
if(ENABLE_SAMPLES) if(ENABLE_SAMPLES)
set_and_check(gflags_DIR "@gflags_BINARY_DIR@") set_and_check(gflags_DIR "@gflags_BINARY_DIR@")

View File

@ -131,7 +131,7 @@ ie_cpack_add_component(${OV_CPACK_COMP_CORE_DEV}
HIDDEN HIDDEN
DEPENDS ${OV_CPACK_COMP_CORE} ${core_dev_components}) DEPENDS ${OV_CPACK_COMP_CORE} ${core_dev_components})
if(BUILD_SHARED_LIBS) if(ENABLE_PLUGINS_XML)
install(FILES $<TARGET_FILE_DIR:${TARGET_NAME}>/plugins.xml install(FILES $<TARGET_FILE_DIR:${TARGET_NAME}>/plugins.xml
DESTINATION ${OV_CPACK_PLUGINSDIR} DESTINATION ${OV_CPACK_PLUGINSDIR}
COMPONENT ${OV_CPACK_COMP_CORE}) COMPONENT ${OV_CPACK_COMP_CORE})

View File

@ -24,6 +24,13 @@ endif()
# Create named folders for the sources within the .vcproj # Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj # Empty name lists them directly under the .vcproj
set(MIXED_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/src/file_util.cpp")
set_property(SOURCE ${MIXED_SRC}
APPEND PROPERTY INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:ngraph_obj,INTERFACE_INCLUDE_DIRECTORIES>)
source_group("src" FILES ${LIBRARY_SRC}) source_group("src" FILES ${LIBRARY_SRC})
source_group("include" FILES ${PUBLIC_HEADERS}) source_group("include" FILES ${PUBLIC_HEADERS})

View File

@ -260,6 +260,14 @@ inline std::basic_string<C> make_plugin_library_name(const std::basic_string<C>&
*/ */
FilePath get_plugin_path(const std::string& plugin); FilePath get_plugin_path(const std::string& plugin);
/**
* @brief Find the plugins which are located together with OV library
* @param plugin - Path (absolute or relative) or name of a plugin. Depending on platform, `plugin` is wrapped with
* shared library suffix and prefix to identify library full name
* @return absolute path or file name with extension (to be found in ENV)
*/
FilePath get_compiled_plugin_path(const std::string& plugin);
/** /**
* @brief Format plugin path (canonicalize, complete to absolute or complete to file name) for further * @brief Format plugin path (canonicalize, complete to absolute or complete to file name) for further
* dynamic loading by OS * dynamic loading by OS

View File

@ -12,6 +12,7 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include "openvino/core/version.hpp"
#include "openvino/util/common_util.hpp" #include "openvino/util/common_util.hpp"
#ifdef _WIN32 #ifdef _WIN32
@ -504,6 +505,37 @@ ov::util::FilePath ov::util::get_plugin_path(const std::string& plugin) {
return ov::util::to_file_path(lib_name); return ov::util::to_file_path(lib_name);
} }
ov::util::FilePath ov::util::get_compiled_plugin_path(const std::string& plugin) {
const auto ov_library_path = get_ov_lib_path();
// plugin can be found either:
// 1. in openvino-X.Y.Z folder relative to libopenvino.so
std::ostringstream str;
str << "openvino-" << OPENVINO_VERSION_MAJOR << "." << OPENVINO_VERSION_MINOR << "." << OPENVINO_VERSION_PATCH;
const auto sub_folder = str.str();
std::string abs_file_path = ov::util::path_join({ov_library_path, sub_folder, plugin});
if (ov::util::file_exists(abs_file_path))
return ov::util::to_file_path(abs_file_path);
// 2. in the openvino.so location
abs_file_path = ov::util::path_join({ov_library_path, plugin});
if (ov::util::file_exists(abs_file_path))
return ov::util::to_file_path(abs_file_path);
auto lib_name = plugin;
// For 3rd case - convert to 4th case
if (!ov::util::ends_with(plugin, ov::util::FileTraits<char>::library_ext()))
lib_name = ov::util::make_plugin_library_name({}, plugin);
// For 4th case
auto lib_path = ov::util::to_file_path(ov::util::get_absolute_file_path(lib_name));
if (ov::util::file_exists(lib_path))
return lib_path;
return ov::util::to_file_path(lib_name);
}
ov::util::FilePath ov::util::get_plugin_path(const std::string& plugin, const std::string& xml_path, bool as_abs_only) { ov::util::FilePath ov::util::get_plugin_path(const std::string& plugin, const std::string& xml_path, bool as_abs_only) {
// Assume `plugin` (from XML "location" record) contains only: // Assume `plugin` (from XML "location" record) contains only:
// 1. /path/to/libexample.so absolute path // 1. /path/to/libexample.so absolute path

View File

@ -9,13 +9,10 @@
#include "dev/converter_utils.hpp" #include "dev/converter_utils.hpp"
#include "dev/core_impl.hpp" #include "dev/core_impl.hpp"
#include "ie_itt.hpp" #include "ie_itt.hpp"
#include "ie_plugins.hpp"
#include "openvino/runtime/device_id_parser.hpp" #include "openvino/runtime/device_id_parser.hpp"
#include "so_extension.hpp" #include "so_extension.hpp"
#ifdef OPENVINO_STATIC_LIBRARY
# include "ie_plugins.hpp"
#endif
namespace { namespace {
std::string resolve_extension_path(const std::string& path) { std::string resolve_extension_path(const std::string& path) {
std::string retvalue; std::string retvalue;
@ -32,8 +29,6 @@ std::string resolve_extension_path(const std::string& path) {
namespace ov { namespace ov {
#ifndef OPENVINO_STATIC_LIBRARY
std::string findPluginXML(const std::string& xmlFile) { std::string findPluginXML(const std::string& xmlFile) {
std::string xmlConfigFile_ = xmlFile; std::string xmlConfigFile_ = xmlFile;
if (xmlConfigFile_.empty()) { if (xmlConfigFile_.empty()) {
@ -56,14 +51,10 @@ std::string findPluginXML(const std::string& xmlFile) {
xmlConfigFileDefault = FileUtils::makePath(ielibraryDir, ov::util::to_file_path("plugins.xml")); xmlConfigFileDefault = FileUtils::makePath(ielibraryDir, ov::util::to_file_path("plugins.xml"));
if (FileUtils::fileExist(xmlConfigFileDefault)) if (FileUtils::fileExist(xmlConfigFileDefault))
return xmlConfigFile_ = ov::util::from_file_path(xmlConfigFileDefault); return xmlConfigFile_ = ov::util::from_file_path(xmlConfigFileDefault);
OPENVINO_THROW("Failed to find plugins.xml file");
} }
return xmlConfigFile_; return xmlConfigFile_;
} }
#endif // OPENVINO_STATIC_LIBRARY
#define OV_CORE_CALL_STATEMENT(...) \ #define OV_CORE_CALL_STATEMENT(...) \
try { \ try { \
__VA_ARGS__; \ __VA_ARGS__; \
@ -81,13 +72,13 @@ public:
Core::Core(const std::string& xml_config_file) { Core::Core(const std::string& xml_config_file) {
_impl = std::make_shared<Impl>(); _impl = std::make_shared<Impl>();
#ifdef OPENVINO_STATIC_LIBRARY std::string xmlConfigFile = ov::findPluginXML(xml_config_file);
OV_CORE_CALL_STATEMENT(_impl->register_plugins_in_registry(::getStaticPluginsRegistry());) if (!xmlConfigFile.empty())
#else
OV_CORE_CALL_STATEMENT( OV_CORE_CALL_STATEMENT(
// If XML is default, load default plugins by absolute paths // If XML is default, load default plugins by absolute paths
_impl->register_plugins_in_registry(findPluginXML(xml_config_file), xml_config_file.empty());) _impl->register_plugins_in_registry(xmlConfigFile, xml_config_file.empty());)
#endif // Load plugins from the pre-compiled list
OV_CORE_CALL_STATEMENT(_impl->register_compile_time_plugins();)
} }
std::map<std::string, Version> Core::get_versions(const std::string& device_name) const { std::map<std::string, Version> Core::get_versions(const std::string& device_name) const {

View File

@ -34,6 +34,7 @@
#include "openvino/runtime/remote_context.hpp" #include "openvino/runtime/remote_context.hpp"
#include "openvino/runtime/threading/executor_manager.hpp" #include "openvino/runtime/threading/executor_manager.hpp"
#include "openvino/util/common_util.hpp" #include "openvino/util/common_util.hpp"
#include "openvino/util/file_util.hpp"
#include "openvino/util/shared_object.hpp" #include "openvino/util/shared_object.hpp"
#include "preprocessing/preprocessing.hpp" #include "preprocessing/preprocessing.hpp"
#include "xml_parse_utils.h" #include "xml_parse_utils.h"
@ -311,6 +312,39 @@ ov::CoreImpl::CoreImpl(bool _newAPI) : m_new_api(_newAPI) {
} }
} }
void ov::CoreImpl::register_compile_time_plugins() {
std::lock_guard<std::mutex> lock(get_mutex());
const decltype(::getCompiledPluginsRegistry())& plugins = getCompiledPluginsRegistry();
#ifdef OPENVINO_STATIC_LIBRARY
for (const auto& plugin : plugins) {
const auto& deviceName = plugin.first;
if (deviceName.find('.') != std::string::npos) {
OPENVINO_THROW("Device name must not contain dot '.' symbol");
}
if (pluginRegistry.find(deviceName) == pluginRegistry.end()) {
const auto& value = plugin.second;
ov::AnyMap config = any_copy(value.m_default_config);
PluginDescriptor desc{value.m_create_plugin_func, config, value.m_create_extension_func};
pluginRegistry[deviceName] = desc;
add_mutex(deviceName);
}
}
#else
for (const auto& plugin : plugins) {
const auto& deviceName = plugin.first;
const auto& pluginPath = ov::util::get_compiled_plugin_path(plugin.second.m_plugin_path);
if (pluginRegistry.find(deviceName) == pluginRegistry.end() && ov::util::file_exists(pluginPath)) {
ov::AnyMap config = any_copy(plugin.second.m_default_config);
PluginDescriptor desc{pluginPath, config};
pluginRegistry[deviceName] = desc;
add_mutex(deviceName);
}
}
#endif
}
void ov::CoreImpl::register_plugins_in_registry(const std::string& xml_config_file, const bool& by_abs_path) { void ov::CoreImpl::register_plugins_in_registry(const std::string& xml_config_file, const bool& by_abs_path) {
std::lock_guard<std::mutex> lock(get_mutex()); std::lock_guard<std::mutex> lock(get_mutex());

View File

@ -15,6 +15,7 @@
#include "ie_cache_manager.hpp" #include "ie_cache_manager.hpp"
#include "ie_extension.h" #include "ie_extension.h"
#include "ie_icore.hpp" #include "ie_icore.hpp"
#include "ie_plugins.hpp"
#include "multi-device/multi_device_config.hpp" #include "multi-device/multi_device_config.hpp"
#include "openvino/core/any.hpp" #include "openvino/core/any.hpp"
#include "openvino/core/extension.hpp" #include "openvino/core/extension.hpp"
@ -22,10 +23,7 @@
#include "openvino/runtime/common.hpp" #include "openvino/runtime/common.hpp"
#include "openvino/runtime/icompiled_model.hpp" #include "openvino/runtime/icompiled_model.hpp"
#include "openvino/runtime/threading/executor_manager.hpp" #include "openvino/runtime/threading/executor_manager.hpp"
#include "openvino/util/file_util.hpp"
#ifdef OPENVINO_STATIC_LIBRARY
# include "ie_plugins.hpp"
#endif
namespace ov { namespace ov {
@ -48,16 +46,13 @@ Parsed parseDeviceNameIntoConfig(const std::string& deviceName, const AnyMap& co
* *
* @param device_name Target device * @param device_name Target device
* @param device_name_to_parse Device ID of property * @param device_name_to_parse Device ID of property
* @return true if ov::device::properties(<device_name_to_parse>, ...) is applicable for device identified by 'device_name * @return true if ov::device::properties(<device_name_to_parse>, ...) is applicable for device identified by
* 'device_name
*/ */
bool is_config_applicable(const std::string& device_name, const std::string& device_name_to_parse); bool is_config_applicable(const std::string& device_name, const std::string& device_name_to_parse);
#ifndef OPENVINO_STATIC_LIBRARY
std::string findPluginXML(const std::string& xmlFile); std::string findPluginXML(const std::string& xmlFile);
#endif
class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_this<InferenceEngine::ICore> { class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_this<InferenceEngine::ICore> {
private: private:
mutable std::map<std::string, ov::Plugin> plugins; mutable std::map<std::string, ov::Plugin> plugins;
@ -94,8 +89,7 @@ private:
// Creating thread-safe copy of config including shared_ptr to ICacheManager // Creating thread-safe copy of config including shared_ptr to ICacheManager
// Passing empty or not-existing name will return global cache config // Passing empty or not-existing name will return global cache config
CacheConfig get_cache_config_for_device(const ov::Plugin& plugin, CacheConfig get_cache_config_for_device(const ov::Plugin& plugin, ov::AnyMap& parsedConfig) const;
ov::AnyMap& parsedConfig) const;
private: private:
mutable std::mutex _cacheConfigMutex; mutable std::mutex _cacheConfigMutex;
@ -163,7 +157,8 @@ private:
const ov::RemoteContext& context, const ov::RemoteContext& context,
const CacheContent& cacheContent) const; const CacheContent& cacheContent) const;
static ov::SoPtr<ov::ICompiledModel> load_model_from_cache(const CacheContent& cacheContent, static ov::SoPtr<ov::ICompiledModel> load_model_from_cache(
const CacheContent& cacheContent,
ov::Plugin& plugin, ov::Plugin& plugin,
const ov::AnyMap& config, const ov::AnyMap& config,
const ov::RemoteContext& context, const ov::RemoteContext& context,
@ -181,8 +176,7 @@ private:
const ov::RemoteContext& context, const ov::RemoteContext& context,
const ov::AnyMap& config) const; const ov::AnyMap& config) const;
ov::AnyMap create_compile_config(const ov::Plugin& plugin, ov::AnyMap create_compile_config(const ov::Plugin& plugin, const ov::AnyMap& origConfig) const;
const ov::AnyMap& origConfig) const;
// Legacy API // Legacy API
void AddExtensionUnsafe(const InferenceEngine::IExtensionPtr& extension) const; void AddExtensionUnsafe(const InferenceEngine::IExtensionPtr& extension) const;
@ -218,30 +212,10 @@ public:
std::string& deviceName, std::string& deviceName,
ov::AnyMap& config) const; ov::AnyMap& config) const;
#ifdef OPENVINO_STATIC_LIBRARY /*
* @brief Register plugins according to the build configuration
/**
* @brief Register plugins for devices using statically defined configuration
* @note The function supports UNICODE path
* @param static_registry a statically defined configuration with device / plugin information
*/ */
void register_plugins_in_registry(const decltype(::getStaticPluginsRegistry())& static_registry) { void register_compile_time_plugins();
std::lock_guard<std::mutex> lock(get_mutex());
for (const auto& plugin : static_registry) {
const auto& deviceName = plugin.first;
if (deviceName.find('.') != std::string::npos) {
IE_THROW() << "Device name must not contain dot '.' symbol";
}
const auto& value = plugin.second;
ov::AnyMap config = any_copy(value.m_default_config);
PluginDescriptor desc{value.m_create_plugin_func, config, value.m_create_extension_func};
pluginRegistry[deviceName] = desc;
add_mutex(deviceName);
}
}
#endif
// //
// ICore public API // ICore public API

View File

@ -30,6 +30,7 @@
#include "ie_network_reader.hpp" #include "ie_network_reader.hpp"
#include "ie_ngraph_utils.hpp" #include "ie_ngraph_utils.hpp"
#include "ie_plugin_config.hpp" #include "ie_plugin_config.hpp"
#include "ie_plugins.hpp"
#include "ie_remote_context.hpp" #include "ie_remote_context.hpp"
#include "ngraph/graph_util.hpp" #include "ngraph/graph_util.hpp"
#include "ngraph/ngraph.hpp" #include "ngraph/ngraph.hpp"
@ -47,10 +48,6 @@
#include "so_extension.hpp" #include "so_extension.hpp"
#include "xml_parse_utils.h" #include "xml_parse_utils.h"
#ifdef OPENVINO_STATIC_LIBRARY
# include "ie_plugins.hpp"
#endif
using namespace InferenceEngine::PluginConfigParams; using namespace InferenceEngine::PluginConfigParams;
using namespace InferenceEngine; using namespace InferenceEngine;
using namespace std::placeholders; using namespace std::placeholders;
@ -91,13 +88,12 @@ public:
Core::Core(const std::string& xmlConfigFile) { Core::Core(const std::string& xmlConfigFile) {
_impl = std::make_shared<Impl>(); _impl = std::make_shared<Impl>();
#ifdef OPENVINO_STATIC_LIBRARY std::string xmlConfigFile_ = ov::findPluginXML(xmlConfigFile);
_impl->register_plugins_in_registry(::getStaticPluginsRegistry()); if (!xmlConfigFile_.empty())
#else
// If XML is default, load default plugins by absolute paths // If XML is default, load default plugins by absolute paths
auto loadByAbsPath = xmlConfigFile.empty(); _impl->register_plugins_in_registry(xmlConfigFile_, xmlConfigFile.empty());
_impl->register_plugins_in_registry(ov::findPluginXML(xmlConfigFile), loadByAbsPath); // Load plugins from pre-compiled list
#endif _impl->register_compile_time_plugins();
} }
std::map<std::string, Version> Core::GetVersions(const std::string& deviceName) const { std::map<std::string, Version> Core::GetVersions(const std::string& deviceName) const {