From 8fb699a42c0a14cf736fe98da9bdf1999ae01da5 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 28 Oct 2021 11:33:56 +0300 Subject: [PATCH] Static compilation for inference plugins (#8197) * 1. Removed explicit SHARED from libraries 2. Fixed double definition for ie_layer_validators * Fixed SEG in unit-test: order of initialization for global vars * Added an ability to find plugins.xml from static IE * Fixes in unit-test * Migrated to new macro for import / export * Minimized number of custom dllexport * Don't use IR v7 for static libraries * Revert for merge * Don't enable tests with dlopen for static libraries * Code style * Added condition for export * Revert format_reader * Removed forward decalaration with external linkage * Fixed IE linkage on Windows * Reverted back 2 flags * Minimal RRTI for cpuFuncTests * Minimal RRTI for cpuFuncTests * Still need IR v7 reader * Fixed build * Fixed compilation * clang-format fix * Removed BUILD_AS_IS and used USE_STATIC_IE * Enable IR v7 reader as static library * Fixed compilation for GPU plugin * Trying to build plugins as static library * Plugins are able provide their own name for CreatePluginEngine function * Fixed CPU * Fixed comments * Fixed ENABLE_IR_V7_READER usage * Fixed VPU * clang-format * Fixes * Fix * Load multiple plugins at once * Fixed interpreter undefined symbols * Trying to dynamically register static plugins * Reverted some ngraph changes * Fixed cpuUnitTests compilation * Fixed compilation * Fixed myriad * Fixed custom_opset tests * Reverted linker flags * Support both static and dynamic plugins * Fixed compilation of myriadFuncTests * Removed duplication * Fixes after self-review * Fixed linkage for preprocessing * Fixes for Windows * Fixes * Fixed cmake options * Fix * Fix * Fix 2 --- .../api_validator/api_validator.cmake | 6 + .../plugins/create_plugins_hpp.cmake | 32 +++++ cmake/developer_package/plugins/plugins.cmake | 116 +++++++++++++++--- .../developer_package/plugins/plugins.hpp.in | 14 +++ .../vs_version/vs_version.cmake | 2 +- cmake/features.cmake | 12 ++ .../tests/functional/CMakeLists.txt | 5 +- .../ie_bridges/c/tests/CMakeLists.txt | 4 +- inference-engine/src/CMakeLists.txt | 31 ++++- .../src/inference_engine/CMakeLists.txt | 72 +++++++---- .../inference_engine/src/cpp/ie_plugin.hpp | 12 +- .../src/inference_engine/src/ie_core.cpp | 82 ++++++++++--- .../src/ie_network_reader.cpp | 35 ++++-- .../include/legacy/ngraph_ops/nms_ie.hpp | 6 - .../include/legacy/ngraph_ops/onehot_ie.hpp | 4 - .../convert_nms_5_to_legacy.hpp | 4 - .../convert_one_hot_to_one_hot_ie.hpp | 4 - .../src/multi_device/CMakeLists.txt | 1 + .../interface/ie_iplugin_internal.hpp | 30 ++++- .../src/preprocessing/CMakeLists.txt | 17 ++- inference-engine/src/readers/CMakeLists.txt | 4 +- .../src/readers/ir_reader_v7/CMakeLists.txt | 12 +- .../src/readers/ir_reader_v7/ie_ir_reader.cpp | 2 +- .../src/readers/reader_api/ie_reader.hpp | 3 +- .../inference_engine/CMakeLists.txt | 20 ++- .../functional/plugin/myriad/CMakeLists.txt | 2 +- .../functional/plugin/shared/CMakeLists.txt | 11 +- .../behavior/shared_tests/CMakeLists.txt | 6 +- .../functional/gna/CMakeLists.txt | 8 +- .../functional/shared_tests/CMakeLists.txt | 11 +- .../functional/vpu/CMakeLists.txt | 7 +- .../include/openvino/core/partial_shape.hpp | 4 +- ngraph/test/opset.cpp | 4 + .../test/runtime/interpreter/CMakeLists.txt | 2 +- 34 files changed, 455 insertions(+), 130 deletions(-) create mode 100644 cmake/developer_package/plugins/create_plugins_hpp.cmake create mode 100644 cmake/developer_package/plugins/plugins.hpp.in diff --git a/cmake/developer_package/api_validator/api_validator.cmake b/cmake/developer_package/api_validator/api_validator.cmake index 204289dc83c..ed168178fe3 100644 --- a/cmake/developer_package/api_validator/api_validator.cmake +++ b/cmake/developer_package/api_validator/api_validator.cmake @@ -51,6 +51,12 @@ endfunction() set(VALIDATED_LIBRARIES "" CACHE INTERNAL "") function(_ie_add_api_validator_post_build_step) + if(NOT BUILD_SHARED_LIBS) + # since _ie_add_api_validator_post_build_step + # is currently run only on shared libraries, we have nothing to test + return() + endif() + set(UWP_API_VALIDATOR_APIS "${PROGRAMFILES}/Windows Kits/10/build/universalDDIs/x64/UniversalDDIs.xml") set(UWP_API_VALIDATOR_EXCLUSION "${UWP_SDK_PATH}/BinaryExclusionlist.xml") diff --git a/cmake/developer_package/plugins/create_plugins_hpp.cmake b/cmake/developer_package/plugins/create_plugins_hpp.cmake new file mode 100644 index 00000000000..bd5c1d5ca2e --- /dev/null +++ b/cmake/developer_package/plugins/create_plugins_hpp.cmake @@ -0,0 +1,32 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +foreach(var IE_DEVICE_NAMES IE_PLUGINS_HPP_HEADER IE_PLUGINS_HPP_HEADER_IN) + if(NOT DEFINED ${var}) + message(FATAL_ERROR "${var} is required, but not defined") + endif() +endforeach() + +# configure variables + +set(IE_PLUGINS_DECLARATIONS "") +set(IE_PLUGINS_MAP_DEFINITION + "std::map plugins_hpp = {") + +foreach(dev_name IN LISTS IE_DEVICE_NAMES) + set(_IE_CREATE_PLUGIN_FUNC "CreatePluginEngine${dev_name}") + set(IE_PLUGINS_DECLARATIONS "${IE_PLUGINS_DECLARATIONS} +IE_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(${_IE_CREATE_PLUGIN_FUNC})") + set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION} + { \"${dev_name}\", ${_IE_CREATE_PLUGIN_FUNC} },") +endforeach() + +set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION} +};\n") + + +message("${IE_PLUGINS_DECLARATIONS}") +message("${IE_PLUGINS_MAP_DEFINITION}") + +configure_file("${IE_PLUGINS_HPP_HEADER_IN}" "${IE_PLUGINS_HPP_HEADER}" @ONLY) diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index 07e2d664028..a2c0d2076cd 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -55,8 +55,20 @@ function(ie_add_plugin) add_cpplint_target(${obj_lib}_cpplint FOR_TARGETS ${obj_lib}) endforeach() - add_library(${IE_PLUGIN_NAME} MODULE ${input_files}) + if(BUILD_SHARED_LIBS) + set(library_type MODULE) + else() + set(library_type STATIC) + endif() + + add_library(${IE_PLUGIN_NAME} ${library_type} ${input_files}) + target_compile_definitions(${IE_PLUGIN_NAME} PRIVATE IMPLEMENT_INFERENCE_ENGINE_PLUGIN) + if(NOT BUILD_SHARED_LIBS) + # to distinguish functions creating plugin objects + target_compile_definitions(${IE_PLUGIN_NAME} PRIVATE + IE_CREATE_PLUGIN=CreatePluginEngine${IE_PLUGIN_DEVICE_NAME}) + endif() ie_add_vs_version_file(NAME ${IE_PLUGIN_NAME} FILEDESCRIPTION "Inference Engine ${IE_PLUGIN_DEVICE_NAME} device plugin library") @@ -87,23 +99,25 @@ function(ie_add_plugin) endif() add_dependencies(ie_plugins ${IE_PLUGIN_NAME}) - if(TARGET inference_engine_preproc) + if(TARGET inference_engine_preproc AND BUILD_SHARED_LIBS) add_dependencies(${IE_PLUGIN_NAME} inference_engine_preproc) endif() # fake dependencies to build in the following order: # IE -> IE readers -> IE inference plugins -> IE-based apps - if(TARGET ir_ngraph_frontend) - add_dependencies(${IE_PLUGIN_NAME} ir_ngraph_frontend) - endif() - if(TARGET inference_engine_ir_v7_reader) - add_dependencies(${IE_PLUGIN_NAME} inference_engine_ir_v7_reader) - endif() - if(TARGET onnx_ngraph_frontend) - add_dependencies(${IE_PLUGIN_NAME} onnx_ngraph_frontend) - endif() - if(TARGET paddlepaddle_ngraph_frontend) - add_dependencies(${IE_PLUGIN_NAME} paddlepaddle_ngraph_frontend) + if(BUILD_SHARED_LIBS) + if(TARGET ir_ngraph_frontend) + add_dependencies(${IE_PLUGIN_NAME} ir_ngraph_frontend) + endif() + if(TARGET inference_engine_ir_v7_reader) + add_dependencies(${IE_PLUGIN_NAME} inference_engine_ir_v7_reader) + endif() + if(TARGET onnx_ngraph_frontend) + add_dependencies(${IE_PLUGIN_NAME} onnx_ngraph_frontend) + endif() + if(TARGET paddlepaddle_ngraph_frontend) + add_dependencies(${IE_PLUGIN_NAME} paddlepaddle_ngraph_frontend) + endif() endif() # install rules @@ -137,10 +151,10 @@ function(ie_add_plugin) endfunction() # -# ie_register_plugins(MAIN_TARGET
-# POSSIBLE_PLUGINS ) +# ie_register_plugins_dynamic(MAIN_TARGET
+# POSSIBLE_PLUGINS ) # -macro(ie_register_plugins) +macro(ie_register_plugins_dynamic) set(options) set(oneValueArgs MAIN_TARGET) set(multiValueArgs POSSIBLE_PLUGINS) @@ -205,3 +219,73 @@ macro(ie_register_plugins) "Registering plugins to plugins.xml config file" VERBATIM) endmacro() + +# +# ie_register_plugins_static(MAIN_TARGET
+# POSSIBLE_PLUGINS ) +# +macro(ie_register_plugins_static) + set(options) + set(oneValueArgs MAIN_TARGET) + set(multiValueArgs POSSIBLE_PLUGINS) + cmake_parse_arguments(IE_REGISTER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(device_names) + foreach(name IN LISTS PLUGIN_FILES) + string(REPLACE ":" ";" name "${name}") + list(LENGTH name length) + if(NOT ${length} EQUAL 2) + message(FATAL_ERROR "Unexpected error, please, contact developer of this script") + endif() + + list(GET name 0 device_name) + list(APPEND device_names ${device_name}) + + list(GET name 1 plugin_name) + target_link_libraries(${IE_REGISTER_MAIN_TARGET} PRIVATE ${plugin_name}) + endforeach() + + set(ie_plugins_hpp "${CMAKE_CURRENT_BINARY_DIR}/ie_plugins.hpp") + set(plugins_hpp_in "${IEDevScripts_DIR}/plugins/plugins.hpp.in") + + add_custom_command(OUTPUT "${ie_plugins_hpp}" + COMMAND + "${CMAKE_COMMAND}" + -D "IE_DEVICE_NAMES=${device_names}" + -D "IE_PLUGINS_HPP_HEADER_IN=${plugins_hpp_in}" + -D "IE_PLUGINS_HPP_HEADER=${ie_plugins_hpp}" + -P "${IEDevScripts_DIR}/plugins/create_plugins_hpp.cmake" + DEPENDS + "${plugins_hpp_in}" + "${IEDevScripts_DIR}/plugins/create_plugins_hpp.cmake" + COMMENT + "Generate ie_plugins.hpp for static build" + VERBATIM) + + # add dependency for object files + get_target_property(sources ${IE_REGISTER_MAIN_TARGET} SOURCES) + foreach(source IN LISTS sources) + if("${source}" MATCHES "\\$\\") + # object library + set(obj_library ${CMAKE_MATCH_1}) + get_target_property(obj_sources ${obj_library} SOURCES) + list(APPEND patched_sources ${obj_sources}) + else() + # usual source + list(APPEND patched_sources ${source}) + endif() + endforeach() + set_source_files_properties(${patched_sources} PROPERTIES OBJECT_DEPENDS ${ie_plugins_hpp}) +endmacro() + +# +# ie_register_plugins(MAIN_TARGET
+# POSSIBLE_PLUGINS ) +# +macro(ie_register_plugins) + if(BUILD_SHARED_LIBS) + ie_register_plugins_dynamic(${ARGN}) + else() + ie_register_plugins_static(${ARGN}) + endif() +endmacro() diff --git a/cmake/developer_package/plugins/plugins.hpp.in b/cmake/developer_package/plugins/plugins.hpp.in new file mode 100644 index 00000000000..2ddf338e433 --- /dev/null +++ b/cmake/developer_package/plugins/plugins.hpp.in @@ -0,0 +1,14 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" + +namespace { +@IE_PLUGINS_DECLARATIONS@ + +@IE_PLUGINS_MAP_DEFINITION@ + +} // namespace diff --git a/cmake/developer_package/vs_version/vs_version.cmake b/cmake/developer_package/vs_version/vs_version.cmake index 14d4c0e1e26..df959467776 100644 --- a/cmake/developer_package/vs_version/vs_version.cmake +++ b/cmake/developer_package/vs_version/vs_version.cmake @@ -26,7 +26,7 @@ set(IE_VS_VER_COMMENTS_STR "https://docs.openvinotoolkit.org/") # [PRODUCTVERSION_QUAD ]) # function(ie_add_vs_version_file) - if(NOT WIN32) + if(NOT WIN32 OR NOT BUILD_SHARED_LIBS) return() endif() diff --git a/cmake/features.cmake b/cmake/features.cmake index 12e14863d8a..c50f6f4da9a 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -78,6 +78,18 @@ if (ENABLE_GNA) endif() endif() +if(ENABLE_TESTS OR BUILD_SHARED_LIBS) + set(ENABLE_IR_V7_READER_DEFAULT ON) +else() + set(ENABLE_IR_V7_READER_DEFAULT OFF) +endif() + +ie_option (ENABLE_IR_V7_READER "Enables IR v7 reader" ${ENABLE_IR_V7_READER_DEFAULT}) + +ie_option (ENABLE_MULTI "Enables Multi Device Plugin" ON) + +ie_option (ENABLE_HETERO "Enables Hetero Device Plugin" ON) + ie_dependent_option (ENABLE_VPU "vpu targeted plugins for inference engine" ON "NOT WINDOWS_PHONE;NOT WINDOWS_STORE" OFF) ie_dependent_option (ENABLE_MYRIAD "myriad targeted plugin for inference engine" ON "ENABLE_VPU" OFF) diff --git a/docs/template_plugin/tests/functional/CMakeLists.txt b/docs/template_plugin/tests/functional/CMakeLists.txt index 85f40435461..16db218346d 100644 --- a/docs/template_plugin/tests/functional/CMakeLists.txt +++ b/docs/template_plugin/tests/functional/CMakeLists.txt @@ -10,7 +10,6 @@ addIeTargetTest( ROOT ${CMAKE_CURRENT_SOURCE_DIR} DEPENDENCIES templatePlugin - HeteroPlugin LINK_LIBRARIES IE::funcSharedTests INCLUDES @@ -21,6 +20,10 @@ addIeTargetTest( TEMPLATE ) +if(ENABLE_HETERO) + add_dependencies(${TARGET_NAME} HeteroPlugin) +endif() + find_package(OpenCV QUIET COMPONENTS core imgproc) if(OpenCV_FOUND) diff --git a/inference-engine/ie_bridges/c/tests/CMakeLists.txt b/inference-engine/ie_bridges/c/tests/CMakeLists.txt index 59476a38c38..dd6bd3db021 100644 --- a/inference-engine/ie_bridges/c/tests/CMakeLists.txt +++ b/inference-engine/ie_bridges/c/tests/CMakeLists.txt @@ -26,7 +26,9 @@ target_compile_definitions(${TARGET_NAME} DATA_PATH=\"${DATA_PATH}\" MODELS_PATH=\"${MODELS_PATH}\" ) -add_dependencies(${TARGET_NAME} MultiDevicePlugin) +if(ENABLE_MULTI) + add_dependencies(${TARGET_NAME} MultiDevicePlugin) +endif() if(ENABLE_MKL_DNN) add_dependencies(${TARGET_NAME} MKLDNNPlugin) diff --git a/inference-engine/src/CMakeLists.txt b/inference-engine/src/CMakeLists.txt index 73e1df69a7f..0465aab7404 100644 --- a/inference-engine/src/CMakeLists.txt +++ b/inference-engine/src/CMakeLists.txt @@ -9,8 +9,6 @@ endif() add_subdirectory(preprocessing) -add_subdirectory(readers) - add_subdirectory(legacy_api) if(ENABLE_MKL_DNN) @@ -29,13 +27,19 @@ if(ENABLE_GNA) add_subdirectory(gna_plugin) endif() -add_subdirectory(hetero_plugin) +if(ENABLE_HETERO) + add_subdirectory(hetero_plugin) +endif() -add_subdirectory(multi_device) +if(ENABLE_MULTI) + add_subdirectory(multi_device) +endif() + +add_subdirectory(inference_engine) add_subdirectory(transformations) -add_subdirectory(inference_engine) +add_subdirectory(readers) add_subdirectory(low_precision_transformations) @@ -48,9 +52,24 @@ add_subdirectory(snippets) add_custom_target(ie_libraries ALL DEPENDS inference_engine_transformations inference_engine_legacy inference_engine inference_engine_preproc - inference_engine_ir_v7_reader ir_ngraph_frontend inference_engine_lp_transformations inference_engine_snippets) +if(ENABLE_IR_V7_READER) + add_dependencies(ie_libraries inference_engine_ir_v7_reader) +endif() + +if(NGRAPH_IR_FRONTEND_ENABLE) + add_dependencies(ie_libraries ir_ngraph_frontend) +endif() + if(NGRAPH_ONNX_FRONTEND_ENABLE) add_dependencies(ie_libraries onnx_ngraph_frontend) endif() + +if(NGRAPH_PDPD_FRONTEND_ENABLE) + add_dependencies(ie_libraries paddlepaddle_ngraph_frontend) +endif() + +if(NGRAPH_TF_FRONTEND_ENABLE) + add_dependencies(ie_libraries tensorflow_ngraph_frontend) +endif() diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt index bf4581bc99c..782655e1391 100644 --- a/inference-engine/src/inference_engine/CMakeLists.txt +++ b/inference-engine/src/inference_engine/CMakeLists.txt @@ -28,11 +28,16 @@ set(LEGACY_LIBRARY_SHARED_SRCS "${LEGACY_SRC_ROOT}/ngraph_ops/onehot_ie.cpp") set_source_files_properties(${LEGACY_LIBRARY_SHARED_SRCS} PROPERTIES - COMPILE_DEFINITIONS "BUILD_AS_IE_SOURCES") + COMPILE_DEFINITIONS "USE_STATIC_IE") set(IE_STATIC_DEPENDENT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/file_utils.cpp) list(REMOVE_ITEM LIBRARY_SRC ${IE_STATIC_DEPENDENT_FILES}) +if(ENABLE_IR_V7_READER) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/ie_network_reader.cpp PROPERTIES + COMPILE_DEFINITIONS "ENABLE_IR_V7_READER") +endif() + file (GLOB LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp @@ -94,7 +99,8 @@ add_library(${TARGET_NAME}_plugin_api INTERFACE) target_include_directories(${TARGET_NAME}_plugin_api INTERFACE "${IE_MAIN_SOURCE_DIR}/src/plugin_api" $ - ${PUBLIC_HEADERS_DIR} ${PUBLIC_HEADERS_DIR}/ie) + ${PUBLIC_HEADERS_DIR} + ${PUBLIC_HEADERS_DIR}/ie) target_link_libraries(${TARGET_NAME}_plugin_api INTERFACE pugixml::static openvino::itt openvino::util) @@ -126,6 +132,7 @@ target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $) target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" + "${CMAKE_CURRENT_BINARY_DIR}" # for static ie_plugins.hpp "${IE_MAIN_SOURCE_DIR}/src/readers/ir_reader_v7" # for ie_ir_version.hpp $ $ @@ -187,35 +194,48 @@ ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME}) # Static library used for unit tests which are always built -add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL - $ - $ - ${IE_STATIC_DEPENDENT_FILES}) +if(BUILD_SHARED_LIBS) + add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL + $ + $ + ${IE_STATIC_DEPENDENT_FILES}) -set_ie_threading_interface_for(${TARGET_NAME}_s) -if (TBBBIND_2_4_FOUND) - target_compile_definitions(${TARGET_NAME}_s PRIVATE -DTBBBIND_2_4_AVAILABLE) - target_link_libraries(${TARGET_NAME}_s PRIVATE ${TBBBIND_2_4_IMPORTED_TARGETS}) + set_ie_threading_interface_for(${TARGET_NAME}_s) + if (TBBBIND_2_4_FOUND) + target_compile_definitions(${TARGET_NAME}_s PRIVATE -DTBBBIND_2_4_AVAILABLE) + target_link_libraries(${TARGET_NAME}_s PRIVATE ${TBBBIND_2_4_IMPORTED_TARGETS}) + endif() + + target_include_directories(${TARGET_NAME}_s PUBLIC + $ + "${CMAKE_CURRENT_SOURCE_DIR}/src" + "${IE_MAIN_SOURCE_DIR}/src/legacy_api/src") + + if(WIN32) + set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s) + endif() + + target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS} ngraph + frontend_manager::static inference_engine_transformations pugixml::static) + + target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE) + + set_target_properties(${TARGET_NAME}_s PROPERTIES + EXCLUDE_FROM_ALL ON + INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) +else() + # for static OpenVINO build we can re-use inference_engine which is already static + add_library(${TARGET_NAME}_s ALIAS ${TARGET_NAME}) + + target_include_directories(${TARGET_NAME} PUBLIC + $ + "${CMAKE_CURRENT_SOURCE_DIR}/src" + "${IE_MAIN_SOURCE_DIR}/src/legacy_api/src") endif() -target_include_directories(${TARGET_NAME}_s PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src" - $ - "${IE_MAIN_SOURCE_DIR}/src/legacy_api/src") - -if(WIN32) - set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s) -endif() - -target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS} ngraph frontend_manager::static - inference_engine_transformations pugixml::static) - -target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE) - -set_target_properties(${TARGET_NAME}_s PROPERTIES EXCLUDE_FROM_ALL ON) - # LTO -set_target_properties(${TARGET_NAME} ${TARGET_NAME}_obj ${TARGET_NAME}_s +set_target_properties(${TARGET_NAME} ${TARGET_NAME}_obj PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) # Export for build tree diff --git a/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp b/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp index 8631812dc6e..bd1718d55d9 100644 --- a/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp +++ b/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp @@ -37,11 +37,10 @@ namespace InferenceEngine { * * It can throw exceptions safely for the application, where it is properly handled. */ -class InferencePlugin : protected details::SOPointer { - using details::SOPointer::SOPointer; - friend class ICore; +struct InferencePlugin { + std::shared_ptr _so; + std::shared_ptr _ptr; -public: void SetName(const std::string & deviceName) { PLUGIN_CALL_STATEMENT(_ptr->SetName(deviceName)); } @@ -139,10 +138,13 @@ namespace runtime { * * It can throw exceptions safely for the application, where it is properly handled. */ -struct InferencePlugin { +class InferencePlugin { std::shared_ptr _so; std::shared_ptr _ptr; +public: + InferencePlugin() = default; + InferencePlugin(const std::shared_ptr& so, const std::shared_ptr& impl) : _so{so}, _ptr{impl} { diff --git a/inference-engine/src/inference_engine/src/ie_core.cpp b/inference-engine/src/inference_engine/src/ie_core.cpp index bfefc6db874..c292a08bd5c 100644 --- a/inference-engine/src/inference_engine/src/ie_core.cpp +++ b/inference-engine/src/inference_engine/src/ie_core.cpp @@ -40,6 +40,10 @@ #include "openvino/util/shared_object.hpp" #include "xml_parse_utils.h" +#ifdef OPENVINO_STATIC_LIBRARY +# include "ie_plugins.hpp" +#endif + using namespace InferenceEngine::PluginConfigParams; using namespace std::placeholders; @@ -48,11 +52,7 @@ namespace runtime { namespace { -template -struct Parsed { - std::string _deviceName; - std::map _config; -}; +#ifndef OPENVINO_STATIC_LIBRARY std::string parseXmlConfig(const std::string& xmlFile) { std::string xmlConfigFile_ = xmlFile; @@ -65,6 +65,14 @@ std::string parseXmlConfig(const std::string& xmlFile) { return xmlConfigFile_; } +#endif + +template +struct Parsed { + std::string _deviceName; + std::map _config; +}; + template Parsed parseDeviceNameIntoConfig(const std::string& deviceName, const std::map& config = {}) { auto config_ = config; @@ -179,10 +187,13 @@ class CoreImpl : public ie::ICore, public std::enable_shared_from_this defaultConfig; + // TODO: make extensions to be optional with conditional compilation std::vector listOfExtentions; + InferenceEngine::CreatePluginEngineFunc* pluginCreateFunc; }; mutable std::unordered_set opsetNames; + // TODO: make extensions to be optional with conditional compilation mutable std::vector extensions; std::map pluginRegistry; @@ -225,7 +236,7 @@ class CoreImpl : public ie::ICore, public std::enable_shared_from_this compile_model_impl( const InferenceEngine::CNNNetwork& network, - InferencePlugin& plugin, + ov::runtime::InferencePlugin& plugin, const std::map& parsedConfig, const ie::RemoteContext::Ptr& context, const std::string& blobID, @@ -363,13 +374,14 @@ public: opsetNames.insert("opset5"); opsetNames.insert("opset6"); opsetNames.insert("opset7"); + opsetNames.insert("opset8"); } ~CoreImpl() override = default; /** - * @brief Register plugins for devices which are located in .xml configuration file. The function supports UNICODE - * path + * @brief Register plugins for devices which are located in .xml configuration file. + * @note The function supports UNICODE path * @param xmlConfigFile An .xml configuraion with device / plugin information */ void RegisterPluginsInRegistry(const std::string& xmlConfigFile) { @@ -427,12 +439,32 @@ public: // fill value in plugin registry for later lazy initialization { - PluginDescriptor desc = {pluginPath, config, listOfExtentions}; + PluginDescriptor desc = {pluginPath, config, listOfExtentions, nullptr}; pluginRegistry[deviceName] = desc; } } } + /** + * @brief Register plugins for devices which are located in .xml configuration file. + * @note The function supports UNICODE path + * @param xmlConfigFile An .xml configuraion with device / plugin information + */ + void RegisterPluginsInRegistry( + const std::map& static_registry) { + std::lock_guard lock(pluginsMutex); + + 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"; + } + // TODO: add properties support to enable AUTO device + PluginDescriptor desc = {{}, {}, {}, plugin.second}; + pluginRegistry[deviceName] = desc; + } + } + // // ICore public API // @@ -727,12 +759,21 @@ public: auto it_plugin = plugins.find(deviceName); if (it_plugin == plugins.end()) { PluginDescriptor desc = it->second; - auto so = ov::util::load_shared_object(desc.libraryLocation.c_str()); + std::shared_ptr so; try { - using CreateF = void(std::shared_ptr&); - std::shared_ptr plugin_impl; - reinterpret_cast(ov::util::get_symbol(so, OV_PP_TOSTRING(IE_CREATE_PLUGIN)))(plugin_impl); - auto plugin = InferencePlugin{so, plugin_impl}; + ov::runtime::InferencePlugin plugin; + + if (desc.pluginCreateFunc) { // static OpenVINO case + std::shared_ptr plugin_impl; + desc.pluginCreateFunc(plugin_impl); + plugin = InferencePlugin{nullptr, plugin_impl}; + } else { + so = ov::util::load_shared_object(desc.libraryLocation.c_str()); + std::shared_ptr plugin_impl; + reinterpret_cast( + ov::util::get_symbol(so, InferenceEngine::create_plugin_function))(plugin_impl); + plugin = InferencePlugin{so, plugin_impl}; + } { plugin.set_name(deviceName); @@ -788,6 +829,7 @@ public: auto result = plugins.emplace(deviceName, plugin).first->second; + // TODO CVS-69016: need to enable for CPU plugin cache TryToRegisterLibraryAsExtensionUnsafe(desc.libraryLocation); return result; @@ -842,7 +884,7 @@ public: pluginPath = absFilePath; } - PluginDescriptor desc = {pluginPath, {}, {}}; + PluginDescriptor desc = {pluginPath, {}, {}, nullptr}; pluginRegistry[deviceName] = desc; } @@ -1092,7 +1134,11 @@ public: Core::Core(const std::string& xmlConfigFile) { _impl = std::make_shared(); +#ifdef OPENVINO_STATIC_LIBRARY + _impl->RegisterPluginsInRegistry(::plugins_hpp); +#else RegisterPlugins(ov::runtime::parseXmlConfig(xmlConfigFile)); +#endif } std::map Core::GetVersions(const std::string& deviceName) const { @@ -1351,7 +1397,11 @@ public: Core::Core(const std::string& xmlConfigFile) { _impl = std::make_shared(); - OV_CORE_CALL_STATEMENT(register_plugins(parseXmlConfig(xmlConfigFile))); +#ifdef OPENVINO_STATIC_LIBRARY + _impl->RegisterPluginsInRegistry(::plugins_hpp); +#else + register_plugins(parseXmlConfig(xmlConfigFile)); +#endif } std::map Core::get_versions(const std::string& deviceName) const { diff --git a/inference-engine/src/inference_engine/src/ie_network_reader.cpp b/inference-engine/src/inference_engine/src/ie_network_reader.cpp index 671179c2ad6..d247965dda4 100644 --- a/inference-engine/src/inference_engine/src/ie_network_reader.cpp +++ b/inference-engine/src/inference_engine/src/ie_network_reader.cpp @@ -37,7 +37,7 @@ namespace InferenceEngine { -#ifndef OPENVINO_STATIC_LIBRARY +#ifdef ENABLE_IR_V7_READER namespace details { @@ -59,34 +59,46 @@ public: * @brief This class is a wrapper for reader interfaces */ class Reader : public IReader { - InferenceEngine::details::SOPointer ptr; +# ifdef OPENVINO_STATIC_LIBRARY + using ReaderPtr = std::shared_ptr; +# else + using ReaderPtr = InferenceEngine::details::SOPointer; +# endif + ReaderPtr ptr; std::once_flag readFlag; std::string name; std::string location; - InferenceEngine::details::SOPointer getReaderPtr() { + ReaderPtr getReaderPtr() { std::call_once(readFlag, [&]() { +# ifdef OPENVINO_STATIC_LIBRARY + // call library creator directly, since we are in the same application + InferenceEngine::CreateReader(ptr); + OPENVINO_ASSERT(ptr != nullptr, "Failed to create static version of IR v7 reader"); +# else ov::util::FilePath libraryName = ov::util::to_file_path(location); ov::util::FilePath readersLibraryPath = FileUtils::makePluginLibraryName(getInferenceEngineLibraryPath(), libraryName); if (!FileUtils::fileExist(readersLibraryPath)) { - IE_THROW() << "Please, make sure that Inference Engine ONNX reader library " + IE_THROW() << "Please, make sure that Inference Engine reader library exists " << ov::util::from_file_path(::FileUtils::makePluginLibraryName({}, libraryName)) << " is in " << getIELibraryPath(); } ptr = {readersLibraryPath}; +# endif // OPENVINO_STATIC_LIBRARY }); return ptr; } - InferenceEngine::details::SOPointer getReaderPtr() const { + ReaderPtr getReaderPtr() const { return const_cast(this)->getReaderPtr(); } public: using Ptr = std::shared_ptr; + Reader(const std::string& name, const std::string location) : name(name), location(location) {} bool supportModel(std::istream& model) const override { OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "Reader::supportModel"); @@ -126,12 +138,14 @@ void registerReaders() { return; auto create_if_exists = [](const std::string name, const std::string library_name) { +# ifndef OPENVINO_STATIC_LIBRARY ov::util::FilePath libraryName = ov::util::to_file_path(library_name); ov::util::FilePath readersLibraryPath = FileUtils::makePluginLibraryName(getInferenceEngineLibraryPath(), libraryName); if (!FileUtils::fileExist(readersLibraryPath)) return std::shared_ptr(); +# endif // !OPENVINO_STATIC_LIBRARY return std::make_shared(name, library_name); }; @@ -243,7 +257,7 @@ CNNNetwork load_ir_v7_network(const std::string& modelPath, } // namespace -#endif // OPENVINO_STATIC_LIBRARY +#endif // ENABLE_IR_V7_READER namespace { @@ -396,7 +410,7 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath, const std::string& binPath, const std::vector& exts, bool newAPI) { -#ifndef OPENVINO_STATIC_LIBRARY +#ifdef ENABLE_IR_V7_READER // IR v7 obsolete code { // Register readers if it is needed @@ -410,7 +424,7 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath, } OPENVINO_SUPPRESS_DEPRECATED_END } -#endif // OPENVINO_STATIC_LIBRARY +#endif // ENABLE_IR_V7_READER // Fix unicode name #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) @@ -460,12 +474,11 @@ CNNNetwork details::ReadNetwork(const std::string& model, std::istringstream modelStringStream(model); std::istream& modelStream = modelStringStream; -#ifndef OPENVINO_STATIC_LIBRARY +#ifdef ENABLE_IR_V7_READER // IR v7 obsolete code { // Register readers if it is needed registerReaders(); - assertIfIRv7LikeModel(modelStream); for (auto it = readers.begin(); it != readers.end(); it++) { @@ -478,7 +491,7 @@ CNNNetwork details::ReadNetwork(const std::string& model, } } } -#endif // OPENVINO_STATIC_LIBRARY +#endif // ENABLE_IR_V7_READER // Try to load with FrontEndManager auto& manager = get_frontend_manager(); diff --git a/inference-engine/src/legacy_api/include/legacy/ngraph_ops/nms_ie.hpp b/inference-engine/src/legacy_api/include/legacy/ngraph_ops/nms_ie.hpp index 4f07c96d64d..83363c95cd8 100644 --- a/inference-engine/src/legacy_api/include/legacy/ngraph_ops/nms_ie.hpp +++ b/inference-engine/src/legacy_api/include/legacy/ngraph_ops/nms_ie.hpp @@ -14,15 +14,9 @@ namespace ngraph { namespace op { -#ifdef BUILD_AS_IE_SOURCES -class NonMaxSuppressionIE; -class NonMaxSuppressionIE2; -class NonMaxSuppressionIE3; -#else class INFERENCE_ENGINE_API_CLASS(NonMaxSuppressionIE); class INFERENCE_ENGINE_API_CLASS(NonMaxSuppressionIE2); class INFERENCE_ENGINE_API_CLASS(NonMaxSuppressionIE3); -#endif } // namespace op } // namespace ngraph diff --git a/inference-engine/src/legacy_api/include/legacy/ngraph_ops/onehot_ie.hpp b/inference-engine/src/legacy_api/include/legacy/ngraph_ops/onehot_ie.hpp index 90861762bb7..9ba2e59cde0 100644 --- a/inference-engine/src/legacy_api/include/legacy/ngraph_ops/onehot_ie.hpp +++ b/inference-engine/src/legacy_api/include/legacy/ngraph_ops/onehot_ie.hpp @@ -16,11 +16,7 @@ namespace ngraph { namespace op { -#ifdef BUILD_AS_IE_SOURCES -class OneHotIE; -#else class INFERENCE_ENGINE_API_CLASS(OneHotIE); -#endif } // namespace op } // namespace ngraph diff --git a/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.hpp b/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.hpp index aa973a29821..130910c4706 100644 --- a/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.hpp +++ b/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.hpp @@ -14,11 +14,7 @@ namespace ngraph { namespace pass { -#ifdef BUILD_AS_IE_SOURCES -class ConvertNMS5ToLegacyMatcher; -#else class INFERENCE_ENGINE_API_CLASS(ConvertNMS5ToLegacyMatcher); -#endif } // namespace pass } // namespace ngraph diff --git a/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_one_hot_to_one_hot_ie.hpp b/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_one_hot_to_one_hot_ie.hpp index 6621901c1d9..0983be6c814 100644 --- a/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_one_hot_to_one_hot_ie.hpp +++ b/inference-engine/src/legacy_api/include/legacy/transformations/convert_opset1_to_legacy/convert_one_hot_to_one_hot_ie.hpp @@ -15,11 +15,7 @@ namespace ngraph { namespace pass { -#ifdef BUILD_AS_IE_SOURCES -class ConvertOneHotToOneHotIEMatcher; -#else class INFERENCE_ENGINE_API_CLASS(ConvertOneHotToOneHotIEMatcher); -#endif } // namespace pass } // namespace ngraph diff --git a/inference-engine/src/multi_device/CMakeLists.txt b/inference-engine/src/multi_device/CMakeLists.txt index 3c6ffbf72e1..7e536a0bdfe 100644 --- a/inference-engine/src/multi_device/CMakeLists.txt +++ b/inference-engine/src/multi_device/CMakeLists.txt @@ -12,6 +12,7 @@ ie_add_plugin(NAME ${TARGET_NAME} SOURCES ${SOURCES} ${HEADERS} VERSION_DEFINES_FOR multi_device_plugin.cpp) +# TODO: add fix for this case since DEFAULT_CONFIG is not used now ie_add_plugin(NAME ${TARGET_NAME} DEVICE_NAME "AUTO" PSEUDO_PLUGIN diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp index 5f15cbb6bf7..b7f7419076f 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp @@ -322,22 +322,37 @@ protected: std::weak_ptr _core; //!< A pointer to ICore interface }; -#define IE_CREATE_PLUGIN CreatePluginEngine +/** + * @private + */ +using CreatePluginEngineFunc = void(std::shared_ptr&); +/** + * @def IE_CREATE_PLUGIN + * @brief Defines a name of a function creating plugin instance + * @ingroup ie_dev_api_plugin_api + */ +#ifndef IE_CREATE_PLUGIN +# define IE_CREATE_PLUGIN CreatePluginEngine +#endif + +/** + * @private + */ constexpr static const auto create_plugin_function = OV_PP_TOSTRING(IE_CREATE_PLUGIN); namespace details { template <> class SOCreatorTrait { public: - static constexpr auto name = OV_PP_TOSTRING(IE_CREATE_PLUGIN); + static constexpr auto name = create_plugin_function; }; } // namespace details } // namespace InferenceEngine /** * @def IE_DEFINE_PLUGIN_CREATE_FUNCTION(PluginType, version) - * @brief Defines the exported `CreatePluginEngine` function which is used to create a plugin instance + * @brief Defines the exported `IE_CREATE_PLUGIN` function which is used to create a plugin instance * @ingroup ie_dev_api_plugin_api */ #define IE_DEFINE_PLUGIN_CREATE_FUNCTION(PluginType, version, ...) \ @@ -355,3 +370,12 @@ public: } \ plugin->SetVersion(version); \ } + +/** + * @def IE_DEFINE_PLUGIN_CREATE_FUNCTION_DEFINITION(_IE_CREATE_PLUGIN_FUNC) + * @brief Declares the exported `CreatePluginEngine` function which is used to create a plugin instance + * @ingroup ie_dev_api_plugin_api + */ +#define IE_DEFINE_PLUGIN_CREATE_FUNCTION_DECLARATION(_IE_CREATE_PLUGIN_FUNC) \ + INFERENCE_PLUGIN_API(void) \ + _IE_CREATE_PLUGIN_FUNC(::std::shared_ptr<::InferenceEngine::IInferencePlugin>& plugin) noexcept(false); diff --git a/inference-engine/src/preprocessing/CMakeLists.txt b/inference-engine/src/preprocessing/CMakeLists.txt index 8d9864f9616..1d100fe1457 100644 --- a/inference-engine/src/preprocessing/CMakeLists.txt +++ b/inference-engine/src/preprocessing/CMakeLists.txt @@ -115,6 +115,12 @@ add_cpplint_target(${TARGET_NAME}_obj_cpplint FOR_TARGETS ${TARGET_NAME}_obj) # Create module library file from object library +if(BUILD_SHARED_LIBS) + set(library_type MODULE) +else() + set(library_type STATIC) +endif() + add_library(${TARGET_NAME} MODULE $) @@ -123,10 +129,15 @@ ie_add_vs_version_file(NAME ${TARGET_NAME} set_ie_threading_interface_for(${TARGET_NAME}) -target_link_libraries(${TARGET_NAME} PRIVATE fluid openvino::itt openvino::util - PUBLIC inference_engine) +target_link_libraries(${TARGET_NAME} PRIVATE fluid openvino::itt openvino::util) -target_include_directories(${TARGET_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") +if(BUILD_SHARED_LIBS) + # for static linkage the dependencies are in opposite order + target_link_libraries(${TARGET_NAME} PRIVATE inference_engine) +endif() + +target_include_directories(${TARGET_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" + $) # Workaround to avoid warnings caused with bug in the avx512intrin.h of GCC5 if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND diff --git a/inference-engine/src/readers/CMakeLists.txt b/inference-engine/src/readers/CMakeLists.txt index 83c7cbc629c..46028205d37 100644 --- a/inference-engine/src/readers/CMakeLists.txt +++ b/inference-engine/src/readers/CMakeLists.txt @@ -15,4 +15,6 @@ file(GLOB_RECURSE reader_api_hpp "${CMAKE_CURRENT_SOURCE_DIR}/reader_api/*.hpp") add_cpplint_target(${TARGET_NAME}_cpplint FOR_SOURCES ${reader_api_hpp}) -add_subdirectory(ir_reader_v7) +if(ENABLE_IR_V7_READER) + add_subdirectory(ir_reader_v7) +endif() diff --git a/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt b/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt index da35e298167..b465372432d 100644 --- a/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt +++ b/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt @@ -15,7 +15,13 @@ source_group("src" FILES ${LIBRARY_SRC}) # Create module library -add_library(${TARGET_NAME} MODULE ${LIBRARY_SRC}) +if(BUILD_SHARED_LIBS) + set(library_type MODULE) +else() + set(library_type STATIC) +endif() + +add_library(${TARGET_NAME} ${library_type} ${LIBRARY_SRC}) ie_faster_build(${TARGET_NAME} UNITY @@ -39,6 +45,10 @@ if(WIN32) set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}) endif() +if(NOT BUILD_SHARED_LIBS) + target_link_libraries(inference_engine PRIVATE ${TARGET_NAME}) +endif() + # code style add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}) diff --git a/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp b/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp index af4d407ad04..1e27c8b6fb7 100644 --- a/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp +++ b/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp @@ -42,6 +42,6 @@ CNNNetwork IRReader::read(std::istream& model, const Blob::CPtr& weights, const return CNNNetwork(parser.parse(root, weights)); } -OPENVINO_PLUGIN_API void InferenceEngine::CreateReader(std::shared_ptr& reader) { +INFERENCE_PLUGIN_API(void) InferenceEngine::CreateReader(std::shared_ptr& reader) { reader = std::make_shared(); } diff --git a/inference-engine/src/readers/reader_api/ie_reader.hpp b/inference-engine/src/readers/reader_api/ie_reader.hpp index 399afc10240..9b023e84824 100644 --- a/inference-engine/src/readers/reader_api/ie_reader.hpp +++ b/inference-engine/src/readers/reader_api/ie_reader.hpp @@ -4,7 +4,6 @@ #pragma once -#include "openvino/runtime/common.hpp" #include #include #include @@ -58,6 +57,6 @@ protected: * @brief Creates the default instance of the reader * @return Reader interface */ -OPENVINO_PLUGIN_API void CreateReader(std::shared_ptr& reader); +INFERENCE_PLUGIN_API(void) CreateReader(std::shared_ptr& reader); } // namespace InferenceEngine diff --git a/inference-engine/tests/functional/inference_engine/CMakeLists.txt b/inference-engine/tests/functional/inference_engine/CMakeLists.txt index df998f0fd45..81c06c3d373 100644 --- a/inference-engine/tests/functional/inference_engine/CMakeLists.txt +++ b/inference-engine/tests/functional/inference_engine/CMakeLists.txt @@ -25,16 +25,28 @@ set(LINK_LIBRARIES set(DEPENDENCIES mock_engine - ir_ngraph_frontend - inference_engine_ir_v7_reader - HeteroPlugin - MultiDevicePlugin template_extension lptNgraphFunctions sharedTestClasses test_model_zoo ) +if(NGRAPH_IR_FRONTEND_ENABLE) + list(APPEND DEPENDENCIES ir_ngraph_frontend) +endif() + +if(ENABLE_IR_V7_READER) + list(APPEND DEPENDENCIES inference_engine_ir_v7_reader) +endif() + +if(ENABLE_HETERO) + list(APPEND DEPENDENCIES HeteroPlugin) +endif() + +if(ENABLE_MULTI) + list(APPEND DEPENDENCIES MultiDevicePlugin) +endif() + if (NOT NGRAPH_ONNX_FRONTEND_ENABLE) list(APPEND EXCLUDED_SOURCE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/onnx_reader") endif() diff --git a/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt b/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt index 65a8fb72db5..5c85da26a88 100644 --- a/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt +++ b/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt @@ -19,8 +19,8 @@ addIeTargetTest( DEPENDENCIES myriadPlugin LINK_LIBRARIES - vpu_common_lib vpu_graph_transformer + vpu_common_lib funcSharedTests mvnc ADD_CPPLINT diff --git a/inference-engine/tests/functional/plugin/shared/CMakeLists.txt b/inference-engine/tests/functional/plugin/shared/CMakeLists.txt index 762ee9867ed..ef26009a2b2 100644 --- a/inference-engine/tests/functional/plugin/shared/CMakeLists.txt +++ b/inference-engine/tests/functional/plugin/shared/CMakeLists.txt @@ -6,7 +6,16 @@ set(TARGET_NAME funcSharedTests) set(PUBLIC_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") -set(DEPENDENCIES inference_engine mock_engine HeteroPlugin MultiDevicePlugin) +set(DEPENDENCIES mock_engine) + +if(ENABLE_HETERO) + list(APPEND DEPENDENCIES HeteroPlugin) +endif() + +if(ENABLE_MULTI) + list(APPEND DEPENDENCIES MultiDevicePlugin) +endif() + if (NGRAPH_ONNX_FRONTEND_ENABLE) list(APPEND DEPENDENCIES test_model_zoo) list(APPEND DEFINES TEST_MODELS="${TEST_MODEL_ZOO}/func_tests/models/") diff --git a/inference-engine/tests_deprecated/behavior/shared_tests/CMakeLists.txt b/inference-engine/tests_deprecated/behavior/shared_tests/CMakeLists.txt index 6b3a8083093..e48b2598155 100644 --- a/inference-engine/tests_deprecated/behavior/shared_tests/CMakeLists.txt +++ b/inference-engine/tests_deprecated/behavior/shared_tests/CMakeLists.txt @@ -8,7 +8,11 @@ file(GLOB_RECURSE SHARED_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) add_library(${TARGET_NAME} STATIC ${SHARED_TESTS_SRC}) -add_dependencies(${TARGET_NAME} MultiDevicePlugin inference_engine_preproc) +add_dependencies(${TARGET_NAME} inference_engine_preproc) + +if(ENABLE_MULTI) + add_dependencies(${TARGET_NAME} MultiDevicePlugin) +endif() target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/plugin_tests") diff --git a/inference-engine/tests_deprecated/functional/gna/CMakeLists.txt b/inference-engine/tests_deprecated/functional/gna/CMakeLists.txt index 857e65b8394..fcda3031422 100644 --- a/inference-engine/tests_deprecated/functional/gna/CMakeLists.txt +++ b/inference-engine/tests_deprecated/functional/gna/CMakeLists.txt @@ -13,9 +13,11 @@ file(GLOB TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instance/single_layer_tests/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/backward_compatibility/*.cpp) -list(APPEND DEPENDENCIES - HeteroPlugin - GNAPlugin) +list(APPEND DEPENDENCIES GNAPlugin) + +if(ENABLE_HETERO) + list(APPEND DEPENDENCIES HeteroPlugin) +endif() if(ENABLE_MKL_DNN) list(APPEND DEPENDENCIES diff --git a/inference-engine/tests_deprecated/functional/shared_tests/CMakeLists.txt b/inference-engine/tests_deprecated/functional/shared_tests/CMakeLists.txt index 91c93c34bb6..4584a6810c2 100644 --- a/inference-engine/tests_deprecated/functional/shared_tests/CMakeLists.txt +++ b/inference-engine/tests_deprecated/functional/shared_tests/CMakeLists.txt @@ -18,7 +18,12 @@ file(GLOB SHARED_TESTS_SRC ) add_library(${TARGET_NAME} STATIC ${SHARED_TESTS_SRC}) -add_dependencies(${TARGET_NAME} inference_engine_preproc MultiDevicePlugin mock_engine) + +add_dependencies(${TARGET_NAME} inference_engine_preproc mock_engine) + +if(ENABLE_MULTI) + add_dependencies(${TARGET_NAME} MultiDevicePlugin) +endif() set_ie_threading_interface_for(${TARGET_NAME}) @@ -51,7 +56,9 @@ endif() target_link_libraries(${TARGET_NAME} PUBLIC ${SHARED_LIBRARIES}) -add_dependencies(${TARGET_NAME} HeteroPlugin) +if(ENABLE_HETERO) + add_dependencies(${TARGET_NAME} HeteroPlugin) +endif() # developer package diff --git a/inference-engine/tests_deprecated/functional/vpu/CMakeLists.txt b/inference-engine/tests_deprecated/functional/vpu/CMakeLists.txt index 762d8f74b18..50f53518083 100644 --- a/inference-engine/tests_deprecated/functional/vpu/CMakeLists.txt +++ b/inference-engine/tests_deprecated/functional/vpu/CMakeLists.txt @@ -6,9 +6,10 @@ set(VPU_DEPENDENCIES vpu_copy_firmware) if (ENABLE_CLDNN) - list(APPEND VPU_DEPENDENCIES - clDNNPlugin - HeteroPlugin) + list(APPEND VPU_DEPENDENCIES clDNNPlugin) + if(ENABLE_HETERO) + list(APPEND VPU_DEPENDENCIES HeteroPlugin) + endif() endif() addIeTarget( diff --git a/ngraph/core/include/openvino/core/partial_shape.hpp b/ngraph/core/include/openvino/core/partial_shape.hpp index 4486215480b..8ad68c66de7 100644 --- a/ngraph/core/include/openvino/core/partial_shape.hpp +++ b/ngraph/core/include/openvino/core/partial_shape.hpp @@ -175,7 +175,7 @@ public: return m_dimensions; } friend OPENVINO_API std::ostream& operator<<(std::ostream& str, const PartialShape& shape); - friend PartialShape operator+(const PartialShape& s1, const PartialShape& s2); + friend OPENVINO_API PartialShape operator+(const PartialShape& s1, const PartialShape& s2); bool operator==(const PartialShape& partial_shape) const; bool operator!=(const PartialShape& partial_shape) const; /// Get the max bounding shape @@ -375,7 +375,7 @@ private: /// std::invalid_argument. /// \li If `s1` and `s2` both have static rank, and their ranks are equal, /// returns a new shape whose `i`th dimension is `s1[i] + s2[i]`. -PartialShape operator+(const PartialShape& s1, const PartialShape& s2); +OPENVINO_API PartialShape operator+(const PartialShape& s1, const PartialShape& s2); /// \brief Inserts a human-readable representation of a PartialShape into an output stream. /// \param str The output stream targeted for insertion. diff --git a/ngraph/test/opset.cpp b/ngraph/test/opset.cpp index d463e5d7092..90a106b1cbc 100644 --- a/ngraph/test/opset.cpp +++ b/ngraph/test/opset.cpp @@ -200,7 +200,11 @@ TEST(opset, custom_opset) { opset.insert(); #endif opset.insert(); +#ifdef OPENVINO_STATIC_LIBRARY + ASSERT_EQ(opset.get_types_info().size(), 1); +#else ASSERT_EQ(opset.get_types_info().size(), 3); +#endif ASSERT_TRUE(opset.contains_type("MyOpNew")); ASSERT_TRUE(opset.contains_type("MyOpOld")); ASSERT_TRUE(opset.contains_type("MyOpNewFromOld")); diff --git a/ngraph/test/runtime/interpreter/CMakeLists.txt b/ngraph/test/runtime/interpreter/CMakeLists.txt index 9977342702b..2b99d191106 100644 --- a/ngraph/test/runtime/interpreter/CMakeLists.txt +++ b/ngraph/test/runtime/interpreter/CMakeLists.txt @@ -21,7 +21,7 @@ if(COMMAND ie_add_vs_version_file) endif() target_compile_definitions(interpreter_backend PRIVATE INTERPRETER_BACKEND_EXPORTS) -target_link_libraries(interpreter_backend PUBLIC ngraph_backend) +target_link_libraries(interpreter_backend PUBLIC ngraph_backend PRIVATE ngraph_reference) install(TARGETS interpreter_backend RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT tests EXCLUDE_FROM_ALL