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:
parent
4561aa7109
commit
c23a1170ba
@ -2,7 +2,7 @@
|
||||
# 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})
|
||||
message(FATAL_ERROR "${var} is required, but not defined")
|
||||
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 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
|
||||
set(dev_config "{")
|
||||
if(${mapped_dev_name}_CONFIG)
|
||||
@ -48,8 +34,28 @@ IE_DEFINE_EXTENSION_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_EXTENSION_FUNC});")
|
||||
endif()
|
||||
set(dev_config "${dev_config}}")
|
||||
|
||||
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}
|
||||
|
||||
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}
|
||||
{ \"${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()
|
||||
|
||||
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}
|
||||
|
@ -113,7 +113,7 @@ function(ie_add_plugin)
|
||||
if(IE_PLUGIN_PSEUDO_DEVICE)
|
||||
set(plugin_hidden HIDDEN)
|
||||
endif()
|
||||
ie_cpack_add_component(${install_component}
|
||||
ie_cpack_add_component(${install_component}
|
||||
DISPLAY_NAME "${IE_PLUGIN_DEVICE_NAME} runtime"
|
||||
DESCRIPTION "${IE_PLUGIN_DEVICE_NAME} runtime"
|
||||
${plugin_hidden}
|
||||
@ -227,16 +227,18 @@ macro(ie_register_plugins_dynamic)
|
||||
|
||||
# Combine all <device_name>.xml files into plugins.xml
|
||||
|
||||
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "CMAKE_SHARED_MODULE_PREFIX=${CMAKE_SHARED_MODULE_PREFIX}"
|
||||
-D "IE_CONFIG_OUTPUT_FILE=${config_output_file}"
|
||||
-D "IE_CONFIGS_DIR=${CMAKE_BINARY_DIR}/plugins"
|
||||
-P "${IEDevScripts_DIR}/plugins/register_plugin_cmake.cmake"
|
||||
COMMENT
|
||||
"Registering plugins to plugins.xml config file"
|
||||
VERBATIM)
|
||||
if(ENABLE_PLUGINS_XML)
|
||||
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "CMAKE_SHARED_MODULE_PREFIX=${CMAKE_SHARED_MODULE_PREFIX}"
|
||||
-D "IE_CONFIG_OUTPUT_FILE=${config_output_file}"
|
||||
-D "IE_CONFIGS_DIR=${CMAKE_BINARY_DIR}/plugins"
|
||||
-P "${IEDevScripts_DIR}/plugins/register_plugin_cmake.cmake"
|
||||
COMMENT
|
||||
"Registering plugins to plugins.xml config file"
|
||||
VERBATIM)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
@ -282,10 +284,6 @@ endfunction()
|
||||
# ie_generate_plugins_hpp()
|
||||
#
|
||||
function(ie_generate_plugins_hpp)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(device_mapping)
|
||||
set(device_configs)
|
||||
set(as_extension)
|
||||
@ -296,17 +294,23 @@ function(ie_generate_plugins_hpp)
|
||||
message(FATAL_ERROR "Unexpected error, please, contact developer of this script")
|
||||
endif()
|
||||
|
||||
# create device mapping: preudo device => actual device
|
||||
# create device mapping: pseudo device => actual device
|
||||
list(GET name 0 device_name)
|
||||
if(${device_name}_PSEUDO_PLUGIN_FOR)
|
||||
list(APPEND device_mapping "${device_name}:${${device_name}_PSEUDO_PLUGIN_FOR}")
|
||||
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()
|
||||
list(APPEND device_mapping "${device_name}:${device_name}")
|
||||
endif()
|
||||
if(${device_name}_PSEUDO_PLUGIN_FOR)
|
||||
list(APPEND device_mapping "${device_name}:${${device_name}_PSEUDO_PLUGIN_FOR}")
|
||||
else()
|
||||
list(APPEND device_mapping "${device_name}:${device_name}")
|
||||
endif()
|
||||
|
||||
# register plugin as extension
|
||||
if(${device_name}_AS_EXTENSION)
|
||||
list(APPEND as_extension -D "${device_name}_AS_EXTENSION=ON")
|
||||
# register plugin as extension
|
||||
if(${device_name}_AS_EXTENSION)
|
||||
list(APPEND as_extension -D "${device_name}_AS_EXTENSION=ON")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# add default plugin config options
|
||||
@ -330,6 +334,7 @@ function(ie_generate_plugins_hpp)
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-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=${ie_plugins_hpp}"
|
||||
${device_configs}
|
||||
@ -339,7 +344,7 @@ function(ie_generate_plugins_hpp)
|
||||
"${plugins_hpp_in}"
|
||||
"${IEDevScripts_DIR}/plugins/create_plugins_hpp.cmake"
|
||||
COMMENT
|
||||
"Generate ie_plugins.hpp for static build"
|
||||
"Generate ie_plugins.hpp for build"
|
||||
VERBATIM)
|
||||
|
||||
# for some reason dependency on source files does not work
|
||||
|
@ -4,6 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
|
||||
#include "cpp_interfaces/interface/ie_iplugin_internal.hpp"
|
||||
|
||||
@IE_PLUGINS_DECLARATIONS@
|
||||
@ -14,10 +19,20 @@ struct Value {
|
||||
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 PluginsStaticRegistry = std::map<Key, Value>;
|
||||
|
||||
inline const std::map<Key, Value> getStaticPluginsRegistry() {
|
||||
|
||||
inline const std::map<Key, Value> getCompiledPluginsRegistry() {
|
||||
@IE_PLUGINS_MAP_DEFINITION@
|
||||
return plugins_hpp;
|
||||
}
|
||||
|
@ -94,6 +94,8 @@ ie_option (ENABLE_HETERO "Enables Hetero Device 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 (ENABLE_DATA "fetch models from testdata repo" ON "ENABLE_FUNCTIONAL_TESTS;NOT ANDROID" OFF)
|
||||
|
@ -28,6 +28,9 @@ foreach(option IN LISTS ov_options)
|
||||
endforeach()
|
||||
message(" ")
|
||||
|
||||
# activate generation of plugins.xml
|
||||
set(ENABLE_PLUGINS_XML ON)
|
||||
|
||||
# for samples in 3rd party projects
|
||||
if(ENABLE_SAMPLES)
|
||||
set_and_check(gflags_DIR "@gflags_BINARY_DIR@")
|
||||
|
@ -131,7 +131,7 @@ ie_cpack_add_component(${OV_CPACK_COMP_CORE_DEV}
|
||||
HIDDEN
|
||||
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
|
||||
DESTINATION ${OV_CPACK_PLUGINSDIR}
|
||||
COMPONENT ${OV_CPACK_COMP_CORE})
|
||||
|
@ -24,6 +24,13 @@ endif()
|
||||
# Create named folders for the sources within 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("include" FILES ${PUBLIC_HEADERS})
|
||||
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
* @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
|
||||
* dynamic loading by OS
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "openvino/core/version.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
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) {
|
||||
// Assume `plugin` (from XML "location" record) contains only:
|
||||
// 1. /path/to/libexample.so absolute path
|
||||
|
@ -9,13 +9,10 @@
|
||||
#include "dev/converter_utils.hpp"
|
||||
#include "dev/core_impl.hpp"
|
||||
#include "ie_itt.hpp"
|
||||
#include "ie_plugins.hpp"
|
||||
#include "openvino/runtime/device_id_parser.hpp"
|
||||
#include "so_extension.hpp"
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
# include "ie_plugins.hpp"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
std::string resolve_extension_path(const std::string& path) {
|
||||
std::string retvalue;
|
||||
@ -32,8 +29,6 @@ std::string resolve_extension_path(const std::string& path) {
|
||||
|
||||
namespace ov {
|
||||
|
||||
#ifndef OPENVINO_STATIC_LIBRARY
|
||||
|
||||
std::string findPluginXML(const std::string& xmlFile) {
|
||||
std::string xmlConfigFile_ = xmlFile;
|
||||
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"));
|
||||
if (FileUtils::fileExist(xmlConfigFileDefault))
|
||||
return xmlConfigFile_ = ov::util::from_file_path(xmlConfigFileDefault);
|
||||
|
||||
OPENVINO_THROW("Failed to find plugins.xml file");
|
||||
}
|
||||
return xmlConfigFile_;
|
||||
}
|
||||
|
||||
#endif // OPENVINO_STATIC_LIBRARY
|
||||
|
||||
#define OV_CORE_CALL_STATEMENT(...) \
|
||||
try { \
|
||||
__VA_ARGS__; \
|
||||
@ -81,13 +72,13 @@ public:
|
||||
Core::Core(const std::string& xml_config_file) {
|
||||
_impl = std::make_shared<Impl>();
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
OV_CORE_CALL_STATEMENT(_impl->register_plugins_in_registry(::getStaticPluginsRegistry());)
|
||||
#else
|
||||
OV_CORE_CALL_STATEMENT(
|
||||
// If XML is default, load default plugins by absolute paths
|
||||
_impl->register_plugins_in_registry(findPluginXML(xml_config_file), xml_config_file.empty());)
|
||||
#endif
|
||||
std::string xmlConfigFile = ov::findPluginXML(xml_config_file);
|
||||
if (!xmlConfigFile.empty())
|
||||
OV_CORE_CALL_STATEMENT(
|
||||
// If XML is default, load default plugins by absolute paths
|
||||
_impl->register_plugins_in_registry(xmlConfigFile, xml_config_file.empty());)
|
||||
// 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 {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "openvino/runtime/remote_context.hpp"
|
||||
#include "openvino/runtime/threading/executor_manager.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
#include "openvino/util/shared_object.hpp"
|
||||
#include "preprocessing/preprocessing.hpp"
|
||||
#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) {
|
||||
std::lock_guard<std::mutex> lock(get_mutex());
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "ie_cache_manager.hpp"
|
||||
#include "ie_extension.h"
|
||||
#include "ie_icore.hpp"
|
||||
#include "ie_plugins.hpp"
|
||||
#include "multi-device/multi_device_config.hpp"
|
||||
#include "openvino/core/any.hpp"
|
||||
#include "openvino/core/extension.hpp"
|
||||
@ -22,10 +23,7 @@
|
||||
#include "openvino/runtime/common.hpp"
|
||||
#include "openvino/runtime/icompiled_model.hpp"
|
||||
#include "openvino/runtime/threading/executor_manager.hpp"
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
# include "ie_plugins.hpp"
|
||||
#endif
|
||||
#include "openvino/util/file_util.hpp"
|
||||
|
||||
namespace ov {
|
||||
|
||||
@ -48,16 +46,13 @@ Parsed parseDeviceNameIntoConfig(const std::string& deviceName, const AnyMap& co
|
||||
*
|
||||
* @param device_name Target device
|
||||
* @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);
|
||||
|
||||
#ifndef OPENVINO_STATIC_LIBRARY
|
||||
|
||||
std::string findPluginXML(const std::string& xmlFile);
|
||||
|
||||
#endif
|
||||
|
||||
class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_this<InferenceEngine::ICore> {
|
||||
private:
|
||||
mutable std::map<std::string, ov::Plugin> plugins;
|
||||
@ -94,8 +89,7 @@ private:
|
||||
|
||||
// Creating thread-safe copy of config including shared_ptr to ICacheManager
|
||||
// Passing empty or not-existing name will return global cache config
|
||||
CacheConfig get_cache_config_for_device(const ov::Plugin& plugin,
|
||||
ov::AnyMap& parsedConfig) const;
|
||||
CacheConfig get_cache_config_for_device(const ov::Plugin& plugin, ov::AnyMap& parsedConfig) const;
|
||||
|
||||
private:
|
||||
mutable std::mutex _cacheConfigMutex;
|
||||
@ -158,16 +152,17 @@ private:
|
||||
const bool m_new_api;
|
||||
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model_and_cache(const std::shared_ptr<const ov::Model>& model,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& parsedConfig,
|
||||
const ov::RemoteContext& context,
|
||||
const CacheContent& cacheContent) const;
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& parsedConfig,
|
||||
const ov::RemoteContext& context,
|
||||
const CacheContent& cacheContent) const;
|
||||
|
||||
static ov::SoPtr<ov::ICompiledModel> load_model_from_cache(const CacheContent& cacheContent,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& config,
|
||||
const ov::RemoteContext& context,
|
||||
std::function<ov::SoPtr<ov::ICompiledModel>()> compile_model_lambda);
|
||||
static ov::SoPtr<ov::ICompiledModel> load_model_from_cache(
|
||||
const CacheContent& cacheContent,
|
||||
ov::Plugin& plugin,
|
||||
const ov::AnyMap& config,
|
||||
const ov::RemoteContext& context,
|
||||
std::function<ov::SoPtr<ov::ICompiledModel>()> compile_model_lambda);
|
||||
|
||||
bool device_supports_import_export(const ov::Plugin& plugin) const;
|
||||
|
||||
@ -177,12 +172,11 @@ private:
|
||||
bool device_supports_cache_dir(const ov::Plugin& plugin) const;
|
||||
|
||||
ov::SoPtr<ov::ICompiledModel> compile_model_with_preprocess(ov::Plugin& plugin,
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const;
|
||||
const std::shared_ptr<const ov::Model>& model,
|
||||
const ov::RemoteContext& context,
|
||||
const ov::AnyMap& config) const;
|
||||
|
||||
ov::AnyMap create_compile_config(const ov::Plugin& plugin,
|
||||
const ov::AnyMap& origConfig) const;
|
||||
ov::AnyMap create_compile_config(const ov::Plugin& plugin, const ov::AnyMap& origConfig) const;
|
||||
|
||||
// Legacy API
|
||||
void AddExtensionUnsafe(const InferenceEngine::IExtensionPtr& extension) const;
|
||||
@ -218,30 +212,10 @@ public:
|
||||
std::string& deviceName,
|
||||
ov::AnyMap& config) const;
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
|
||||
/**
|
||||
* @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
|
||||
/*
|
||||
* @brief Register plugins according to the build configuration
|
||||
*/
|
||||
void register_plugins_in_registry(const decltype(::getStaticPluginsRegistry())& static_registry) {
|
||||
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
|
||||
void register_compile_time_plugins();
|
||||
|
||||
//
|
||||
// ICore public API
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "ie_network_reader.hpp"
|
||||
#include "ie_ngraph_utils.hpp"
|
||||
#include "ie_plugin_config.hpp"
|
||||
#include "ie_plugins.hpp"
|
||||
#include "ie_remote_context.hpp"
|
||||
#include "ngraph/graph_util.hpp"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
@ -47,10 +48,6 @@
|
||||
#include "so_extension.hpp"
|
||||
#include "xml_parse_utils.h"
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
# include "ie_plugins.hpp"
|
||||
#endif
|
||||
|
||||
using namespace InferenceEngine::PluginConfigParams;
|
||||
using namespace InferenceEngine;
|
||||
using namespace std::placeholders;
|
||||
@ -91,13 +88,12 @@ public:
|
||||
Core::Core(const std::string& xmlConfigFile) {
|
||||
_impl = std::make_shared<Impl>();
|
||||
|
||||
#ifdef OPENVINO_STATIC_LIBRARY
|
||||
_impl->register_plugins_in_registry(::getStaticPluginsRegistry());
|
||||
#else
|
||||
// If XML is default, load default plugins by absolute paths
|
||||
auto loadByAbsPath = xmlConfigFile.empty();
|
||||
_impl->register_plugins_in_registry(ov::findPluginXML(xmlConfigFile), loadByAbsPath);
|
||||
#endif
|
||||
std::string xmlConfigFile_ = ov::findPluginXML(xmlConfigFile);
|
||||
if (!xmlConfigFile_.empty())
|
||||
// If XML is default, load default plugins by absolute paths
|
||||
_impl->register_plugins_in_registry(xmlConfigFile_, xmlConfigFile.empty());
|
||||
// Load plugins from pre-compiled list
|
||||
_impl->register_compile_time_plugins();
|
||||
}
|
||||
|
||||
std::map<std::string, Version> Core::GetVersions(const std::string& deviceName) const {
|
||||
|
Loading…
Reference in New Issue
Block a user