diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index e099ff08fa1..3384fd40c0d 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -25,8 +25,10 @@ jobs: matrix: Dynamic: CMAKE_BUILD_SHARED_LIBS: 'ON' + PYTHON_STATIC_ARGS: Static: CMAKE_BUILD_SHARED_LIBS: 'OFF' + PYTHON_STATIC_ARGS: -m "not dynamic_library and not template_plugin" maxParallel: 2 # About 150% of total time @@ -209,10 +211,9 @@ jobs: - script: | export DATA_PATH=$(MODELS_PATH) export MODELS_PATH=$(MODELS_PATH) - . $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyngraph --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_backend.py + . $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyngraph $(PYTHON_STATIC_ARGS) --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_backend.py displayName: 'nGraph Python Bindings Tests' continueOnError: false - condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON') - script: | export MO_ROOT=$(INSTALL_DIR)/tools/model_optimizer @@ -267,11 +268,11 @@ jobs: - script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/templateFuncTests --gtest_filter=*smoke* --gtest_output=xml:TEST-templateFuncTests.xml displayName: 'TEMPLATE FuncTests' continueOnError: false - condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON') - script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/cpuFuncTests --gtest_filter=*smoke* --gtest_print_time=1 --gtest_output=xml:TEST-cpuFuncTests.xml displayName: 'CPU FuncTests' continueOnError: false + condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF') - script: | export DATA_PATH=$(MODELS_PATH) @@ -284,10 +285,9 @@ jobs: export DATA_PATH=$(MODELS_PATH) export MODELS_PATH=$(MODELS_PATH) cd $(REPO_DIR)/inference-engine/ie_bridges/python/tests - . $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml + . $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml $(PYTHON_STATIC_ARGS) displayName: 'Python API Tests' continueOnError: false - condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON') - script: | . $(SETUPVARS) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef69fe8ed73..b0c6d805e6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,11 +87,7 @@ add_subdirectory(openvino) add_subdirectory(ngraph) add_subdirectory(inference-engine) add_subdirectory(runtime) - -# for Template plugin -openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend) include(cmake/extra_modules.cmake) - if(ENABLE_SAMPLES) add_subdirectory(samples) endif() diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index dd9ea346301..abba70313e0 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -175,8 +175,9 @@ macro(ie_register_plugins_dynamic) message(FATAL_ERROR "Please, define MAIN_TARGET") endif() + # Unregister .xml files for plugins from current build tree + set(plugins_to_remove ${IE_REGISTER_POSSIBLE_PLUGINS}) - set(plugin_files_local) set(config_output_file "$/plugins.xml") foreach(plugin IN LISTS plugins_to_remove) @@ -192,6 +193,9 @@ macro(ie_register_plugins_dynamic) VERBATIM) endforeach() + # Generate .xml files + + set(plugin_files_local) foreach(name IN LISTS PLUGIN_FILES) string(REPLACE ":" ";" name "${name}") list(LENGTH name length) @@ -219,6 +223,8 @@ macro(ie_register_plugins_dynamic) list(APPEND plugin_files_local "${config_file_name}") endforeach() + # Combine all .xml files into plugins.xml + add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD COMMAND "${CMAKE_COMMAND}" @@ -231,15 +237,19 @@ macro(ie_register_plugins_dynamic) VERBATIM) endmacro() +macro(ie_register_plugins) + if(BUILD_SHARED_LIBS) + ie_register_plugins_dynamic(${ARGN}) + endif() +endmacro() + # -# ie_register_plugins_static(MAIN_TARGET
-# POSSIBLE_PLUGINS ) +# ie_generate_plugins_hpp() # -macro(ie_register_plugins_static) - set(options) - set(oneValueArgs MAIN_TARGET) - set(multiValueArgs POSSIBLE_PLUGINS) - cmake_parse_arguments(IE_REGISTER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) +macro(ie_generate_plugins_hpp) + if(BUILD_SHARED_LIBS) + return() + endif() set(device_mapping) set(device_configs) @@ -271,10 +281,10 @@ macro(ie_register_plugins_static) # link plugin to inference_engine static version list(GET name 1 plugin_name) - target_link_libraries(${IE_REGISTER_MAIN_TARGET} PRIVATE ${plugin_name}) + target_link_libraries(inference_engine PRIVATE ${plugin_name}) endforeach() - set(ie_plugins_hpp "${CMAKE_CURRENT_BINARY_DIR}/ie_plugins.hpp") + set(ie_plugins_hpp "${CMAKE_BINARY_DIR}/inference-engine/src/inference_engine/ie_plugins.hpp") set(plugins_hpp_in "${IEDevScripts_DIR}/plugins/plugins.hpp.in") add_custom_command(OUTPUT "${ie_plugins_hpp}" @@ -293,30 +303,25 @@ macro(ie_register_plugins_static) "Generate ie_plugins.hpp for static build" VERBATIM) + # for some reason dependnency on source files does not work + # so, we have to use explicit target and make it dependency for inference_engine + add_custom_target(ie_generate_hpp DEPENDS ${ie_plugins_hpp}) + add_dependencies(inference_engine ie_generate_hpp) + # add dependency for object files - get_target_property(sources ${IE_REGISTER_MAIN_TARGET} SOURCES) + get_target_property(sources inference_engine 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}) + list(APPEND all_sources ${obj_sources}) else() # usual source - list(APPEND patched_sources ${source}) + list(APPEND all_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() + # add dependency on header file generation for all inference_engine source files + set_source_files_properties(${all_sources} PROPERTIES OBJECT_DEPENDS ${ie_plugins_hpp}) endmacro() diff --git a/cmake/extra_modules.cmake b/cmake/extra_modules.cmake index 8e2ba6b5cd3..d72497749ac 100644 --- a/cmake/extra_modules.cmake +++ b/cmake/extra_modules.cmake @@ -8,6 +8,7 @@ function(ie_generate_dev_package_config) set(all_dev_targets gflags ie_libraries) foreach(component IN LISTS openvino_export_components) + # export all targets with prefix and use them during extra modules build export(TARGETS ${${component}} NAMESPACE IE:: APPEND FILE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake") list(APPEND all_dev_targets ${${component}}) @@ -25,8 +26,6 @@ function(ie_generate_dev_package_config) @ONLY) endfunction() -ie_generate_dev_package_config() - # # Add extra modules # @@ -54,7 +53,7 @@ function(register_extra_modules) generate_fake_dev_package() - # automatically import plugins from the 'plugins' folder + # automatically import plugins from the 'runtime/plugins' folder file(GLOB local_extra_modules "runtime/plugins/*") # add template plugin if(ENABLE_TEMPLATE) @@ -90,4 +89,24 @@ function(register_extra_modules) endforeach() endfunction() +# +# Extra modules support +# + +# for Template plugin +openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend) + +# this InferenceEngineDeveloperPackageConfig.cmake is not used +# during extra modules build since it's generated after modules +# are configured +ie_generate_dev_package_config() + +# extra modules must be registered after inference_engine library +# and all other IE common libraries (ie_libraries) are creared +# because 'register_extra_modules' creates fake InferenceEngineDeveloperPackageConfig.cmake +# with all imported developer targets register_extra_modules() + +# for static libraries case we need to generate final ie_plugins.hpp +# with all the information about plugins +ie_generate_plugins_hpp() diff --git a/docs/template_plugin/src/template_executable_network.cpp b/docs/template_plugin/src/template_executable_network.cpp index 8479a027550..cff492f5c4a 100644 --- a/docs/template_plugin/src/template_executable_network.cpp +++ b/docs/template_plugin/src/template_executable_network.cpp @@ -218,7 +218,9 @@ void TemplatePlugin::ExecutableNetwork::Export(std::ostream& modelStream) { // Note: custom ngraph extensions are not supported std::map custom_opsets; std::stringstream xmlFile, binFile; + OPENVINO_SUPPRESS_DEPRECATED_START ov::pass::Serialize serializer(xmlFile, binFile, custom_opsets); + OPENVINO_SUPPRESS_DEPRECATED_END serializer.run_on_function(_function); auto m_constants = binFile.str(); diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt index 304098403a6..942907895b4 100644 --- a/inference-engine/CMakeLists.txt +++ b/inference-engine/CMakeLists.txt @@ -63,4 +63,3 @@ elseif(WIN32) PATTERN speech_libs_and_demos EXCLUDE PATTERN .clang-format EXCLUDE) endif() - diff --git a/inference-engine/ie_bridges/python/tests/conftest.py b/inference-engine/ie_bridges/python/tests/conftest.py index 9d429a1d9c2..2be7c5e1783 100644 --- a/inference-engine/ie_bridges/python/tests/conftest.py +++ b/inference-engine/ie_bridges/python/tests/conftest.py @@ -45,9 +45,8 @@ def device(): def pytest_configure(config): # register an additional markers - config.addinivalue_line( - "markers", "template_plugin" - ) + config.addinivalue_line("markers", "template_plugin: Skip test on Template plugin") + config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case") def create_encoder(input_shape, levels = 4): diff --git a/inference-engine/ie_bridges/python/tests/test_IECore.py b/inference-engine/ie_bridges/python/tests/test_IECore.py index 6e57f0958e3..f7b67e20feb 100644 --- a/inference-engine/ie_bridges/python/tests/test_IECore.py +++ b/inference-engine/ie_bridges/python/tests/test_IECore.py @@ -75,6 +75,7 @@ def test_query_network(device): assert next(iter(set(query_res.values()))) == device, "Wrong device for some layers" +@pytest.mark.dynamic_library @pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", reason="Device dependent test") def test_register_plugin(): ie = IECore() @@ -86,6 +87,7 @@ def test_register_plugin(): assert isinstance(exec_net, ExecutableNetwork), "Cannot load the network to the registered plugin with name 'BLA'" +@pytest.mark.dynamic_library @pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", reason="Device dependent test") def test_register_plugins(): ie = IECore() diff --git a/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp b/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp index 6fcb0efc552..7c4e595b945 100644 --- a/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp @@ -104,9 +104,11 @@ protected: inline InferenceEngine::Core createIECoreWithTemplate() { PluginCache::get().reset(); InferenceEngine::Core ie; +#ifndef OPENVINO_STATIC_LIBRARY std::string pluginName = "templatePlugin"; pluginName += IE_BUILD_POSTFIX; - ie.RegisterPlugin(pluginName, "TEMPLATE"); + ie.RegisterPlugin(pluginName, CommonTestUtils::DEVICE_TEMPLATE); +#endif // !OPENVINO_STATIC_LIBRARY return ie; } diff --git a/inference-engine/tests/functional/plugin/shared/include/base/ov_behavior_test_utils.hpp b/inference-engine/tests/functional/plugin/shared/include/base/ov_behavior_test_utils.hpp index 8cce834dc2b..e5d693e13d5 100644 --- a/inference-engine/tests/functional/plugin/shared/include/base/ov_behavior_test_utils.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/base/ov_behavior_test_utils.hpp @@ -69,9 +69,11 @@ protected: inline ov::runtime::Core createCoreWithTemplate() { ov::test::utils::PluginCache::get().reset(); ov::runtime::Core core; +#ifndef OPENVINO_STATIC_LIBRARY std::string pluginName = "templatePlugin"; pluginName += IE_BUILD_POSTFIX; core.register_plugin(pluginName, CommonTestUtils::DEVICE_TEMPLATE); +#endif // !OPENVINO_STATIC_LIBRARY return core; } diff --git a/ngraph/frontend/frontend_manager/CMakeLists.txt b/ngraph/frontend/frontend_manager/CMakeLists.txt index ada2b275ea1..ab1093805dc 100644 --- a/ngraph/frontend/frontend_manager/CMakeLists.txt +++ b/ngraph/frontend/frontend_manager/CMakeLists.txt @@ -35,7 +35,7 @@ ov_install_static_lib(${TARGET_NAME}_static ngraph) # Shared library - need to recompile object files to export necessary symbols -add_library(${TARGET_NAME} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) +add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) add_library(ngraph::${TARGET_NAME} ALIAS ${TARGET_NAME}) add_library(openvino::frontend::manager ALIAS ${TARGET_NAME}) diff --git a/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_manager_defs.hpp b/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_manager_defs.hpp index 708fa83f525..c7d81bd8b01 100644 --- a/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_manager_defs.hpp +++ b/ngraph/frontend/frontend_manager/include/frontend_manager/frontend_manager_defs.hpp @@ -9,7 +9,7 @@ // Increment each time when FrontEnd/InputModel/Place interface is changed #define OV_FRONTEND_API_VERSION 1 -#if defined(USE_STATIC_FRONTEND_MANAGER) || defined(OPENVINO_STATIC_LIBRARY) +#if defined(USE_STATIC_FRONTEND_MANAGER) // || defined(OPENVINO_STATIC_LIBRARY) # define FRONTEND_API #else // Defined if cmake is building the frontend_manager DLL (instead of using it) diff --git a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp index cb7fdf481b0..8869a0c387b 100644 --- a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp +++ b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp @@ -48,12 +48,12 @@ static void get_paddings(const NodeContext& node, // TODO: need to support NHWC input #55483 switch (paddings.size()) { case 2: - pad_begin = Shape{static_cast(paddings[0]), static_cast(paddings[1])}; + pad_begin = Shape{static_cast(paddings[0]), static_cast(paddings[1])}; pad_end = pad_begin; break; case 4: - pad_begin = Shape{static_cast(paddings[0]), static_cast(paddings[2])}; - pad_end = Shape{static_cast(paddings[1]), static_cast(paddings[3])}; + pad_begin = Shape{static_cast(paddings[0]), static_cast(paddings[2])}; + pad_end = Shape{static_cast(paddings[1]), static_cast(paddings[3])}; break; default: throw std::runtime_error("Unsupported pooling paddings " + std::to_string(paddings.size())); @@ -131,7 +131,7 @@ NamedOutputs pool2d(const NodeContext& node) { auto strides = node.get_attribute>("strides"); auto paddings = node.get_attribute>("paddings"); - uint64_t kernel_h, kernel_w; + size_t kernel_h, kernel_w; if (kernel_shape.size() == 1) { // Not tested: implemented according to spec, but can't generate real // model to test diff --git a/runtime/bindings/python/tests/conftest.py b/runtime/bindings/python/tests/conftest.py index 865ae43552e..f7963486cf5 100644 --- a/runtime/bindings/python/tests/conftest.py +++ b/runtime/bindings/python/tests/conftest.py @@ -78,6 +78,7 @@ def pytest_configure(config): config.addinivalue_line("markers", "skip_on_hetero: Skip test on HETERO") config.addinivalue_line("markers", "skip_on_template: Skip test on TEMPLATE") config.addinivalue_line("markers", "onnx_coverage: Collect ONNX operator coverage") + config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case") def pytest_collection_modifyitems(config, items): diff --git a/runtime/bindings/python/tests/test_inference_engine/test_core.py b/runtime/bindings/python/tests/test_inference_engine/test_core.py index 59ed993278c..febb7226d88 100644 --- a/runtime/bindings/python/tests/test_inference_engine/test_core.py +++ b/runtime/bindings/python/tests/test_inference_engine/test_core.py @@ -242,6 +242,7 @@ def test_query_network(device): assert next(iter(set(query_res.values()))) == device, "Wrong device for some layers" +@pytest.mark.dynamic_library @pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", reason="Device independent test") def test_register_plugin(): ie = Core() @@ -252,6 +253,7 @@ def test_register_plugin(): "Cannot load the network to the registered plugin with name 'BLA'" +@pytest.mark.dynamic_library @pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", reason="Device independent test") def test_register_plugins(): ie = Core()