From a721c9f5ab27733440c677a4718775ef4290a8c9 Mon Sep 17 00:00:00 2001 From: Anastasiia Pnevskaia Date: Wed, 9 Aug 2023 09:36:47 +0200 Subject: [PATCH 01/51] Corrected category in OVC events. (#19064) --- tools/ovc/openvino/tools/ovc/convert_impl.py | 8 ++++---- tools/ovc/openvino/tools/ovc/telemetry_utils.py | 8 ++++---- tools/ovc/openvino/tools/ovc/utils.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/ovc/openvino/tools/ovc/convert_impl.py b/tools/ovc/openvino/tools/ovc/convert_impl.py index 68228093654801..7fd0e683f638a8 100644 --- a/tools/ovc/openvino/tools/ovc/convert_impl.py +++ b/tools/ovc/openvino/tools/ovc/convert_impl.py @@ -140,8 +140,8 @@ def prepare_ir(argv: argparse.Namespace): argv.placeholder_data_types, getattr(argv, "example_input", None), argv.share_weights) - t.send_event("mo", "conversion_method", moc_front_end.get_name() + "_frontend") - moc_front_end.add_extension(TelemetryExtension("mo", t.send_event, t.send_error, t.send_stack_trace)) + t.send_event("ovc", "conversion_method", moc_front_end.get_name() + "_frontend") + moc_front_end.add_extension(TelemetryExtension("ovc", t.send_event, t.send_error, t.send_stack_trace)) if new_extensions_used(argv): for extension in argv.extension: moc_front_end.add_extension(extension) @@ -407,8 +407,8 @@ def _convert(cli_parser: argparse.ArgumentParser, args, python_api_used): return None, None simplified_ie_version = VersionChecker().get_ie_simplified_version() telemetry = init_mo_telemetry() - telemetry.start_session('mo') - telemetry.send_event('mo', 'version', simplified_ie_version) + telemetry.start_session('ovc') + telemetry.send_event('ovc', 'version', simplified_ie_version) # Initialize logger with 'ERROR' as default level to be able to form nice messages # before arg parser deliver log_level requested by user init_logger('ERROR', False) diff --git a/tools/ovc/openvino/tools/ovc/telemetry_utils.py b/tools/ovc/openvino/tools/ovc/telemetry_utils.py index c0f1c7b8ec37a3..87e0132ccd17a6 100644 --- a/tools/ovc/openvino/tools/ovc/telemetry_utils.py +++ b/tools/ovc/openvino/tools/ovc/telemetry_utils.py @@ -25,7 +25,7 @@ def send_framework_info(framework: str): :param framework: framework name. """ t = tm.Telemetry() - t.send_event('mo', 'framework', framework) + t.send_event('ovc', 'framework', framework) def get_tid(): @@ -37,8 +37,8 @@ def get_tid(): def send_conversion_result(conversion_result: str, need_shutdown=False): t = tm.Telemetry() - t.send_event('mo', 'conversion_result', conversion_result) - t.end_session('mo') + t.send_event('ovc', 'conversion_result', conversion_result) + t.end_session('ovc') if need_shutdown: t.force_shutdown(1.0) @@ -71,4 +71,4 @@ def send_params_info(argv: argparse.Namespace, cli_parser: argparse.ArgumentPars else: param_str = arg + ":" + arg_to_str(arg_value) - t.send_event('mo', 'cli_parameters', param_str) + t.send_event('ovc', 'cli_parameters', param_str) diff --git a/tools/ovc/openvino/tools/ovc/utils.py b/tools/ovc/openvino/tools/ovc/utils.py index 29d4deaf3ef983..0f9915d3960e63 100644 --- a/tools/ovc/openvino/tools/ovc/utils.py +++ b/tools/ovc/openvino/tools/ovc/utils.py @@ -21,7 +21,7 @@ def refer_to_faq_msg(question_num: int): try: t = tm.Telemetry() - t.send_event('mo', 'error_info', "faq:" + str(question_num)) + t.send_event('ovc', 'error_info', "faq:" + str(question_num)) except Exception: # Telemetry can be not initialized if it is used in MO IR Reader pass From 7d89c93ded7d68b6da5a57ecebfe4198b40e47ba Mon Sep 17 00:00:00 2001 From: Roman Lyamin Date: Wed, 9 Aug 2023 12:03:48 +0400 Subject: [PATCH 02/51] [GPU] Added gi_yxs_os_yxsv2_osv16 format to to_weights_layout map (#19074) --- .../intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp index b2ab89d3b11ae4..ca60e4a16a369a 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp @@ -572,6 +572,8 @@ kernel_selector::weights_layout to_weights_layout(format f, bool is_grouped) { return kernel_selector::weights_layout::gs_oizyx_gsv32; case format::gyxio: return kernel_selector::weights_layout::gyxio; + case format::gi_yxs_os_yxsv2_osv16: + return kernel_selector::weights_layout::gi_yxs_os_yxsv2_osv16; case format::g_is_os_zyx_isv16_osv16: return kernel_selector::weights_layout::g_is_os_zyx_isv16_osv16; case format::g_is_os_yx_isv16_osv16: From 2d5a4e20ec7a791cce832039d3c4c99bf639af74 Mon Sep 17 00:00:00 2001 From: Roman Lyamin Date: Wed, 9 Aug 2023 12:47:06 +0400 Subject: [PATCH 03/51] [GPU] Fix premature termination of async compilation task in tests (#19035) --- .../src/graph/compilation_context.cpp | 19 +++++++++++++++++-- .../graph_optimizer/post_optimize_weights.cpp | 2 +- .../src/graph/include/compilation_context.hpp | 1 + .../intel_gpu/src/graph/primitive_inst.cpp | 7 ++++--- .../kernel_impl_params_relevance_test.cpp | 6 +++--- .../test_cases/fully_connected_gpu_test.cpp | 4 ++-- .../tests/unit/test_cases/gemm_gpu_test.cpp | 4 ++-- 7 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/compilation_context.cpp b/src/plugins/intel_gpu/src/graph/compilation_context.cpp index 89291bfaa01cbf..76bc86f48994f4 100644 --- a/src/plugins/intel_gpu/src/graph/compilation_context.cpp +++ b/src/plugins/intel_gpu/src/graph/compilation_context.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "intel_gpu/runtime/utils.hpp" namespace cldnn { @@ -20,11 +21,18 @@ class CompilationContext : public ICompilationContext { if (_stop_compilation) return; + auto promise = std::make_shared>(); + futures.emplace_back(promise->get_future()); + std::lock_guard lock(_mutex); if (_task_keys.find(key) == _task_keys.end()) { _task_keys.insert(key); - if (_task_executor != nullptr) - _task_executor->run(task); + if (_task_executor != nullptr) { + _task_executor->run([task, promise] { + task(); + promise->set_value(); + }); + } } } @@ -60,12 +68,19 @@ class CompilationContext : public ICompilationContext { } } + void wait_all() override { + for (auto&& future : futures) { + future.wait(); + } + } + private: ov::threading::IStreamsExecutor::Config _task_executor_config; std::shared_ptr _task_executor; std::mutex _mutex; std::unordered_set _task_keys; std::atomic_bool _stop_compilation{false}; + std::vector> futures; }; std::unique_ptr ICompilationContext::create(ov::threading::IStreamsExecutor::Config task_executor_config) { diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp index 3790b299a25cdb..5aade76ae00035 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp @@ -44,7 +44,7 @@ void post_optimize_weights::optimize_weights(T& node, program& p) { } // TODO: To relax current limitation w.r.t the future optimization of weight reorder process // In dynamic shape, selected weight format can change in runtime. However reordering blocked format to blocked format is not fully verified yet. - // So we need to enable other primiives such as convolution with verifying reorder b/w the possible layouts + // So we need to enable other primitives such as convolution with verifying reorder b/w the possible layouts // Also we skip weight reorder for onednn impl because onednn fully connected layer is using simple format, therefore // reordering to cldnn shape_agnostic_kernel's preferred blocked format at build time does not helpful for the performance. // This situation might be changed once onednn shape agnostic kernel is used in the future. diff --git a/src/plugins/intel_gpu/src/graph/include/compilation_context.hpp b/src/plugins/intel_gpu/src/graph/include/compilation_context.hpp index e5c157cabdef8c..be8d65c6aa5ecc 100644 --- a/src/plugins/intel_gpu/src/graph/include/compilation_context.hpp +++ b/src/plugins/intel_gpu/src/graph/include/compilation_context.hpp @@ -19,6 +19,7 @@ class ICompilationContext { virtual ~ICompilationContext() = default; virtual bool is_stopped() = 0; virtual void cancel() = 0; + virtual void wait_all() = 0; static std::unique_ptr create(ov::threading::IStreamsExecutor::Config task_executor_config); }; diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp index bbbb4fb41a4bda..730a62d53beaa1 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -588,7 +588,8 @@ bool primitive_inst::update_impl() { o.data_padding.set_dynamic_pad(tensor(0)); } - auto& cache = get_network().get_program()->get_implementations_cache(); + const auto& prog = get_network().get_program(); + auto& cache = prog->get_implementations_cache(); std::shared_ptr cached_impl = nullptr; { cached_impl = cache.get(updated_params_no_dyn_pad); @@ -604,7 +605,7 @@ bool primitive_inst::update_impl() { if (!cached_impl) { if (_dynamic_impl) { if (use_async_compilation()) { - auto& compilation_context = get_network().get_program()->get_compilation_context(); + auto& compilation_context = prog->get_compilation_context(); compilation_context.push_task(updated_params_no_dyn_pad, [this, &compilation_context, updated_params_no_dyn_pad]() { if (compilation_context.is_stopped()) return; @@ -637,7 +638,7 @@ bool primitive_inst::update_impl() { _impl = _node->type()->choose_impl(*_node, updated_params_no_dyn_pad); _impl->set_node_params(*_node); if (!can_be_optimized()) { - auto& kernels_cache = get_network().get_program()->get_kernels_cache(); + auto& kernels_cache = prog->get_kernels_cache(); auto kernels = kernels_cache.compile(updated_params_no_dyn_pad, _impl->get_kernels_source()); _impl->set_kernels(std::move(kernels)); cache.add(updated_params_no_dyn_pad, _impl->clone()); diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/kernel_impl_params_relevance_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/kernel_impl_params_relevance_test.cpp index abfbabce9c9736..34cc90d791a756 100644 --- a/src/plugins/intel_gpu/tests/unit/module_tests/kernel_impl_params_relevance_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/module_tests/kernel_impl_params_relevance_test.cpp @@ -44,7 +44,7 @@ TEST(kernel_impl_params_relevance, weights_layout) { network.set_input_data("input", actual_input_data); // 2. Force reference `fully_connected_gpu_bfyx_ref` kernel impl before execution, - // so during _node->type()->choose_impl(*_node, updated_params); call for static kernel vesrion reference + // so during _node->type()->choose_impl(*_node, updated_params); call for static kernel version reference // impl will be used. Call execute() to trigger desired kernel compilation auto fc_ref_impl = ov::intel_gpu::ImplementationDesc(format::bfyx, "fully_connected_gpu_bfyx_ref", impl_types::ocl); auto force_impl_prop = ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"fc", fc_ref_impl} }); @@ -52,8 +52,8 @@ TEST(kernel_impl_params_relevance, weights_layout) { network.execute(); - // 3. WA: Call cancel() to wait for all queued kernels compilation finish (including above `fully_connected_gpu_bfyx_ref`) - network.get_program()->get_compilation_context().cancel(); + // 3. WA: Call wait_all() to wait for all queued kernels compilation finish (including above `fully_connected_gpu_bfyx_ref`) + network.get_program()->get_compilation_context().wait_all(); // 4. Call execute() second time with same input shape to use pre-compiled `fully_connected_gpu_bfyx_ref` kernel network.execute(); diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp index d96182b974bb74..afbc1e30c2f3fe 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp @@ -1738,8 +1738,8 @@ TEST(fully_connected_onednn, impl_replacement_with_cldnn) { ASSERT_EQ(-2.25f, output_ptr[2]); ASSERT_EQ(3.0f, output_ptr[3]); - // WA: Call cancel() to wait for all queued kernels compilation finish - network.get_program()->get_compilation_context().cancel(); + // WA: Call wait_all() to wait for all queued kernels compilation finish + network.get_program()->get_compilation_context().wait_all(); // Check if OneDNN's impl is used for the next execute() call network.execute(); diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp index e82e076a2e6d5c..6b5b76ffd7fecc 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp @@ -1559,8 +1559,8 @@ TEST(gemm_onednn, impl_replacement_with_cldnn) { ASSERT_FLOAT_EQ(output_ptr[i], out_data[i]); } - // WA: Call cancel() to wait for all queued kernels compilation finish - network.get_program()->get_compilation_context().cancel(); + // WA: Call wait_all() to wait for all queued kernels compilation finish + network.get_program()->get_compilation_context().wait_all(); // Check if OneDNN's impl is used for the next execute() call network.execute(); From 19b3f062afebfe840b5c70fba50c27f983f22dd8 Mon Sep 17 00:00:00 2001 From: Aleksandr Voron Date: Wed, 9 Aug 2023 11:28:44 +0200 Subject: [PATCH 04/51] [CPU] Replace memory_order_relaxed with release/acquire in UpdateNodesBase class (#19028) --- src/plugins/intel_cpu/src/graph.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp index de4100517fbb53..6d523ef8347721 100644 --- a/src/plugins/intel_cpu/src/graph.cpp +++ b/src/plugins/intel_cpu/src/graph.cpp @@ -1163,15 +1163,15 @@ class UpdateNodesBase : public IUpdateNodes { m_completion.store(true, std::memory_order::memory_order_relaxed); throw; } - m_prepareCounter.store(stop_indx, std::memory_order::memory_order_release); - m_completion.store(true, std::memory_order::memory_order_relaxed); + m_prepareCounter.store(stop_indx, std::memory_order::memory_order_relaxed); + m_completion.store(true, std::memory_order::memory_order_release); } void updateDynParams(size_t node_indx, size_t /*unused*/) { size_t local_counter = node_indx; while (true) { - bool completion = m_completion.load(std::memory_order::memory_order_relaxed); - size_t prepareCounter = m_prepareCounter.load(std::memory_order::memory_order_acquire); + const bool completion = m_completion.load(std::memory_order::memory_order_acquire); + const size_t prepareCounter = m_prepareCounter.load(std::memory_order::memory_order_relaxed); if (completion && local_counter == prepareCounter) { break; } From 81645aaeda5151d7fecf58a901111c995db6fa1b Mon Sep 17 00:00:00 2001 From: Nadezhda Ageeva Date: Wed, 9 Aug 2023 17:22:20 +0400 Subject: [PATCH 05/51] [HETERO] Avoid unexpected dynamism (#18862) * [HETERO] Add ConstantFolding in compile modelto avoid unexpected dynamism after model split. Add new property, which shows number of subgraphs * Remove check for dynamic subgraph --- src/plugins/hetero/src/compiled_model.cpp | 16 +++- src/plugins/hetero/src/properties.hpp | 5 ++ .../tests/functional/compile_model_tests.cpp | 14 ++++ .../hetero/tests/functional/hetero_tests.cpp | 76 +++++++++++++++---- .../hetero/tests/functional/hetero_tests.hpp | 9 ++- .../tests/functional/query_model_tests.cpp | 37 ++++++++- 6 files changed, 135 insertions(+), 22 deletions(-) diff --git a/src/plugins/hetero/src/compiled_model.cpp b/src/plugins/hetero/src/compiled_model.cpp index 46e2419fd44b7a..7b8bf399286a8b 100644 --- a/src/plugins/hetero/src/compiled_model.cpp +++ b/src/plugins/hetero/src/compiled_model.cpp @@ -11,10 +11,13 @@ #include "ie_plugin_config.hpp" #include "itt.hpp" #include "openvino/op/util/op_types.hpp" +#include "openvino/pass/constant_folding.hpp" +#include "openvino/pass/manager.hpp" #include "openvino/runtime/internal_properties.hpp" #include "openvino/runtime/properties.hpp" #include "openvino/util/common_util.hpp" #include "plugin.hpp" +#include "properties.hpp" #include "xml_parse_utils.h" template @@ -55,6 +58,14 @@ ov::hetero::CompiledModel::CompiledModel(const std::shared_ptr& model if (std::getenv("OPENVINO_HETERO_VISUALIZE")) dumpDotFile = true; + // Calling of ConstantFolding in HETERO plugin is required because + // in some cases topology split is happening after constant subgraph. + // It may cause replacement of Constant by Parameter in such operations + // like Reshape/Transpose/Gather and lead to unexpected dynamism or exception + ov::pass::Manager manager; + manager.register_pass(); + manager.run_passes(model); + ov::SupportedOpsMap queryNetworkResult; auto orderedOps = model->get_ordered_ops(); @@ -664,7 +675,8 @@ ov::Any ov::hetero::CompiledModel::get_property(const std::string& name) const { std::vector ro_properties{ov::model_name, ov::optimal_number_of_infer_requests, ov::execution_devices, - ov::loaded_from_cache}; + ov::loaded_from_cache, + ov::hetero::number_of_submodels}; return ro_properties; }; const auto& to_string_vector = [](const std::vector& properties) { @@ -723,6 +735,8 @@ ov::Any ov::hetero::CompiledModel::get_property(const std::string& name) const { device_names.push_back(comp_model_desc.device); } return decltype(ov::execution_devices)::value_type{device_names}; + } else if (ov::hetero::number_of_submodels == name) { + return decltype(ov::hetero::number_of_submodels)::value_type{m_compiled_submodels.size()}; } return m_cfg.get(name); OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/plugins/hetero/src/properties.hpp b/src/plugins/hetero/src/properties.hpp index 799d07dbe7be1a..8ecd488bff98ca 100644 --- a/src/plugins/hetero/src/properties.hpp +++ b/src/plugins/hetero/src/properties.hpp @@ -13,5 +13,10 @@ namespace hetero { */ static constexpr Property caching_device_properties{"CACHING_DEVICE_PROPERTIES"}; +/** + * @brief Read-only property showing number of compiled submodels + */ +static constexpr Property number_of_submodels{"HETERO_NUMBER_OF_SUBMODELS"}; + } // namespace hetero } // namespace ov diff --git a/src/plugins/hetero/tests/functional/compile_model_tests.cpp b/src/plugins/hetero/tests/functional/compile_model_tests.cpp index 9fb2745f5944ff..bfcd0ca1c8bb90 100644 --- a/src/plugins/hetero/tests/functional/compile_model_tests.cpp +++ b/src/plugins/hetero/tests/functional/compile_model_tests.cpp @@ -42,6 +42,20 @@ TEST_F(HeteroTests, compile_without_device_priorities_throw) { EXPECT_THROW(core.compile_model(model, "HETERO"), ov::Exception); } +TEST_F(HeteroTests, compile_dynamic_model_fail) { + // Change device priority + core.set_property("HETERO", ov::device::priorities("MOCK0,MOCK1")); + auto model = create_model_with_subtract_reshape(true); + EXPECT_THROW(core.compile_model(model, "HETERO"), ov::Exception); +} + +TEST_F(HeteroTests, compile_model_shapeof) { + // Change device priority + core.set_property("HETERO", ov::device::priorities("MOCK0,MOCK1")); + auto model = create_model_with_subtract_shapeof_reshape(); + EXPECT_NO_THROW(core.compile_model(model, "HETERO")); +} + TEST_F(HeteroTests, compile_with_device_properties) { ov::AnyMap config = {ov::device::priorities("MOCK0,MOCK1"), ov::device::properties("MOCK0", ov::num_streams(4), ov::enable_profiling(false)), diff --git a/src/plugins/hetero/tests/functional/hetero_tests.cpp b/src/plugins/hetero/tests/functional/hetero_tests.cpp index f8d1f5ea91c814..4228a5c14ce8e6 100644 --- a/src/plugins/hetero/tests/functional/hetero_tests.cpp +++ b/src/plugins/hetero/tests/functional/hetero_tests.cpp @@ -12,6 +12,8 @@ #include "openvino/core/any.hpp" #include "openvino/core/except.hpp" #include "openvino/opsets/opset11.hpp" +#include "openvino/pass/constant_folding.hpp" +#include "openvino/pass/manager.hpp" #include "openvino/pass/serialize.hpp" #include "openvino/runtime/exec_model_info.hpp" #include "openvino/runtime/internal_properties.hpp" @@ -22,6 +24,7 @@ #include "openvino/runtime/properties.hpp" #include "openvino/util/file_util.hpp" #include "openvino/util/shared_object.hpp" +#include "transformations/init_node_info.hpp" #include "transformations/rt_info/fused_names_attribute.hpp" namespace { @@ -67,8 +70,9 @@ ov::Tensor ov::hetero::tests::HeteroTests::create_and_fill_tensor(const ov::elem OPENVINO_THROW("Cannot generate tensor. Unsupported element type."); } -std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract() { - auto param = std::make_shared(ov::element::i64, ov::Shape{1, 3, 2, 2}); +std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract(bool dynamic) { + int64_t bs = dynamic ? -1 : 1; + auto param = std::make_shared(ov::element::i64, ov::PartialShape{bs, 3, 2, 2}); param->set_friendly_name("input"); auto const_value = ov::opset11::Constant::create(ov::element::i64, ov::Shape{1, 1, 1, 1}, {1}); const_value->set_friendly_name("const_val"); @@ -81,8 +85,9 @@ std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_sub return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); } -std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract_reshape() { - auto param = std::make_shared(ov::element::i64, ov::Shape{1, 3, 2, 2}); +std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract_reshape(bool dynamic) { + int64_t bs = dynamic ? -1 : 1; + auto param = std::make_shared(ov::element::i64, ov::PartialShape{bs, 3, 2, 2}); param->set_friendly_name("input"); auto const_value = ov::opset11::Constant::create(ov::element::i64, ov::Shape{1, 1, 1, 1}, {1}); const_value->set_friendly_name("const_val"); @@ -99,8 +104,9 @@ std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_sub return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); } -std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract_reshape_relu() { - auto param = std::make_shared(ov::element::i64, ov::Shape{1, 3, 2, 2}); +std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract_reshape_relu(bool dynamic) { + int64_t bs = dynamic ? -1 : 1; + auto param = std::make_shared(ov::element::i64, ov::PartialShape{bs, 3, 2, 2}); param->set_friendly_name("input"); auto const_value = ov::opset11::Constant::create(ov::element::i64, ov::Shape{1, 1, 1, 1}, {1}); const_value->set_friendly_name("const_val"); @@ -119,8 +125,9 @@ std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_sub return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); } -std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_reshape() { - auto param = std::make_shared(ov::element::i64, ov::Shape{1, 3, 2, 2}); +std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_reshape(bool dynamic) { + int64_t bs = dynamic ? -1 : 1; + auto param = std::make_shared(ov::element::i64, ov::PartialShape{bs, 3, 2, 2}); param->set_friendly_name("input"); auto const_value = ov::opset11::Constant::create(ov::element::i64, ov::Shape{1, 1, 1, 1}, {1}); const_value->set_friendly_name("const_val"); @@ -135,6 +142,27 @@ std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_res return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); } +std::shared_ptr ov::hetero::tests::HeteroTests::create_model_with_subtract_shapeof_reshape(bool dynamic) { + int64_t bs = dynamic ? -1 : 1; + auto param = std::make_shared(ov::element::i64, ov::PartialShape{bs, 3, 2, 2}); + param->set_friendly_name("input"); + auto reshape_val0 = ov::opset11::Constant::create(ov::element::i64, ov::Shape{2}, {bs, 12}); + reshape_val0->set_friendly_name("reshape_val0"); + auto reshape0 = std::make_shared(param, reshape_val0, true); + reshape0->set_friendly_name("reshape0"); + auto const_value = ov::opset11::Constant::create(ov::element::i64, ov::Shape{1, 1}, {1}); + const_value->set_friendly_name("const_val"); + auto subtract = std::make_shared(reshape0, const_value); + subtract->set_friendly_name("sub"); + auto shape_of = std::make_shared(param); + shape_of->set_friendly_name("shape_of"); + auto reshape1 = std::make_shared(subtract, shape_of, true); + reshape1->set_friendly_name("reshape1"); + auto result = std::make_shared(reshape1); + result->set_friendly_name("res"); + return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); +} + // Mock plugins class MockCompiledModel : public ov::ICompiledModel { @@ -386,8 +414,11 @@ class MockCustomRemoteContext : public ov::IRemoteContext { class MockPluginBase : public ov::IPlugin { public: - MockPluginBase(const std::string& name, const std::unordered_set& supported_ops) - : m_supported_ops(supported_ops) { + MockPluginBase(const std::string& name, + const std::unordered_set& supported_ops, + bool dynamism_supported = false) + : m_supported_ops(supported_ops), + m_dynamism_supported(dynamism_supported) { set_device_name(name); } @@ -501,10 +532,24 @@ class MockPluginBase : public ov::IPlugin { auto device_id = properties.count(ov::device::id.name()) ? properties.at(ov::device::id.name()).as() : m_default_device_id; - for (const auto& op : model->get_ordered_ops()) { - if (m_supported_ops.find(op->get_type_info().name) == m_supported_ops.end()) - continue; - res[op->get_friendly_name()] = get_device_name() + "." + device_id; + + auto supported = ov::get_supported_nodes( + model, + [&](std::shared_ptr& model) { + ov::pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(model); + }, + [&](const std::shared_ptr& op) { + if (op->is_dynamic() && !m_dynamism_supported) + return false; + if (m_supported_ops.find(op->get_type_info().name) == m_supported_ops.end()) + return false; + return true; + }); + for (auto&& op_name : supported) { + res.emplace(op_name, get_device_name() + "." + device_id); } return res; } @@ -512,6 +557,7 @@ class MockPluginBase : public ov::IPlugin { protected: std::string m_default_device_id = "0"; std::unordered_set m_supported_ops; + bool m_dynamism_supported = false; bool m_profiling = false; bool m_loaded_from_cache{false}; }; @@ -519,7 +565,7 @@ class MockPluginBase : public ov::IPlugin { class MockPluginReshape : public MockPluginBase { public: MockPluginReshape(const std::string& name) - : MockPluginBase(name, {"Parameter", "Result", "Add", "Constant", "Reshape"}) {} + : MockPluginBase(name, {"Parameter", "Result", "Add", "Constant", "Reshape"}, true) {} const ov::Version& get_const_version() override { static const ov::Version version = {CI_BUILD_NUMBER, "openvino_mock_reshape_plugin"}; diff --git a/src/plugins/hetero/tests/functional/hetero_tests.hpp b/src/plugins/hetero/tests/functional/hetero_tests.hpp index b2af29f19472a5..7b6e5f85fad0ee 100644 --- a/src/plugins/hetero/tests/functional/hetero_tests.hpp +++ b/src/plugins/hetero/tests/functional/hetero_tests.hpp @@ -20,10 +20,11 @@ class HeteroTests : public ::testing::Test { void SetUp() override; - std::shared_ptr create_model_with_subtract(); - std::shared_ptr create_model_with_subtract_reshape(); - std::shared_ptr create_model_with_subtract_reshape_relu(); - std::shared_ptr create_model_with_reshape(); + std::shared_ptr create_model_with_subtract(bool dynamic = false); + std::shared_ptr create_model_with_subtract_reshape(bool dynamic = false); + std::shared_ptr create_model_with_subtract_reshape_relu(bool dynamic = false); + std::shared_ptr create_model_with_reshape(bool dynamic = false); + std::shared_ptr create_model_with_subtract_shapeof_reshape(bool dynamic = false); ov::Tensor create_and_fill_tensor(const ov::element::Type& type, const ov::Shape& shape); private: diff --git a/src/plugins/hetero/tests/functional/query_model_tests.cpp b/src/plugins/hetero/tests/functional/query_model_tests.cpp index 9df8c2b110abcf..4563cdd726b7f0 100644 --- a/src/plugins/hetero/tests/functional/query_model_tests.cpp +++ b/src/plugins/hetero/tests/functional/query_model_tests.cpp @@ -37,8 +37,14 @@ TEST_F(HeteroTests, query_model_on_mock1) { EXPECT_EQ(op.second, dev_name); names.erase(op.first); } - EXPECT_EQ(1, names.size()); - EXPECT_EQ("reshape", *names.begin()); + const std::vector unmarked_names = {"reshape_val", "reshape", "res"}; + EXPECT_EQ(unmarked_names.size(), names.size()); + for (auto& name : unmarked_names) { + auto it = names.find(name); + if (it != names.end()) + names.erase(it); + } + EXPECT_EQ(0, names.size()); } TEST_F(HeteroTests, query_model_on_mixed) { @@ -65,3 +71,30 @@ TEST_F(HeteroTests, query_model_on_mixed) { } EXPECT_EQ(0, names.size()); } + +TEST_F(HeteroTests, query_dynamic_model_on_mixed) { + const std::string dev_name0 = "MOCK0.3"; + const std::string dev_name1 = "MOCK1.2"; + ov::AnyMap config = {ov::device::priorities(dev_name0 + "," + dev_name1)}; + const auto model = create_model_with_subtract_reshape(true); + std::set supported_ops_mock0; + for (auto& op : core.query_model(model, dev_name0)) { + if (op.second == dev_name0) + supported_ops_mock0.insert(op.first); + } + const auto supported_ops = core.query_model(model, "HETERO", config); + std::unordered_set names; + for (const auto& op : model->get_ops()) { + names.insert(op->get_friendly_name()); + } + for (const auto& op : supported_ops) { + if (supported_ops_mock0.count(op.first)) + EXPECT_EQ(op.second, dev_name0); + else + EXPECT_EQ(op.second, dev_name1); + names.erase(op.first); + } + EXPECT_EQ(1, names.size()); + // fallback plugin doesn't support dynamism + ASSERT_TRUE(names.count("sub")); +} From ae20c5251a376bf4194a85c6e17412f0c3f1b8fe Mon Sep 17 00:00:00 2001 From: Irina Efode Date: Wed, 9 Aug 2023 19:27:45 +0400 Subject: [PATCH 06/51] [CONFORMANCE] Fix expected trusted op passrate + python constants fix (#19050) * [CONFORMANCE] Fix expected trusted op passrate + constants * tmp disable qm & ie * rename read_ir to inference * take max timestamp instead of min --- .../op_conformance_runner/src/read_ir/read_ir_tests.cpp | 7 ++++--- .../layer_tests_summary/merge_xmls.py | 2 +- .../layer_tests_summary/rename_conformance_ir.py | 1 - .../layer_tests_summary/template/report_template.html | 2 +- .../layer_tests_summary/utils/constants.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp index 062861c9a35e74..8a0092bc0204e5 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp @@ -17,15 +17,16 @@ using namespace ov::test::subgraph; namespace { -TEST_P(ReadIRTest, ReadIR) { +TEST_P(ReadIRTest, Inference) { run(); } -TEST_P(ReadIRTest, QueryModel) { +// temporarty disable to provide correct numbers for release +TEST_P(ReadIRTest, DISABLED_QueryModel) { query_model(); } -TEST_P(ReadIRTest, ImportExport) { +TEST_P(ReadIRTest, DISABLED_ImportExport) { import_export(); } diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/merge_xmls.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/merge_xmls.py index 1a7a32b114b28f..c75a1e5607dbe8 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/merge_xmls.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/merge_xmls.py @@ -67,7 +67,7 @@ def aggregate_test_results(aggregated_results: SubElement, xml_reports: list, continue xml_results = xml_root.find("results") xml_timestamp = xml_root.get("timestamp") - if aggregated_timestamp is None or xml_timestamp < aggregated_timestamp: + if aggregated_timestamp is None or xml_timestamp > aggregated_timestamp: aggregated_timestamp = xml_timestamp for xml_device_entry in xml_results: if merge_device_suffix and "." in xml_device_entry.tag: diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/rename_conformance_ir.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/rename_conformance_ir.py index 9347617afee3ae..0cf63c5ce1e216 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/rename_conformance_ir.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/rename_conformance_ir.py @@ -24,7 +24,6 @@ if PY_OPENVINO in os.listdir(ov_bin_path): env = os.environ py_ov = os.path.join(ov_bin_path, PY_OPENVINO) - py_ov = os.path.join(py_ov, find_latest_dir(py_ov)) env = set_env_variable(env, "PYTHONPATH", py_ov) env = set_env_variable(env, LD_LIB_PATH_NAME, ov_bin_path) diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/template/report_template.html b/src/tests/test_utils/functional_test_utils/layer_tests_summary/template/report_template.html index 80efaabbdb250f..e440458b2704ed 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/template/report_template.html +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/template/report_template.html @@ -32,7 +32,7 @@

Operations coverage summary: Tag: {{report_tag}} | Version: {{report_version Passrates are based on relative weights each subgraphs! You can check absolute value in `General passrate` row!
- Relative Passrate could be from 0 to 200% now! Relative weight of operation is calculated once for current set of models, but there are more then one tests per model. + Relative Passrate could be from 0 to 100% (Inference only)! Relative weight of operation is calculated once for current set of models, but there are more then one tests per model.
Status: diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index a5cef0ce3ebf9f..825e599d52ea07 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -28,7 +28,7 @@ LD_LIB_PATH_NAME = "PATH" if IS_WIN else "LD_LIBRARY_PATH" OPENVINO_NAME = 'openvino' -PY_OPENVINO = "python_api" +PY_OPENVINO = "python" DEBUG_DIR = "Debug" RELEASE_DIR = "Release" From c44df9907b1577f237c813f2b13ccad1b0d7f388 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Wed, 9 Aug 2023 18:01:35 +0200 Subject: [PATCH 07/51] [MO] Do not create example inputs based on input or input_shape (#18975) --- .../test_mo_convert_pytorch.py | 110 +++++------------- .../mo/moc_frontend/pytorch_frontend_utils.py | 59 +--------- .../moc_frontend/pytorch_frontend_utils.py | 58 +-------- 3 files changed, 36 insertions(+), 191 deletions(-) diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py index 5e6cdc765c9db0..ae48f1ce1ae7f2 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py @@ -74,6 +74,7 @@ def __init__(self): ) def forward(self, x, y=None, z=None): + logits = None if y is None: logits = self.linear_relu_stack(x + z) if z is None: @@ -87,7 +88,7 @@ def make_ref_pt_model_one_input(shape, dtype=np.float32): shape = PartialShape(shape) param1 = ov.opset8.parameter(shape, name="input_0", dtype=dtype) relu = ov.opset8.relu(param1) - if dtype != np.float32: + if dtype not in [np.float32, Type.dynamic]: relu = ov.opset8.convert(relu, np.float32) sigm = ov.opset8.sigmoid(relu) @@ -106,9 +107,13 @@ def make_ref_pt_model_two_inputs(shape, dtype=np.float32): shape = PartialShape(shape) param1 = ov.opset8.parameter(shape, name="input_0", dtype=dtype) param2 = ov.opset8.parameter(shape, name="input_1", dtype=dtype) - mul = ov.opset8.multiply(param1, param2) + if dtype == Type.dynamic: + cl = ov.opset8.convert_like(param2, param1) + mul = ov.opset8.multiply(param1, cl) + else: + mul = ov.opset8.multiply(param1, param2) relu = ov.opset8.relu(mul) - if dtype != np.float32: + if dtype not in [np.float32, Type.dynamic]: relu = ov.opset8.convert(relu, np.float32) sigm = ov.opset8.sigmoid(relu) @@ -277,7 +282,7 @@ def scripted_fn(x: torch.Tensor, y: torch.Tensor): return torch.sigmoid(torch.relu(x * y)) inp_shape = PartialShape([Dimension(1, -1), Dimension(-1, 5), 10]) - ref_model = make_ref_pt_model_two_inputs(inp_shape) + ref_model = make_ref_pt_model_two_inputs(inp_shape, dtype=Type.dynamic) return scripted_fn, ref_model, {'input': [(inp_shape), (inp_shape)]} @@ -292,7 +297,7 @@ def create_pytorch_nn_module_layout_list(tmp_dir): ref_model.inputs[1].node.layout = Layout('nhwc') return pt_model, ref_model, { - 'input_shape': [shape, shape], 'layout': ['nchw', Layout('nhwc')], 'use_convert_model_from_mo': True + 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ['nchw', Layout('nhwc')], 'use_convert_model_from_mo': True } @@ -307,30 +312,7 @@ def create_pytorch_nn_module_layout_list_case2(tmp_dir): ref_model.inputs[1].node.layout = Layout('nhwc') return pt_model, ref_model, { - 'input_shape': [shape, shape], 'layout': ('nchw', Layout('nhwc')), 'use_convert_model_from_mo': True} - - -def create_pytorch_nn_module_mean_list(tmp_dir): - pt_model = make_pt_model_two_inputs() - shape = [1, 10, 10, 3] - - shape = PartialShape(shape) - param1 = ov.opset8.parameter(shape) - param2 = ov.opset8.parameter(shape) - const1 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32) - const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32) - add1 = ov.opset8.add(param1, const1) - add2 = ov.opset8.add(param2, const2) - mul = ov.opset8.multiply(add1, add2) - relu = ov.opset8.relu(mul) - sigm = ov.opset8.sigmoid(relu) - - parameter_list = [param1, param2] - ref_model = Model([sigm], parameter_list, "test") - - return pt_model, ref_model, { - 'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': False, - 'use_convert_model_from_mo': True} + 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ('nchw', Layout('nhwc')), 'use_convert_model_from_mo': True} def create_pytorch_nn_module_mean_list_compression_disabled(tmp_dir): @@ -351,7 +333,7 @@ def create_pytorch_nn_module_mean_list_compression_disabled(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': False, 'use_convert_model_from_mo': True} @@ -375,7 +357,7 @@ def create_pytorch_nn_module_mean_list_compression_default(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'use_convert_model_from_mo': True} @@ -403,32 +385,10 @@ def create_pytorch_nn_module_mean_list_compression_enabled(tmp_dir): ref_model = Model([sigm], parameter_list, "test") return pt_model, ref_model, { - 'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], + 'input': [(shape, np.float32), (shape, np.float32)], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': True, 'use_convert_model_from_mo': True} -def create_pytorch_nn_module_scale_list(tmp_dir): - pt_model = make_pt_model_two_inputs() - shape = [1, 10, 10, 3] - - shape = PartialShape(shape) - param1 = ov.opset8.parameter(shape) - param2 = ov.opset8.parameter(shape) - const1 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32) - const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32) - sub1 = ov.opset8.multiply(param1, const1) - sub2 = ov.opset8.multiply(param2, const2) - mul = ov.opset8.multiply(sub1, sub2) - relu = ov.opset8.relu(mul) - sigm = ov.opset8.sigmoid(relu) - - parameter_list = [param1, param2] - ref_model = Model([sigm], parameter_list, "test") - - return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': False, - 'use_convert_model_from_mo': True} - - def create_pytorch_nn_module_scale_list_compression_disabled(tmp_dir): pt_model = make_pt_model_two_inputs() shape = [1, 10, 10, 3] @@ -447,7 +407,8 @@ def create_pytorch_nn_module_scale_list_compression_disabled(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': False, 'use_convert_model_from_mo': True} @@ -471,7 +432,8 @@ def create_pytorch_nn_module_scale_list_compression_default(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'scale_values': [[1, 1, 1], [1, 1, 1]], 'use_convert_model_from_mo': True} @@ -497,13 +459,14 @@ def create_pytorch_nn_module_scale_list_compression_enabled(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': True, 'use_convert_model_from_mo': True} def create_pytorch_nn_module_shapes_list_static(tmp_dir): pt_model = make_pt_model_two_inputs() - ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20]) + ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20], dtype=Type.dynamic) return pt_model, ref_model, {'input': [[1, 3, 20, 20], [1, 3, 20, 20]]} @@ -521,10 +484,11 @@ def create_pytorch_nn_module_shapes_list_dynamic(tmp_dir): [-1, 3, 20, Dimension(-1, 20)]] param1 = ov.opset8.parameter(PartialShape( - inp_shapes[0]), name="x", dtype=np.float32) + inp_shapes[0]), name="x", dtype=Type.dynamic) param2 = ov.opset8.parameter(PartialShape( - inp_shapes[1]), name="y", dtype=np.float32) - mul = ov.opset8.multiply(param1, param2) + inp_shapes[1]), name="y", dtype=Type.dynamic) + cl = ov.opset8.convert_like(param2, param1) + mul = ov.opset8.multiply(param1, cl) relu = ov.opset8.relu(mul) sigm = ov.opset8.sigmoid(relu) @@ -548,13 +512,13 @@ def create_pytorch_nn_module_shapes_list_dynamic_via_input(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input': [(inp_shapes[0],), (inp_shapes[1],)]} + return pt_model, ref_model, {'input': [(inp_shapes[0], Type.f32), (inp_shapes[1], Type.f32)]} def create_pytorch_nn_module_shapes_list_dynamic_single_input(tmp_dir): pt_model = make_pt_model_one_input() inp_shapes = [[Dimension(-1), 3, 20, Dimension(20, -1)]] - ref_model = make_ref_pt_model_one_input(inp_shapes[0]) + ref_model = make_ref_pt_model_one_input(inp_shapes[0], dtype=Type.dynamic) return pt_model, ref_model, {'input': inp_shapes} @@ -568,7 +532,7 @@ def create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input(tmp_dir) def create_pytorch_nn_module_shapes_list_static_single_input(tmp_dir): pt_model = make_pt_model_one_input() inp_shapes = [[1, 3, 20, 20]] - ref_model = make_ref_pt_model_one_input(inp_shapes[0]) + ref_model = make_ref_pt_model_one_input(inp_shapes[0], dtype=Type.dynamic) return pt_model, ref_model, {'input': inp_shapes} @@ -735,20 +699,6 @@ def create_pytorch_module_with_optional_inputs_case3(tmp_dir): return net, ref_model, {"example_input": example_input, "input": [[3, 3, 3, 3], [3, 3, 3, 3]]} -def create_pytorch_module_with_optional_inputs_case4(tmp_dir): - net = make_pt_model_with_optional_input() - ref_model = make_ref_pt_model_with_optional_inputs( - [3, 3, 3, 3], z_exist=True) - return net, ref_model, {"input": [("x", [3, 3, 3, 3]), ("z", [3, 3, 3, 3])]} - - -def create_pytorch_module_with_optional_inputs_case5(tmp_dir): - net = make_pt_model_with_optional_input() - ref_model = make_ref_pt_model_with_optional_inputs( - [1, 3, -1, -1], z_exist=True) - return net, ref_model, {"input": [("x",[1, 3, -1, -1]), ("z", [1, 3, -1, -1])]} - - def create_pytorch_module_with_compressed_int8_constant_compress_to_fp16_default(tmp_dir): import torch import torch.nn.functional as F @@ -1013,11 +963,9 @@ class TestMoConvertPyTorch(CommonMOConvertTest): create_pytorch_jit_script_function, create_pytorch_nn_module_layout_list, create_pytorch_nn_module_layout_list_case2, - create_pytorch_nn_module_mean_list, create_pytorch_nn_module_mean_list_compression_default, create_pytorch_nn_module_mean_list_compression_disabled, create_pytorch_nn_module_mean_list_compression_enabled, - create_pytorch_nn_module_scale_list, create_pytorch_nn_module_scale_list_compression_default, create_pytorch_nn_module_scale_list_compression_disabled, create_pytorch_nn_module_scale_list_compression_enabled, @@ -1039,8 +987,6 @@ class TestMoConvertPyTorch(CommonMOConvertTest): create_pytorch_module_with_optional_inputs_case1, create_pytorch_module_with_optional_inputs_case2, create_pytorch_module_with_optional_inputs_case3, - create_pytorch_module_with_optional_inputs_case4, - create_pytorch_module_with_optional_inputs_case5, create_pytorch_nn_module_with_scalar_input, create_pytorch_module_with_compressed_int8_constant, create_pytorch_module_with_compressed_int8_constant_compress_to_fp16_default, diff --git a/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py b/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py index b42fa131225077..7cb46d92300640 100644 --- a/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py +++ b/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py @@ -30,7 +30,7 @@ def get_pytorch_decoder(model, input_shape, example_inputs, args): "NNCF models produced by nncf<2.6 are not supported directly. Please export to ONNX first.") except: pass - inputs = prepare_torch_inputs(example_inputs, input_shape, args.get("input"), allow_none=True) + inputs = prepare_torch_inputs(example_inputs) decoder = TorchScriptPythonDecoder(model, example_input=inputs) args['input_model'] = decoder args["framework"] = "pytorch" @@ -151,36 +151,7 @@ def to_torch_tensor(tensor): "Got {}".format(type(tensor))) -def get_torch_dtype(dtype): - import torch - ov_str_to_torch = { - "boolean": torch.bool, - "f16": torch.float16, - "f32": torch.float32, - "f64": torch.float64, - "i8": torch.int8, - "i16": torch.int16, - "i32": torch.int32, - "i64": torch.int64, - "u8": torch.uint8, - } - if dtype is None: - return torch.float - if isinstance(dtype, torch.dtype): - return dtype - if isinstance(dtype, (type, np.dtype)): - dtype = get_element_type_str(dtype) - if isinstance(dtype, Type): - dtype = dtype.get_type_name() - if isinstance(dtype, str): - str_dtype = ov_str_to_torch.get(dtype) - if str_dtype is None: - raise Error(f"Unexpected data type '{dtype}' for input") - return str_dtype - raise Error(f"Unexpected data type for input. Supported torch.dtype, numpy.dtype, ov.Type and str. Got {type(dtype)}") - - -def prepare_torch_inputs(example_inputs, input_shape, input_info=None, allow_none=False): +def prepare_torch_inputs(example_inputs): import torch inputs = None if example_inputs is not None: @@ -201,29 +172,7 @@ def prepare_torch_inputs(example_inputs, input_shape, input_info=None, allow_non inputs[name] = to_torch_tensor(tensor) else: inputs = to_torch_tensor(inputs) - elif input_info is not None or input_shape is not None: - input_info = input_to_input_cut_info(input_info) or [] - input_shape_to_input_cut_info(input_shape, input_info) - inputs = [] - inputs_with_names = {} - for inp in input_info: - shape = inp.shape - if shape is None: - if not allow_none: - raise Error("Please provide input_shape or example_input for all inputs converting PyTorch model.") - inputs = None - break - dtype = get_torch_dtype(inp.type) - static_shape = get_static_shape(shape, dynamic_value=1) - input_tensor = torch.zeros(static_shape, dtype=dtype) # pylint: disable=no-member - if inp.name is not None: - inputs_with_names[inp.name] = input_tensor - inputs.append(input_tensor) - if isinstance(inputs, list): - inputs = tuple(inputs) - if inputs is not None and len(inputs) == len(inputs_with_names): - inputs = inputs_with_names else: - if not allow_none: - raise Error("Please provide input_shape or example_input for converting PyTorch model.") + # No example_input were provided, decoder will use scripting + return None return inputs diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py index 3bb6c928f3a10f..89c5ce11ae520b 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py @@ -30,7 +30,7 @@ def get_pytorch_decoder(model, example_inputs, args): "NNCF models produced by nncf<2.6 are not supported directly. Please export to ONNX first.") except: pass - inputs = prepare_torch_inputs(example_inputs, args.get("input"), allow_none=True) + inputs = prepare_torch_inputs(example_inputs) decoder = TorchScriptPythonDecoder(model, example_input=inputs) args['input_model'] = decoder args["example_input"] = inputs @@ -150,36 +150,7 @@ def to_torch_tensor(tensor): "Got {}".format(type(tensor))) -def get_torch_dtype(dtype): - import torch - ov_str_to_torch = { - "boolean": torch.bool, - "f16": torch.float16, - "f32": torch.float32, - "f64": torch.float64, - "i8": torch.int8, - "i16": torch.int16, - "i32": torch.int32, - "i64": torch.int64, - "u8": torch.uint8, - } - if dtype is None: - return torch.float - if isinstance(dtype, torch.dtype): - return dtype - if isinstance(dtype, (type, np.dtype)): - dtype = get_element_type_str(dtype) - if isinstance(dtype, Type): - dtype = dtype.get_type_name() - if isinstance(dtype, str): - str_dtype = ov_str_to_torch.get(dtype) - if str_dtype is None: - raise Error(f"Unexpected data type '{dtype}' for input") - return str_dtype - raise Error(f"Unexpected data type for input. Supported torch.dtype, numpy.dtype, ov.Type and str. Got {type(dtype)}") - - -def prepare_torch_inputs(example_inputs, input_info=None, allow_none=False): +def prepare_torch_inputs(example_inputs): import torch inputs = None if example_inputs is not None: @@ -200,28 +171,7 @@ def prepare_torch_inputs(example_inputs, input_info=None, allow_none=False): inputs[name] = to_torch_tensor(tensor) else: inputs = to_torch_tensor(inputs) - elif input_info is not None: - input_info = input_to_input_cut_info(input_info) or [] - inputs = [] - inputs_with_names = {} - for inp in input_info: - shape = inp.shape - if shape is None: - if not allow_none: - raise Error("Please provide shape in `input` or `example_input` for all inputs converting PyTorch model.") - inputs = None - break - dtype = get_torch_dtype(inp.type) - static_shape = get_static_shape(shape, dynamic_value=1) - input_tensor = torch.zeros(static_shape, dtype=dtype) # pylint: disable=no-member - if inp.name is not None: - inputs_with_names[inp.name] = input_tensor - inputs.append(input_tensor) - if isinstance(inputs, list): - inputs = tuple(inputs) - if inputs is not None and len(inputs) == len(inputs_with_names): - inputs = inputs_with_names else: - if not allow_none: - raise Error("Please provide shapes `input` or `example_input` for converting PyTorch model.") + # No example_input were provided, decoder will use scripting + return None return inputs From 1939dd1df0738a1c9cf3147f382200c40f34cb1e Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 9 Aug 2023 20:18:27 +0400 Subject: [PATCH 08/51] [TF FE] [TF Hub] Support MaxPoolWithArgmax operation (#19085) * [TF FE] Support MaxPoolWithArgmax operation Signed-off-by: Kazantsev, Roman * Add ticket number for TS crash * Correct error message * Skip crashing tests * Set additional tensor name for MaxPool --------- Signed-off-by: Kazantsev, Roman --- src/frontends/tensorflow/src/op_table.cpp | 1 + .../tensorflow_common/src/op/max_pool.cpp | 169 ++++++++++++++---- src/frontends/tensorflow_common/src/utils.cpp | 5 +- .../test_tf_MaxPoolWithArgmax.py | 75 ++++++++ 4 files changed, 214 insertions(+), 36 deletions(-) create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cpp index c7cf8ff6195933..08abacac63cfdd 100644 --- a/src/frontends/tensorflow/src/op_table.cpp +++ b/src/frontends/tensorflow/src/op_table.cpp @@ -190,6 +190,7 @@ const std::map get_supported_ops() { {"MaxPool", CreatorFunction(translate_max_pool_op)}, {"MaxPoolV2", CreatorFunction(translate_max_pool_op)}, {"MaxPool3D", CreatorFunction(translate_max_pool_op)}, + {"MaxPoolWithArgmax", CreatorFunction(translate_max_pool_op)}, {"Merge", CreatorFunction(translate_merge_op)}, {"MirrorPad", CreatorFunction(translate_mirror_pad_op)}, {"MutableHashTable", CreatorFunction(translate_hash_table_op)}, diff --git a/src/frontends/tensorflow_common/src/op/max_pool.cpp b/src/frontends/tensorflow_common/src/op/max_pool.cpp index b2a4520249eb78..d64ac1a17fbafe 100644 --- a/src/frontends/tensorflow_common/src/op/max_pool.cpp +++ b/src/frontends/tensorflow_common/src/op/max_pool.cpp @@ -2,12 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/op/max_pool.hpp" + #include "common_op_table.hpp" -#include "openvino/opsets/opset8.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/subtract.hpp" #include "utils.hpp" using namespace std; using namespace ov; +using namespace ov::op; using namespace ov::frontend::tensorflow; namespace ov { @@ -17,21 +26,25 @@ namespace op { OutputVector translate_max_pool_util(const NodeContext& node, size_t spatial_dims_num, - const std::vector& tf_kernel_sizes, - const std::vector& tf_strides) { - default_op_checks(node, 1, {"MaxPool", "MaxPoolV2", "MaxPool3D"}); + const vector& tf_kernel_sizes, + const vector& tf_strides, + element::Type indices_element_type = element::i64, + int64_t axis = 0, + bool set_friendly_name = true, + bool with_indices = false) { + default_op_checks(node, 1, {"MaxPool", "MaxPoolV2", "MaxPool3D", "MaxPoolWithArgmax"}); TENSORFLOW_OP_VALIDATION(node, spatial_dims_num == 2 || spatial_dims_num == 3, - "Only MaxPool, MaxPoolV2 and MaxPool3D are supported."); + "Only MaxPool, MaxPoolV2, MaxPool3D and MaxPoolWithArgmax are supported."); auto input = node.get_input(0); - auto tf_padding_type = node.get_attribute("padding"); - ov::op::PadType auto_pad = convert_tf_padding(node, tf_padding_type); - auto tf_data_format = node.get_attribute("data_format", spatial_dims_num == 2 ? "NHWC" : "NDHWC"); + auto tf_padding_type = node.get_attribute("padding"); + PadType auto_pad = convert_tf_padding(node, tf_padding_type); + auto tf_data_format = node.get_attribute("data_format", spatial_dims_num == 2 ? "NHWC" : "NDHWC"); - auto tf_explicit_paddings = std::vector{}; - if (auto_pad == ov::op::PadType::EXPLICIT) { - tf_explicit_paddings = node.get_attribute>("explicit_paddings", {}); + auto tf_explicit_paddings = vector{}; + if (auto_pad == PadType::EXPLICIT) { + tf_explicit_paddings = node.get_attribute>("explicit_paddings", {}); } bool is_nhwc = true; @@ -48,40 +61,51 @@ OutputVector translate_max_pool_util(const NodeContext& node, } // prepare attributes for OpenVINO MaxPool operation - ov::Strides strides(spatial_dims_num); - ov::Strides dilations = (spatial_dims_num == 2 ? ov::Strides({1, 1}) : ov::Strides({1, 1, 1})); - ov::Shape kernel_sizes(spatial_dims_num); - ov::frontend::tensorflow::convert_nhwc_to_hw(is_nhwc, tf_strides, strides); - ov::frontend::tensorflow::convert_nhwc_to_hw(is_nhwc, tf_kernel_sizes, kernel_sizes); - - ov::CoordinateDiff pads_begin; - ov::CoordinateDiff pads_end; - if (auto_pad == ov::op::PadType::EXPLICIT) { + Strides strides(spatial_dims_num); + Strides dilations = (spatial_dims_num == 2 ? Strides({1, 1}) : Strides({1, 1, 1})); + Shape kernel_sizes(spatial_dims_num); + convert_nhwc_to_hw(is_nhwc, tf_strides, strides); + convert_nhwc_to_hw(is_nhwc, tf_kernel_sizes, kernel_sizes); + + CoordinateDiff pads_begin; + CoordinateDiff pads_end; + if (auto_pad == PadType::EXPLICIT) { fill_explicit_pads_vectors(node, is_nhwc, spatial_dims_num, tf_explicit_paddings, pads_begin, pads_end); } // prepare input to MaxPool - convert_nhwc_to_nchw(is_nhwc, input, ov::Rank(spatial_dims_num + 2)); - - auto max_pool_node = std::make_shared(input, - strides, - dilations, - ov::Shape(pads_begin.begin(), pads_begin.end()), - ov::Shape(pads_end.begin(), pads_end.end()), - kernel_sizes, - ov::op::RoundingType::FLOOR, - auto_pad); + convert_nhwc_to_nchw(is_nhwc, input, Rank(spatial_dims_num + 2)); + + auto max_pool_node = make_shared(input, + strides, + dilations, + Shape(pads_begin.begin(), pads_begin.end()), + Shape(pads_end.begin(), pads_end.end()), + kernel_sizes, + RoundingType::FLOOR, + auto_pad, + indices_element_type, + axis); auto max_pool = max_pool_node->output(0); - ov::frontend::tensorflow::convert_nchw_to_nhwc(is_nhwc, max_pool, ov::Rank(spatial_dims_num + 2)); - ov::frontend::tensorflow::set_node_name(node.get_name(), max_pool.get_node_shared_ptr()); + convert_nchw_to_nhwc(is_nhwc, max_pool, Rank(spatial_dims_num + 2)); + if (set_friendly_name) { + set_node_name(node.get_name(), max_pool.get_node_shared_ptr()); + } else { + set_out_name(node.get_name() + ":0", max_pool); + } + + if (with_indices) { + auto output_indices = max_pool_node->output(1); + return OutputVector{max_pool, output_indices}; + } return {max_pool}; } OutputVector translate_max_pool(const NodeContext& node, size_t spatial_dims_num) { // MaxPool2D and MaxPool3D have ksize and strides as attributes // retrieve attributes - auto strides = node.get_attribute>("strides"); - auto kernel_sizes = node.get_attribute>("ksize"); + auto strides = node.get_attribute>("strides"); + auto kernel_sizes = node.get_attribute>("ksize"); return translate_max_pool_util(node, spatial_dims_num, kernel_sizes, strides); } @@ -104,6 +128,81 @@ OutputVector translate_max_pool_v2(const NodeContext& node) { return translate_max_pool_util(node, 2, ksize_vector, strides_vector); } +OutputVector translate_max_pool_with_argmax(const NodeContext& node) { + // MaxPoolWithArgmax has just one input. ksize and strides are attributes + TENSORFLOW_OP_VALIDATION(node, + node.get_input_size() > 0, + "MaxPoolWithArgmax operation must have at least one input."); + auto include_batch_in_index = node.get_attribute("include_batch_in_index", false); + auto targmax = node.get_attribute("Targmax", element::i64); + auto ksize = node.get_attribute>("ksize"); + auto strides = node.get_attribute>("ksize"); + auto images = node.get_input(0); + auto node_name = node.get_name(); + + // indices from which dimension to count output indices + int64_t axis = include_batch_in_index ? 0 : 1; + + auto max_pool_with_indices = translate_max_pool_util(node, 2, ksize, strides, targmax, axis, false, true); + TENSORFLOW_OP_VALIDATION(node, + max_pool_with_indices.size() == 2, + "[TensorFlow Frontend] internal error: expect two outputs for MaxPoolWithArgmax."); + auto max_pool = max_pool_with_indices[0]; + auto output_indices_nchw = max_pool_with_indices[1]; + + auto tf_data_format = node.get_attribute("data_format", "NHWC"); + Output output_indices; + if (tf_data_format != "NHWC") { + output_indices = output_indices_nchw; + } else { + output_indices = output_indices_nchw; + // adjust output indices to have them for NHWC layout + // now it is computed for NCHW layout + // 1. compute all dimensions N, H, W, C + auto images_shape = make_shared(images, targmax); + auto const_zero = make_shared(element::i32, Shape{1}, 0); + auto const_one = make_shared(element::i32, Shape{1}, 1); + auto const_two = make_shared(element::i32, Shape{1}, 2); + auto const_three = make_shared(element::i32, Shape{1}, 3); + auto N = make_shared(images_shape, const_zero, const_zero); + auto H = make_shared(images_shape, const_one, const_zero); + auto W = make_shared(images_shape, const_two, const_zero); + auto C = make_shared(images_shape, const_three, const_zero); + + // 2. compute complex index for NCHW layout, i.e. n, h, w, c + auto HW = make_shared(H, W); + Output n; + if (include_batch_in_index) { + auto CHW = make_shared(C, HW); + n = make_shared(output_indices_nchw, CHW); + auto nCHW = make_shared(n, CHW); + output_indices_nchw = make_shared(output_indices_nchw, nCHW); + } else { + n = make_shared(targmax, Shape{1}, 0); + } + auto c = make_shared(output_indices_nchw, HW); + auto cHW = make_shared(c, HW); + output_indices_nchw = make_shared(output_indices_nchw, cHW); + auto h = make_shared(output_indices_nchw, W); + auto hW = make_shared(h, W); + auto w = make_shared(output_indices_nchw, hW); + + // transform them into flatten form for NHWC layout + auto WC = make_shared(W, C); + auto HWC = make_shared(H, WC); + output_indices = make_shared(n, HWC); + auto hWC = make_shared(h, WC); + output_indices = make_shared(output_indices, hWC); + auto wC = make_shared(w, C); + output_indices = make_shared(output_indices, wC); + output_indices = make_shared(output_indices, c); + convert_nchw_to_nhwc(true, output_indices, 4); + } + + set_out_name(node_name + ":1", output_indices); + return {max_pool, output_indices}; +} + OutputVector translate_max_pool_op(const NodeContext& node) { if (node.get_op_type() == "MaxPool") { return translate_max_pool(node, 2); @@ -111,6 +210,8 @@ OutputVector translate_max_pool_op(const NodeContext& node) { return translate_max_pool_v2(node); } else if (node.get_op_type() == "MaxPool3D") { return translate_max_pool(node, 3); + } else if (node.get_op_type() == "MaxPoolWithArgmax") { + return translate_max_pool_with_argmax(node); } else { TENSORFLOW_OP_VALIDATION(node, false, "Only MaxPool2D, MaxPoolV2 and MaxPool3D are supported."); } diff --git a/src/frontends/tensorflow_common/src/utils.cpp b/src/frontends/tensorflow_common/src/utils.cpp index 05aca5ad9ba6c6..83c2f6e8796471 100644 --- a/src/frontends/tensorflow_common/src/utils.cpp +++ b/src/frontends/tensorflow_common/src/utils.cpp @@ -42,6 +42,7 @@ PadType convert_tf_padding(const frontend::NodeContext& node, const string& tf_p "MaxPool", "MaxPoolV2", "MaxPool3D", + "MaxPoolWithArgmax", "ExtractImagePatches", "DepthwiseConv2dNative", "AvgPool", @@ -68,8 +69,8 @@ PadType convert_tf_padding(const frontend::NodeContext& node, const string& tf_p return PadType::SAME_LOWER; } } else if (op_type == "Conv2D" || op_type == "Conv3D" || op_type == "MaxPool" || op_type == "MaxPoolV2" || - op_type == "MaxPool3D" || op_type == "ExtractImagePatches" || op_type == "DepthwiseConv2dNative" || - op_type == "AvgPool" || op_type == "AvgPool3D") { + op_type == "MaxPool3D" || op_type == "MaxPoolWithArgmax" || op_type == "ExtractImagePatches" || + op_type == "DepthwiseConv2dNative" || op_type == "AvgPool" || op_type == "AvgPool3D") { if (tf_padding == "SAME") { // According to the formulas for calculating auto_pad values of the // Conv layer in the Operation specification, diff --git a/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py b/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py new file mode 100644 index 00000000000000..bb39a94594b91a --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py @@ -0,0 +1,75 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +import tensorflow as tf +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestMaxPoolWithArgmax(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + assert 'input' in inputs_info + input_shape = inputs_info['input'] + inputs_data = {} + inputs_data['input'] = np.random.randint(-5, 5, input_shape).astype(self.input_type) + return inputs_data + + def create_max_pool_with_argmax_net(self, input_shape, ksize, strides, input_type, padding, targmax, + include_batch_in_index, with_second_output): + self.input_type = input_type + tf.compat.v1.reset_default_graph() + # Create the graph and model + with tf.compat.v1.Session() as sess: + input = tf.compat.v1.placeholder(input_type, input_shape, 'input') + max_pool_with_argmax = tf.raw_ops.MaxPoolWithArgmax(input=input, ksize=ksize, strides=strides, + padding=padding, Targmax=targmax, + include_batch_in_index=include_batch_in_index + ) + tf.identity(max_pool_with_argmax[0], name='max_pool') + if with_second_output: + tf.identity(max_pool_with_argmax[1], name='output_indices') + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + return tf_net, None + + test_data_basic = [ + dict(input_shape=[1, 25, 24, 3], + ksize=[1, 1, 1, 1], strides=[1, 1, 1, 1]), + dict(input_shape=[1, 10, 20, 3], + ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1]), + ] + + @pytest.mark.parametrize("params", test_data_basic) + @pytest.mark.parametrize("input_type", [ + np.float32, np.int32 + ]) + @pytest.mark.parametrize("padding", [ + 'VALID', 'SAME' + ]) + @pytest.mark.parametrize("targmax", [ + tf.int32, tf.int64 + ]) + @pytest.mark.parametrize("include_batch_in_index", [ + True, False + ]) + @pytest.mark.parametrize("with_second_output", [ + pytest.param( + True, + marks=pytest.mark.skip(reason="117415: TransposeSinking crash") + ), + False + ]) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_max_pool_with_argmax_basic(self, params, input_type, padding, targmax, + include_batch_in_index, with_second_output, + ie_device, precision, ir_version, temp_dir, + use_new_frontend, use_old_api): + self._test( + *self.create_max_pool_with_argmax_net(**params, input_type=input_type, padding=padding, targmax=targmax, + include_batch_in_index=include_batch_in_index, + with_second_output=with_second_output), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend, use_old_api=use_old_api) From 1c0a81bd5f806686e72096677e9497012be5e87e Mon Sep 17 00:00:00 2001 From: Zlobin Vladimir Date: Wed, 9 Aug 2023 20:38:23 +0400 Subject: [PATCH 09/51] Update open_model_zoo submodule (#19092) Ticket 111903 --- thirdparty/open_model_zoo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/open_model_zoo b/thirdparty/open_model_zoo index 4035972e8a3dbb..7353ea15fc0ba5 160000 --- a/thirdparty/open_model_zoo +++ b/thirdparty/open_model_zoo @@ -1 +1 @@ -Subproject commit 4035972e8a3dbbac90d22df5cf741f6cbbca1ea2 +Subproject commit 7353ea15fc0ba57d4bcdd7aaf9c4cde454ca447b From 678c2954ed7f778184d766e3cca951d63c2a9ccd Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 9 Aug 2023 21:10:13 +0400 Subject: [PATCH 10/51] Properly handle python-package in cpack exclude components (#19089) --- .ci/azure/linux.yml | 2 +- CMakeLists.txt | 1 + .../developer_package/packaging/archive.cmake | 90 +++++++++++++++++ cmake/developer_package/packaging/nsis.cmake | 46 +++++++++ .../packaging/packaging.cmake | 96 ++----------------- cmake/packaging/archive.cmake | 23 +++++ cmake/packaging/common-libraries.cmake | 3 + cmake/packaging/debian.cmake | 3 +- cmake/packaging/nsis.cmake | 1 + cmake/packaging/packaging.cmake | 10 +- cmake/packaging/rpm.cmake | 3 +- src/bindings/python/CMakeLists.txt | 3 + 12 files changed, 187 insertions(+), 94 deletions(-) create mode 100644 cmake/developer_package/packaging/archive.cmake create mode 100644 cmake/packaging/archive.cmake diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 2c20f894ba8ca4..7d7454f8794849 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -64,7 +64,7 @@ jobs: Static: CMAKE_BUILD_SHARED_LIBS: 'OFF' PYTHON_STATIC_ARGS: -m "not dynamic_library" - CMAKE_CPACK_GENERATOR: + CMAKE_CPACK_GENERATOR: "TGZ" SAMPLES_INSTALL_DIR: $(INSTALL_DIR)/samples PYTHON_SAMPLES_INSTALL_DIR: $(SAMPLES_INSTALL_DIR)/python RUN_PREFIX: . $(SETUPVARS) && diff --git a/CMakeLists.txt b/CMakeLists.txt index fad19139a1de77..461f1a209cb1c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ message (STATUS "CMAKE_VERSION ......................... " ${CMAKE_VERSION}) message (STATUS "OpenVINO_SOURCE_DIR ................... " ${OpenVINO_SOURCE_DIR}) message (STATUS "OpenVINO_BINARY_DIR ................... " ${OpenVINO_BINARY_DIR}) message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR}) +message (STATUS "CPACK_GENERATOR ....................... " ${CPACK_GENERATOR}) message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID}) message (STATUS "CMAKE_CXX_COMPILER_ID ................. " ${CMAKE_CXX_COMPILER_ID}) if(OV_GENERATOR_MULTI_CONFIG) diff --git a/cmake/developer_package/packaging/archive.cmake b/cmake/developer_package/packaging/archive.cmake new file mode 100644 index 00000000000000..7513a72f880f96 --- /dev/null +++ b/cmake/developer_package/packaging/archive.cmake @@ -0,0 +1,90 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +include(GNUInstallDirs) + +# +# ov_archive_cpack_set_dirs() +# +# Set directories for ARCHIVE cpack +# +macro(ov_archive_cpack_set_dirs) + # common "archive" package locations + # TODO: move current variables to OpenVINO specific locations + set(OV_CPACK_INCLUDEDIR runtime/include) + set(OV_CPACK_IE_CMAKEDIR runtime/cmake) + set(OV_CPACK_NGRAPH_CMAKEDIR runtime/cmake) + set(OV_CPACK_OPENVINO_CMAKEDIR runtime/cmake) + set(OV_CPACK_DOCDIR docs) + set(OV_CPACK_LICENSESDIR licenses) + set(OV_CPACK_SAMPLESDIR samples) + set(OV_CPACK_WHEELSDIR tools) + set(OV_CPACK_TOOLSDIR tools) + set(OV_CPACK_DEVREQDIR tools) + set(OV_CPACK_PYTHONDIR python) + + if(WIN32) + set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_CPACK_RUNTIMEDIR runtime/bin/${ARCH_FOLDER}/$) + set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_WHEEL_RUNTIMEDIR runtime/bin/${ARCH_FOLDER}/Release) + elseif(APPLE) + set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_CPACK_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_WHEEL_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}/Release) + else() + set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}) + set(OV_CPACK_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}) + set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}) + set(OV_WHEEL_RUNTIMEDIR ${OV_CPACK_RUNTIMEDIR}) + endif() + set(OV_CPACK_PLUGINSDIR ${OV_CPACK_RUNTIMEDIR}) + + # for BW compatibility + set(IE_CPACK_LIBRARY_PATH ${OV_CPACK_LIBRARYDIR}) + set(IE_CPACK_RUNTIME_PATH ${OV_CPACK_RUNTIMEDIR}) + set(IE_CPACK_ARCHIVE_PATH ${OV_CPACK_ARCHIVEDIR}) +endmacro() + +ov_archive_cpack_set_dirs() + +# +# Override include / exclude rules for components +# This is required to exclude some files from installation +# (e.g. archive packages don't require python_package component) +# + +macro(ov_define_component_include_rules) + # core components + unset(OV_CPACK_COMP_CORE_EXCLUDE_ALL) + unset(OV_CPACK_COMP_CORE_C_EXCLUDE_ALL) + unset(OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL) + unset(OV_CPACK_COMP_CORE_C_DEV_EXCLUDE_ALL) + # licensing + unset(OV_CPACK_COMP_LICENSING_EXCLUDE_ALL) + # samples + unset(OV_CPACK_COMP_CPP_SAMPLES_EXCLUDE_ALL) + unset(OV_CPACK_COMP_C_SAMPLES_EXCLUDE_ALL) + unset(OV_CPACK_COMP_PYTHON_SAMPLES_EXCLUDE_ALL) + # python + unset(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL) + unset(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL) + unset(OV_CPACK_COMP_OVC_EXCLUDE_ALL) + set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL EXCLUDE_FROM_ALL) + unset(OV_CPACK_COMP_PYTHON_WHEELS_EXCLUDE_ALL) + # tools + set(OV_CPACK_COMP_OPENVINO_DEV_REQ_FILES_EXCLUDE_ALL EXCLUDE_FROM_ALL) + unset(OV_CPACK_COMP_DEPLOYMENT_MANAGER_EXCLUDE_ALL) + # scripts + unset(OV_CPACK_COMP_INSTALL_DEPENDENCIES_EXCLUDE_ALL) + unset(OV_CPACK_COMP_SETUPVARS_EXCLUDE_ALL) +endmacro() + +ov_define_component_include_rules() + +# New in version 3.18 +set(CPACK_ARCHIVE_THREADS 8) +# multiple packages are generated +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) diff --git a/cmake/developer_package/packaging/nsis.cmake b/cmake/developer_package/packaging/nsis.cmake index 1a89f39344016c..f5393357d0ab51 100644 --- a/cmake/developer_package/packaging/nsis.cmake +++ b/cmake/developer_package/packaging/nsis.cmake @@ -43,6 +43,52 @@ endmacro() ov_nsis_specific_settings() +# +# ov_nsis_cpack_set_dirs() +# +# Set directories for ARCHIVE cpack +# +macro(ov_archive_cpack_set_dirs) + # common "archive" package locations + # TODO: move current variables to OpenVINO specific locations + set(OV_CPACK_INCLUDEDIR runtime/include) + set(OV_CPACK_IE_CMAKEDIR runtime/cmake) + set(OV_CPACK_NGRAPH_CMAKEDIR runtime/cmake) + set(OV_CPACK_OPENVINO_CMAKEDIR runtime/cmake) + set(OV_CPACK_DOCDIR docs) + set(OV_CPACK_LICENSESDIR licenses) + set(OV_CPACK_SAMPLESDIR samples) + set(OV_CPACK_WHEELSDIR tools) + set(OV_CPACK_TOOLSDIR tools) + set(OV_CPACK_DEVREQDIR tools) + set(OV_CPACK_PYTHONDIR python) + + if(WIN32) + set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_CPACK_RUNTIMEDIR runtime/bin/${ARCH_FOLDER}/$) + set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_WHEEL_RUNTIMEDIR runtime/bin/${ARCH_FOLDER}/Release) + elseif(APPLE) + set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_CPACK_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}/$) + set(OV_WHEEL_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}/Release) + else() + set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}) + set(OV_CPACK_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}) + set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}) + set(OV_WHEEL_RUNTIMEDIR ${OV_CPACK_RUNTIMEDIR}) + endif() + set(OV_CPACK_PLUGINSDIR ${OV_CPACK_RUNTIMEDIR}) + + # for BW compatibility + set(IE_CPACK_LIBRARY_PATH ${OV_CPACK_LIBRARYDIR}) + set(IE_CPACK_RUNTIME_PATH ${OV_CPACK_RUNTIMEDIR}) + set(IE_CPACK_ARCHIVE_PATH ${OV_CPACK_ARCHIVEDIR}) +endmacro() + +ov_nsis_cpack_set_dirs() + # # Override include / exclude rules for components # This is required to exclude some files from installation diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake index e1d9b60f6079de..50a9d14e2e5d40 100644 --- a/cmake/developer_package/packaging/packaging.cmake +++ b/cmake/developer_package/packaging/packaging.cmake @@ -39,52 +39,6 @@ function(ov_get_pyversion pyversion) endif() endfunction() -# -# ov_cpack_set_dirs() -# -# Set directories for cpack -# -macro(ov_cpack_set_dirs) - # common IRC package locations - # TODO: move current variables to OpenVINO specific locations - set(OV_CPACK_INCLUDEDIR runtime/include) - set(OV_CPACK_IE_CMAKEDIR runtime/cmake) - set(OV_CPACK_NGRAPH_CMAKEDIR runtime/cmake) - set(OV_CPACK_OPENVINO_CMAKEDIR runtime/cmake) - set(OV_CPACK_DOCDIR docs) - set(OV_CPACK_LICENSESDIR licenses) - set(OV_CPACK_SAMPLESDIR samples) - set(OV_CPACK_WHEELSDIR tools) - set(OV_CPACK_TOOLSDIR tools) - set(OV_CPACK_DEVREQDIR tools) - set(OV_CPACK_PYTHONDIR python) - - if(WIN32) - set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}/$) - set(OV_CPACK_RUNTIMEDIR runtime/bin/${ARCH_FOLDER}/$) - set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}/$) - set(OV_WHEEL_RUNTIMEDIR runtime/bin/${ARCH_FOLDER}/Release) - elseif(APPLE) - set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}/$) - set(OV_CPACK_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}/$) - set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}/$) - set(OV_WHEEL_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}/Release) - else() - set(OV_CPACK_LIBRARYDIR runtime/lib/${ARCH_FOLDER}) - set(OV_CPACK_RUNTIMEDIR runtime/lib/${ARCH_FOLDER}) - set(OV_CPACK_ARCHIVEDIR runtime/lib/${ARCH_FOLDER}) - set(OV_WHEEL_RUNTIMEDIR ${OV_CPACK_RUNTIMEDIR}) - endif() - set(OV_CPACK_PLUGINSDIR ${OV_CPACK_RUNTIMEDIR}) - - # for BW compatibility - set(IE_CPACK_LIBRARY_PATH ${OV_CPACK_LIBRARYDIR}) - set(IE_CPACK_RUNTIME_PATH ${OV_CPACK_RUNTIMEDIR}) - set(IE_CPACK_ARCHIVE_PATH ${OV_CPACK_ARCHIVEDIR}) -endmacro() - -ov_cpack_set_dirs() - # # ov_cpack_add_component(NAME ...) # @@ -169,38 +123,15 @@ endmacro() ov_define_component_names() -# default components for case when CPACK_GENERATOR is not set (i.e. default open source user) -macro(ov_define_component_include_rules) - # core components - unset(OV_CPACK_COMP_CORE_EXCLUDE_ALL) - unset(OV_CPACK_COMP_CORE_C_EXCLUDE_ALL) - unset(OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL) - unset(OV_CPACK_COMP_CORE_C_DEV_EXCLUDE_ALL) - # licensing - unset(OV_CPACK_COMP_LICENSING_EXCLUDE_ALL) - # samples - unset(OV_CPACK_COMP_CPP_SAMPLES_EXCLUDE_ALL) - unset(OV_CPACK_COMP_C_SAMPLES_EXCLUDE_ALL) - unset(OV_CPACK_COMP_PYTHON_SAMPLES_EXCLUDE_ALL) - # python - unset(OV_CPACK_COMP_PYTHON_OPENVINO_EXCLUDE_ALL) - unset(OV_CPACK_COMP_BENCHMARK_APP_EXCLUDE_ALL) - unset(OV_CPACK_COMP_OVC_EXCLUDE_ALL) - set(OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE_EXCLUDE_ALL EXCLUDE_FROM_ALL) - unset(OV_CPACK_COMP_PYTHON_WHEELS_EXCLUDE_ALL) - # tools - set(OV_CPACK_COMP_OPENVINO_DEV_REQ_FILES_EXCLUDE_ALL EXCLUDE_FROM_ALL) - unset(OV_CPACK_COMP_DEPLOYMENT_MANAGER_EXCLUDE_ALL) - # scripts - unset(OV_CPACK_COMP_INSTALL_DEPENDENCIES_EXCLUDE_ALL) - unset(OV_CPACK_COMP_SETUPVARS_EXCLUDE_ALL) -endmacro() - -ov_define_component_include_rules() +if(NOT DEFINED CPACK_GENERATOR) + set(CPACK_GENERATOR "TGZ") +elseif(NOT CPACK_GENERATOR) + message(FATAL_ERROR "CPACK_GENERATOR cannot contain an empty value") +endif() # # Include generator specific configuration file: -# 1. Overrides directories set by ov__cpack_set_dirs() +# 1. Overrides directories set by ov__cpack_set_dirs() # This is requried, because different generator use different locations for installed files # 2. Merges some components using ov_override_component_names() # This is required, because different generators have different set of components @@ -230,12 +161,11 @@ elseif(CPACK_GENERATOR STREQUAL "NSIS") include(packaging/nsis) elseif(CPACK_GENERATOR MATCHES "^(CONDA-FORGE|BREW|CONAN|VCPKG)$") include(packaging/common-libraries) +elseif(CPACK_GENERATOR MATCHES "^(7Z|TBZ2|TGZ|TXZ|TZ|TZST|ZIP)$") + include(packaging/archive) endif() macro(ie_cpack) - if(NOT DEFINED CPACK_GENERATOR) - set(CPACK_GENERATOR "TGZ") - endif() set(CPACK_SOURCE_GENERATOR "") # not used set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenVINO™ Toolkit") set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED OFF) @@ -287,18 +217,10 @@ macro(ie_cpack) # include GENERATOR dedicated per-component configuration file # NOTE: private modules need to define ov_cpack_settings macro - # for custom packages configuration + # for custom packages configuration if(COMMAND ov_cpack_settings) ov_cpack_settings() endif() - # generator specific variables - if(CPACK_GENERATOR MATCHES "^(7Z|TBZ2|TGZ|TXZ|TZ|ZIP)$") - # New in version 3.18 - set(CPACK_ARCHIVE_THREADS 8) - # multiple packages are generated - set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) - endif() - include(CPack) endmacro() diff --git a/cmake/packaging/archive.cmake b/cmake/packaging/archive.cmake new file mode 100644 index 00000000000000..59bdc01eb0427b --- /dev/null +++ b/cmake/packaging/archive.cmake @@ -0,0 +1,23 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +# +# OpenVINO Core components including frontends, plugins, etc +# +macro(ov_cpack_settings) + # fill a list of components which are part of conda + set(cpack_components_all ${CPACK_COMPONENTS_ALL}) + unset(CPACK_COMPONENTS_ALL) + foreach(item IN LISTS cpack_components_all) + string(TOUPPER ${item} UPPER_COMP) + # filter out some components, which are not needed to be wrapped to conda-forge | brew | conan | vcpkg + if(NOT OV_CPACK_COMP_${UPPER_COMP}_EXCLUDE_ALL AND + # python_package is not needed in case of archives, because components like pyopenvino are used, as well as wheels + NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE}_python.*") + list(APPEND CPACK_COMPONENTS_ALL ${item}) + endif() + endforeach() + unset(cpack_components_all) + list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL) +endmacro() diff --git a/cmake/packaging/common-libraries.cmake b/cmake/packaging/common-libraries.cmake index 5d2f7bd79e9e89..9b96ed528609df 100644 --- a/cmake/packaging/common-libraries.cmake +++ b/cmake/packaging/common-libraries.cmake @@ -13,6 +13,8 @@ macro(ov_cpack_settings) string(TOUPPER ${item} UPPER_COMP) # filter out some components, which are not needed to be wrapped to conda-forge | brew | conan | vcpkg if(NOT OV_CPACK_COMP_${UPPER_COMP}_EXCLUDE_ALL AND + # because in case of VCPKG | CONAN | BREW | CONDA-FORGE distributions, python is either not needed or installed separately + (NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE}_python.*" OR ENABLE_PYTHON_PACKAGING) AND # even for case of system TBB we have installation rules for wheels packages # so, need to skip this explicitly since they are installed in `host` section NOT item MATCHES "^tbb(_dev)?$" AND @@ -21,6 +23,7 @@ macro(ov_cpack_settings) list(APPEND CPACK_COMPONENTS_ALL ${item}) endif() endforeach() + unset(cpack_components_all) list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL) # override generator diff --git a/cmake/packaging/debian.cmake b/cmake/packaging/debian.cmake index 49a1ad9fe08d36..766209977340bb 100644 --- a/cmake/packaging/debian.cmake +++ b/cmake/packaging/debian.cmake @@ -47,7 +47,7 @@ macro(ov_cpack_settings) string(TOUPPER ${item} UPPER_COMP) # filter out some components, which are not needed to be wrapped to .deb package if(NOT OV_CPACK_COMP_${UPPER_COMP}_EXCLUDE_ALL AND - # skip OpenVINO Python API (pattern in form of "_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") + # skip OpenVINO Python API (pattern in form of "pyopenvino_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO}_python.*" AND # because in case of .deb package, pyopenvino_package_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} is installed (NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE}_python.*" OR ENABLE_PYTHON_PACKAGING) AND @@ -65,6 +65,7 @@ macro(ov_cpack_settings) list(APPEND CPACK_COMPONENTS_ALL ${item}) endif() endforeach() + unset(cpack_components_all) list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL) # version with 3 components diff --git a/cmake/packaging/nsis.cmake b/cmake/packaging/nsis.cmake index b6e809514ca713..e5467ee5afedec 100644 --- a/cmake/packaging/nsis.cmake +++ b/cmake/packaging/nsis.cmake @@ -15,6 +15,7 @@ macro(ov_cpack_settings) list(APPEND CPACK_COMPONENTS_ALL ${item}) endif() endforeach() + unset(cpack_components_all) # restore the components settings diff --git a/cmake/packaging/packaging.cmake b/cmake/packaging/packaging.cmake index a4e165d615d310..7d685f43143de0 100644 --- a/cmake/packaging/packaging.cmake +++ b/cmake/packaging/packaging.cmake @@ -3,11 +3,13 @@ # if(CPACK_GENERATOR STREQUAL "DEB") - include(cmake/packaging/debian.cmake) + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/debian.cmake") elseif(CPACK_GENERATOR STREQUAL "RPM") - include(cmake/packaging/rpm.cmake) + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/rpm.cmake") elseif(CPACK_GENERATOR MATCHES "^(CONDA-FORGE|BREW|CONAN|VCPKG)$") - include(cmake/packaging/common-libraries.cmake) + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/common-libraries.cmake") +elseif(CPACK_GENERATOR MATCHES "^(7Z|TBZ2|TGZ|TXZ|TZ|TZST|ZIP)$") + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/archive.cmake") elseif(CPACK_GENERATOR STREQUAL "NSIS") - include(cmake/packaging/nsis.cmake) + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/nsis.cmake") endif() diff --git a/cmake/packaging/rpm.cmake b/cmake/packaging/rpm.cmake index 24ce1b2cb0696b..d3dd22bcdbd195 100644 --- a/cmake/packaging/rpm.cmake +++ b/cmake/packaging/rpm.cmake @@ -33,7 +33,7 @@ macro(ov_cpack_settings) string(TOUPPER ${item} UPPER_COMP) # filter out some components, which are not needed to be wrapped to .rpm package if(NOT OV_CPACK_COMP_${UPPER_COMP}_EXCLUDE_ALL AND - # skip OpenVINO Python API (pattern in form of "_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") + # skip OpenVINO Python API (pattern in form of "pyopenvino_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO}_python.*" AND # because in case of .rpm package, pyopenvino_package_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} is installed (NOT item MATCHES "^${OV_CPACK_COMP_PYTHON_OPENVINO_PACKAGE}_python.*" OR ENABLE_PYTHON_PACKAGING) AND @@ -51,6 +51,7 @@ macro(ov_cpack_settings) list(APPEND CPACK_COMPONENTS_ALL ${item}) endif() endforeach() + unset(cpack_components_all) list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL) # version with 3 components diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index facfb2218312e6..2e41c7e7802fbd 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -364,5 +364,8 @@ if(ENABLE_TESTS) endif() if(OpenVINODeveloperPackage_FOUND) + # provides a callback function to describe each component in repo + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/packaging.cmake") + ie_cpack(${IE_CPACK_COMPONENTS_ALL}) endif() From 37eef6e554e132632a036f702e00eaa3af33e6e3 Mon Sep 17 00:00:00 2001 From: Georgy Krivoruchko Date: Wed, 9 Aug 2023 11:50:47 -0700 Subject: [PATCH 11/51] Aligned naming for latest changes (#19076) --- .../conformance/test_runner/conformance_infra/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp index e321cec288acf2..b501519c15bbce 100644 --- a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp @@ -22,7 +22,7 @@ void RegisterTestCustomQueries(void) { std::map& extTestQueries = *::PostgreSQLLink::get_ext_test_queries(); std::map& extTestNames = *::PostgreSQLLink::get_ext_test_names(); - std::string testName("checkPluginImplementation"); + std::string testName("checkPluginImplementationCompileModel"); extTestQueries[testName + "_ON_START"] = "OpImplCheck_CheckPluginImpl($__test_id, '$opName', '$opSet', " "'$targetDevice', '$targetDeviceArch', '$targetDeviceName', '$config', $__is_temp)"; From 4ee47fc002943c5c11e95d22997ead4c168ee026 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 9 Aug 2023 22:58:33 +0400 Subject: [PATCH 12/51] [TF FE] Simplify ResizeBilinear and ResizeNearestNeighbor translators (#19099) Signed-off-by: Kazantsev, Roman --- .../tensorflow_common/src/op/interpolate.cpp | 54 +++++++++---------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/frontends/tensorflow_common/src/op/interpolate.cpp b/src/frontends/tensorflow_common/src/op/interpolate.cpp index c2c09295e4a024..a46acf773e5376 100644 --- a/src/frontends/tensorflow_common/src/op/interpolate.cpp +++ b/src/frontends/tensorflow_common/src/op/interpolate.cpp @@ -2,12 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/op/interpolate.hpp" + #include "common_op_table.hpp" -#include "openvino/opsets/opset8.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/slice.hpp" using namespace std; using namespace ov; -using namespace ov::opset8; +using namespace ov::op; namespace ov { namespace frontend { @@ -30,58 +36,48 @@ OutputVector translate_interpolate_op(const NodeContext& node) { " is True, the attribute align_corners must be False."); // prepare attributes for OpenVINO Interpolate operation - Interpolate::InterpolateAttrs interpolate_attrs; - interpolate_attrs.shape_calculation_mode = Interpolate::ShapeCalcMode::SIZES; + v11::Interpolate::InterpolateAttrs interpolate_attrs; + interpolate_attrs.shape_calculation_mode = v11::Interpolate::ShapeCalcMode::SIZES; if (op_type == "ResizeNearestNeighbor") { - interpolate_attrs.mode = Interpolate::InterpolateMode::NEAREST; - interpolate_attrs.nearest_mode = Interpolate::NearestMode::FLOOR; + interpolate_attrs.mode = v11::Interpolate::InterpolateMode::NEAREST; + interpolate_attrs.nearest_mode = v11::Interpolate::NearestMode::FLOOR; } else if (op_type == "ResizeBilinear") { auto input_rank = images.get_partial_shape().rank(); if (input_rank.is_static() && input_rank.get_length() == 4) { - interpolate_attrs.mode = Interpolate::InterpolateMode::LINEAR_ONNX; + interpolate_attrs.mode = v11::Interpolate::InterpolateMode::LINEAR_ONNX; } else { - interpolate_attrs.mode = Interpolate::InterpolateMode::LINEAR; + interpolate_attrs.mode = v11::Interpolate::InterpolateMode::LINEAR; } - interpolate_attrs.nearest_mode = Interpolate::NearestMode::ROUND_PREFER_FLOOR; + interpolate_attrs.nearest_mode = v11::Interpolate::NearestMode::ROUND_PREFER_FLOOR; } if (tf_align_corners) { - interpolate_attrs.coordinate_transformation_mode = Interpolate::CoordinateTransformMode::ALIGN_CORNERS; - if (interpolate_attrs.mode == Interpolate::InterpolateMode::NEAREST) { - interpolate_attrs.nearest_mode = Interpolate::NearestMode::ROUND_PREFER_CEIL; + interpolate_attrs.coordinate_transformation_mode = v11::Interpolate::CoordinateTransformMode::ALIGN_CORNERS; + if (interpolate_attrs.mode == v11::Interpolate::InterpolateMode::NEAREST) { + interpolate_attrs.nearest_mode = v11::Interpolate::NearestMode::ROUND_PREFER_CEIL; } } else if (tf_half_pixel_centers) { - if (interpolate_attrs.mode == Interpolate::InterpolateMode::NEAREST) { + if (interpolate_attrs.mode == v11::Interpolate::InterpolateMode::NEAREST) { interpolate_attrs.coordinate_transformation_mode = - Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN; + v11::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN; } else { - interpolate_attrs.coordinate_transformation_mode = Interpolate::CoordinateTransformMode::HALF_PIXEL; + interpolate_attrs.coordinate_transformation_mode = v11::Interpolate::CoordinateTransformMode::HALF_PIXEL; } } else { - interpolate_attrs.coordinate_transformation_mode = Interpolate::CoordinateTransformMode::ASYMMETRIC; + interpolate_attrs.coordinate_transformation_mode = v11::Interpolate::CoordinateTransformMode::ASYMMETRIC; } - // prepare scales input - auto images_shape = make_shared(images, element::i32); - auto spatial_shape = make_shared(images_shape, - make_shared(element::i64, Shape{1}, std::vector{1}), - make_shared(element::i64, Shape{1}, std::vector{3}), - make_shared(element::i64, Shape{1}, std::vector{1}), - make_shared(element::i64, Shape{1}, std::vector{0})); - auto scales = make_shared(make_shared(size, element::f32), - make_shared(spatial_shape, element::f32)); - // since Interpolate is layout agnostic // we can avoid Transpose operation by specifying axes = {1, 2} for original NHWC layout - auto axes = make_shared(element::i32, Shape{2}, std::vector({1, 2})); + auto axes = make_shared(element::i32, Shape{2}, std::vector({1, 2})); // according to the specification of ResizeBilinear, // it always returns FP32 output type so we immediately align input type for it if (op_type == "ResizeBilinear") { - images = make_shared(images, element::f32); + images = make_shared(images, element::f32); } - auto interpolate = make_shared(images, size, scales, axes, interpolate_attrs); + auto interpolate = make_shared(images, size, axes, interpolate_attrs); set_node_name(node.get_name(), interpolate); return {interpolate}; } From dafe437833b452b27b37e428e57025b8916b443e Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Wed, 9 Aug 2023 21:50:07 +0200 Subject: [PATCH 13/51] [PT FE] Fix issue with kwargs in signature (#19088) * Fix issue with kwargs in signature * Update src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py * Fix problem with some ops in detectron2 * Use debug name for extra input signature --- .../src/openvino/frontend/pytorch/ts_decoder.py | 11 +++++++++-- src/frontends/pytorch/src/utils_quantize.cpp | 17 ++--------------- src/frontends/pytorch/src/utils_quantize.hpp | 3 +-- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py index ce8c60c864dbaf..e07a23dc5cccc1 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py @@ -58,8 +58,15 @@ def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=N self.pt_module = pt_module self.raw_inputs = list(self.graph_element.inputs()) self.raw_outputs = list(self.graph_element.outputs()) - if self._input_signature is not None and "self" in self.raw_inputs[0].debugName(): - self._input_signature.insert(0, "self") + if self._input_signature is not None: + if "self" in self.raw_inputs[0].debugName(): + self._input_signature.insert(0, "self") + if 0 < len(self._input_signature) < len(self.raw_inputs): + # last input is args input, we need to multiply that name by number of extra inputs + self._input_signature = self._input_signature[:-1] + n = len(self._input_signature) + for i in range(len(self.raw_inputs) - n): + self._input_signature.append(self.raw_inputs[i + n].debugName()) if isinstance(self.graph_element, torch.Graph): self._transform_tensor_list_constants_to_listconstruct(self.graph_element) diff --git a/src/frontends/pytorch/src/utils_quantize.cpp b/src/frontends/pytorch/src/utils_quantize.cpp index a8820b8ffe473d..aee7d74eca9c51 100644 --- a/src/frontends/pytorch/src/utils_quantize.cpp +++ b/src/frontends/pytorch/src/utils_quantize.cpp @@ -156,8 +156,8 @@ Output quantize(const NodeContext& context, FRONT_END_OP_CONVERSION_CHECK(false, "Failed to convert a node to QuantizedPtNode"); } -std::shared_ptr cast_quantized_fw_node(Output node) { - auto quant_node = std::dynamic_pointer_cast(node.get_node_shared_ptr()); +std::shared_ptr cast_quantized_fw_node(std::shared_ptr node) { + auto quant_node = std::dynamic_pointer_cast(node); if (!quant_node) { return nullptr; } @@ -168,19 +168,6 @@ std::shared_ptr cast_quantized_fw_node(Output node) { return quant_node; } -std::shared_ptr cast_quantized_fw_node(Output node, const std::string& type) { - auto quant_node = std::dynamic_pointer_cast(node.get_node_shared_ptr()); - if (!quant_node) { - return nullptr; - } - const auto& attrs = quant_node->get_attrs(); - if (attrs.find(QuantizedPtNode::quantized_node_type_key) == attrs.end() || - attrs.at(QuantizedPtNode::quantized_node_type_key) != type) { - return nullptr; - } - return quant_node; -} - } // namespace pytorch } // namespace frontend } // namespace ov diff --git a/src/frontends/pytorch/src/utils_quantize.hpp b/src/frontends/pytorch/src/utils_quantize.hpp index a78855ca2b3eb5..0d5219f00885f7 100644 --- a/src/frontends/pytorch/src/utils_quantize.hpp +++ b/src/frontends/pytorch/src/utils_quantize.hpp @@ -140,8 +140,7 @@ Output quantize(const NodeContext& context, const Output& zero_point, const Output& quantized_node); -std::shared_ptr cast_quantized_fw_node(Output node); -std::shared_ptr cast_quantized_fw_node(Output node, const std::string& type); +std::shared_ptr cast_quantized_fw_node(std::shared_ptr node); namespace op { /** From 24f8c4105e9bbc6740bdf9a757cbc409d7601465 Mon Sep 17 00:00:00 2001 From: Stefania Hergane Date: Wed, 9 Aug 2023 23:20:07 +0300 Subject: [PATCH 14/51] [EISW-89824] [master] Rename VPUX to NPU (#19004) * Change `VPUX`/`VPU` occurrences to `NPU` * Switch `HARDWARE_AWARE_IGNORED_PATTERNS` VPU to NPU * Rename `MYRIAD plugin` * Rename vpu_patterns to npu_patterns in tools/pot * Rename vpu.json to npu.json in tools/pot * Rename restrict_for_vpu to restrict_for_npu in tools/pot * Change keembayOptimalBatchNum to npuOptimalBatchNum --------- Co-authored-by: Dan --- docs/OV_Runtime_UG/automatic_batching.md | 2 +- .../opset_report_omz_static.html | 846 +++++++++--------- .../nncf/ptq/basic_quantization_flow.md | 2 +- samples/cpp/benchmark_app/utils.cpp | 2 +- samples/cpp/speech_sample/README.md | 6 +- samples/cpp/speech_sample/speech_sample.hpp | 4 +- samples/python/speech_sample/README.md | 4 +- samples/python/speech_sample/arg_parser.py | 2 +- .../include/ie/vpu/myriad_config.hpp | 2 +- src/plugins/auto/src/auto_compiled_model.cpp | 2 +- src/plugins/auto/src/auto_schedule.cpp | 8 +- src/plugins/auto/src/plugin_config.cpp | 2 +- .../tests/unit/compile_model_metric_test.cpp | 4 +- .../auto/tests/unit/get_device_list.cpp | 18 +- .../tests/unit/select_device_failed_test.cpp | 10 +- .../include/api_conformance_helpers.hpp | 2 +- .../common_test_utils/CMakeLists.txt | 2 +- .../common_test_utils/common_utils.hpp | 2 +- .../include/common_test_utils/data_utils.hpp | 2 +- .../include/common_test_utils/file_utils.hpp | 2 +- .../include/common_test_utils/test_common.hpp | 2 +- .../common_test_utils/test_constants.hpp | 2 +- .../common_test_utils/src/test_constants.cpp | 2 +- .../functional_test_utils/crash_handler.hpp | 2 +- .../.automation/auto_plugin_test_config.yml | 192 ++-- .../.automation/desktop_test_config.yml | 128 +-- .../.automation/desktop_test_config_cache.yml | 128 +-- tests/time_tests/test_runner/test_timetest.py | 2 +- thirdparty/dependencies.cmake | 4 +- .../tools/benchmark/utils/constants.py | 4 +- tools/pot/README_dev.md | 2 +- tools/pot/docs/BestPractices.md | 4 +- tools/pot/docs/DefaultQuantizationUsage.md | 2 +- .../pot/algorithms/quantization/README.md | 4 +- .../quantization/accuracy_aware/algorithm.py | 2 +- .../accuracy_aware_common/mixed_precision.py | 4 +- .../fake_quantize_configuration.py | 2 +- .../pot/algorithms/quantization/utils.py | 2 +- .../pot/openvino/tools/pot/configs/config.py | 2 +- .../{vpu_patterns.py => npu_patterns.py} | 2 +- tools/pot/openvino/tools/pot/graph/utils.py | 4 +- tools/pot/tests/test_target_device.py | 2 +- 42 files changed, 711 insertions(+), 711 deletions(-) rename tools/pot/openvino/tools/pot/graph/{vpu_patterns.py => npu_patterns.py} (92%) diff --git a/docs/OV_Runtime_UG/automatic_batching.md b/docs/OV_Runtime_UG/automatic_batching.md index 5b558502234f55..7fc4732a8e8db6 100644 --- a/docs/OV_Runtime_UG/automatic_batching.md +++ b/docs/OV_Runtime_UG/automatic_batching.md @@ -11,7 +11,7 @@ The Automatic Batching Execution mode (or Auto-batching for short) performs automatic batching on-the-fly to improve device utilization by grouping inference requests together, without programming effort from the user. With Automatic Batching, gathering the input and scattering the output from the individual inference requests required for the batch happen transparently, without affecting the application code. -Auto Batching can be used :ref:`directly as a virtual device ` or as an :ref:`option for inference on CPU/GPU/VPU ` (by means of configuration/hint). These 2 ways are provided for the user to enable the BATCH devices **explicitly** or **implicitly**, with the underlying logic remaining the same. An example of the difference is that the CPU device doesn’t support implicitly to enable BATCH device, commands such as ``./benchmark_app -m -d CPU -hint tput`` will not apply BATCH device **implicitly**, but ``./benchmark_app -m -d "BATCH:CPU(16)`` can **explicitly** load BATCH device. +Auto Batching can be used :ref:`directly as a virtual device ` or as an :ref:`option for inference on CPU/GPU/NPU ` (by means of configuration/hint). These 2 ways are provided for the user to enable the BATCH devices **explicitly** or **implicitly**, with the underlying logic remaining the same. An example of the difference is that the CPU device doesn’t support implicitly to enable BATCH device, commands such as ``./benchmark_app -m -d CPU -hint tput`` will not apply BATCH device **implicitly**, but ``./benchmark_app -m -d "BATCH:CPU(16)`` can **explicitly** load BATCH device. Auto-batching primarily targets the existing code written for inferencing many requests, each instance with the batch size 1. To get corresponding performance improvements, the application **must be running multiple inference requests simultaneously**. Auto-batching can also be used via a particular *virtual* device. diff --git a/docs/_static/download/operation_conformance_table_files/opset_report_omz_static.html b/docs/_static/download/operation_conformance_table_files/opset_report_omz_static.html index dea9f8ca231cb6..4f95c22d048fae 100644 --- a/docs/_static/download/operation_conformance_table_files/opset_report_omz_static.html +++ b/docs/_static/download/operation_conformance_table_files/opset_report_omz_static.html @@ -105,7 +105,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver GPU NVIDIA TEMPLATE - VPUX + NPU @@ -119,7 +119,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver 95 95 95 - 93 + 93 @@ -131,7 +131,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver 76.84 % 26.32 % 97.89 % - 11.83 % + 11.83 % @@ -143,7 +143,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver 94.92 % 55.09 % 100.0 % - 21.1 % + 21.1 % @@ -155,7 +155,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver 98.25 % 88.98 % 99.96 % - 7.69 % + 7.69 % @@ -304,12 +304,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver

- ---
@@ -430,12 +430,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -556,12 +556,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -682,12 +682,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -808,12 +808,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -969,12 +969,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -1100,12 +1100,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -1226,12 +1226,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -1352,12 +1352,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -1478,12 +1478,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -1604,12 +1604,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -1730,12 +1730,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -1891,12 +1891,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -2022,12 +2022,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -2183,12 +2183,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -2349,12 +2349,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -2480,12 +2480,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -2606,12 +2606,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -2767,12 +2767,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -2898,12 +2898,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -3024,12 +3024,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -3185,12 +3185,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -3311,12 +3311,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -3472,12 +3472,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -3638,12 +3638,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -3804,12 +3804,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -3935,12 +3935,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -4096,12 +4096,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -4227,12 +4227,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -4388,12 +4388,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -4554,12 +4554,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -4720,12 +4720,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -4851,12 +4851,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5012,12 +5012,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -5143,12 +5143,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5269,12 +5269,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5395,12 +5395,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5521,12 +5521,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5647,12 +5647,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5773,12 +5773,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -5934,12 +5934,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -6100,12 +6100,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -6266,12 +6266,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 75.0 %
@@ -6432,12 +6432,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -6563,12 +6563,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -6689,12 +6689,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -6815,12 +6815,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -6976,12 +6976,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -7142,12 +7142,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -7308,12 +7308,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -7439,12 +7439,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -7565,12 +7565,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -7691,12 +7691,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -7817,12 +7817,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -7943,12 +7943,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -8069,12 +8069,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -8097,7 +8097,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver N/A N/A N/A - N/A + N/A @@ -8244,12 +8244,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -8410,12 +8410,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -8576,12 +8576,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -8707,12 +8707,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -8833,12 +8833,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -8994,12 +8994,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 60.0 %
@@ -9160,12 +9160,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -9291,12 +9291,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -9452,12 +9452,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 22.73 %
@@ -9583,12 +9583,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -9709,12 +9709,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -9870,12 +9870,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -10001,12 +10001,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -10127,12 +10127,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -10288,12 +10288,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -10419,12 +10419,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -10580,12 +10580,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -10711,12 +10711,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -10837,12 +10837,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -10998,12 +10998,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -11164,12 +11164,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -11295,7 +11295,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - N/A + N/A @@ -11442,12 +11442,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 66.67 %
@@ -11608,12 +11608,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -11774,12 +11774,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -11905,12 +11905,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -12031,12 +12031,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -12192,12 +12192,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -12323,12 +12323,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -12484,12 +12484,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -12615,12 +12615,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -12741,12 +12741,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -12902,12 +12902,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 55.56 %
@@ -13033,12 +13033,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -13159,12 +13159,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -13285,12 +13285,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -13446,12 +13446,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -13577,12 +13577,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -13703,12 +13703,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -13829,12 +13829,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -13990,12 +13990,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -14121,12 +14121,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -14247,12 +14247,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -14408,12 +14408,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -14574,12 +14574,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -14705,12 +14705,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -14866,12 +14866,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -14997,12 +14997,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -15123,12 +15123,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -15249,12 +15249,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -15375,12 +15375,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -15536,12 +15536,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 50.0 %
@@ -15702,12 +15702,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -15833,12 +15833,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -15959,12 +15959,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -16120,12 +16120,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -16286,12 +16286,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -16452,12 +16452,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -16618,12 +16618,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -16749,12 +16749,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -16875,12 +16875,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -17001,12 +17001,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -17162,12 +17162,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -17293,12 +17293,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -17419,12 +17419,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -17580,12 +17580,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -17711,12 +17711,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -17837,12 +17837,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -17963,12 +17963,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -18089,12 +18089,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -18215,12 +18215,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -18341,12 +18341,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -18502,12 +18502,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -18668,12 +18668,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -18794,12 +18794,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -18955,12 +18955,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -19086,12 +19086,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -19247,12 +19247,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -19378,7 +19378,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - N/A + N/A @@ -19490,12 +19490,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -19651,12 +19651,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -19782,12 +19782,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -19908,12 +19908,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20034,12 +20034,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20160,12 +20160,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20321,12 +20321,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -20452,12 +20452,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20578,12 +20578,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20704,12 +20704,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20830,12 +20830,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -20956,12 +20956,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -21117,12 +21117,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -21248,12 +21248,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -21374,12 +21374,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -21500,12 +21500,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -21626,12 +21626,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -21752,12 +21752,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -21878,12 +21878,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -22004,12 +22004,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -22135,12 +22135,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -22261,12 +22261,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -22422,12 +22422,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -22588,12 +22588,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -22754,12 +22754,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -22920,12 +22920,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -23086,12 +23086,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -23252,12 +23252,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -23418,12 +23418,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -23549,12 +23549,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -23710,12 +23710,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -23841,12 +23841,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -23967,12 +23967,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -24093,12 +24093,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -24219,12 +24219,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -24380,12 +24380,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -24511,7 +24511,7 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - N/A + N/A @@ -24658,12 +24658,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -24824,12 +24824,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -24990,12 +24990,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -25156,12 +25156,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -25287,12 +25287,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -25448,12 +25448,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -25614,12 +25614,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 75.0 %
@@ -25780,12 +25780,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -25946,12 +25946,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -26077,12 +26077,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -26238,12 +26238,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -26369,12 +26369,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -26530,12 +26530,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 90.91 %
@@ -26696,12 +26696,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -26827,12 +26827,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -26988,12 +26988,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -27154,12 +27154,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 44.44 %
@@ -27320,12 +27320,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -27486,12 +27486,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -27652,12 +27652,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -27818,12 +27818,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -27949,12 +27949,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -28110,12 +28110,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -28276,12 +28276,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 0.0 %
@@ -28442,12 +28442,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 22.22 %
@@ -28608,12 +28608,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -28739,12 +28739,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -28900,12 +28900,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 100.0 %
@@ -29031,12 +29031,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -29192,12 +29192,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 50.0 %
@@ -29323,12 +29323,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -29449,12 +29449,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -29610,12 +29610,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 25.0 %
@@ -29776,12 +29776,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 71.43 %
@@ -29907,12 +29907,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
@@ -30068,12 +30068,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 63.64 %
@@ -30234,12 +30234,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - 90.0 %
@@ -30365,12 +30365,12 @@

Operations coverage summary: Tag: Conformance_report__omz_static_opset | Ver - ---
diff --git a/docs/optimization_guide/nncf/ptq/basic_quantization_flow.md b/docs/optimization_guide/nncf/ptq/basic_quantization_flow.md index 5fc93dcc34405e..2b31176f1ef102 100644 --- a/docs/optimization_guide/nncf/ptq/basic_quantization_flow.md +++ b/docs/optimization_guide/nncf/ptq/basic_quantization_flow.md @@ -191,7 +191,7 @@ Tune quantization parameters regex = '.*layer_.*' nncf.quantize(model, dataset, ignored_scope=nncf.IgnoredScope(patterns=regex)) -* ``target_device`` - defines the target device, the specificity of which will be taken into account during optimization. The following values are supported: ``ANY`` (default), ``CPU``, ``CPU_SPR``, ``GPU``, and ``VPU``. +* ``target_device`` - defines the target device, the specificity of which will be taken into account during optimization. The following values are supported: ``ANY`` (default), ``CPU``, ``CPU_SPR``, ``GPU``, and ``NPU``. .. code-block:: sh diff --git a/samples/cpp/benchmark_app/utils.cpp b/samples/cpp/benchmark_app/utils.cpp index 10cc2c3163ca59..af0691693545d9 100644 --- a/samples/cpp/benchmark_app/utils.cpp +++ b/samples/cpp/benchmark_app/utils.cpp @@ -61,7 +61,7 @@ size_t InputInfo::depth() const { uint32_t device_default_device_duration_in_seconds(const std::string& device) { static const std::map deviceDefaultDurationInSeconds{{"CPU", 60}, {"GPU", 60}, - {"VPU", 60}, + {"NPU", 60}, {"UNKNOWN", 120}}; uint32_t duration = 0; for (const auto& deviceDurationInSeconds : deviceDefaultDurationInSeconds) { diff --git a/samples/cpp/speech_sample/README.md b/samples/cpp/speech_sample/README.md index 2771f141923454..188a5b43cbc2c6 100644 --- a/samples/cpp/speech_sample/README.md +++ b/samples/cpp/speech_sample/README.md @@ -96,7 +96,7 @@ Several execution modes are supported via the ``-d`` flag: - ``CPU`` - All calculations are performed on CPU device using CPU Plugin. - ``GPU`` - All calculations are performed on GPU device using GPU Plugin. -- ``VPU`` - All calculations are performed on VPU device using VPU Plugin. +- ``NPU`` - All calculations are performed on NPU device using NPU Plugin. - ``GNA_AUTO`` - GNA hardware is used if available and the driver is installed. Otherwise, the GNA device is emulated in fast-but-not-bit-exact mode. - ``GNA_HW`` - GNA hardware is used if available and the driver is installed. Otherwise, an error will occur. - ``GNA_SW`` - Deprecated. The GNA device is emulated in fast-but-not-bit-exact mode. @@ -144,7 +144,7 @@ Usage message: -i "" Required. Path(s) to input file(s). Usage for a single file/layer: or . Example of usage for several files/layers: :=,:=. -m "" Required. Path to an .xml file with a trained model (required if -rg is missing). -o "" Optional. Output file name(s) to save scores (inference results). Example of usage for a single file/layer: or . Example of usage for several files/layers: :=,:=. - -d "" Optional. Specify a target device to infer on. CPU, GPU, VPU, GNA_AUTO, GNA_HW, GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU as a secondary (e.g. HETERO:GNA,CPU) are supported. The sample will look for a suitable plugin for device specified. + -d "" Optional. Specify a target device to infer on. CPU, GPU, NPU, GNA_AUTO, GNA_HW, GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU as a secondary (e.g. HETERO:GNA,CPU) are supported. The sample will look for a suitable plugin for device specified. -pc Optional. Enables per-layer performance report. -q "" Optional. Input quantization mode for GNA: static (default) or user defined (use with -sf). -qb "" Optional. Weight resolution in bits for GNA quantization: 8 or 16 (default) @@ -162,7 +162,7 @@ Usage message: -compile_target "" Optional. Specify GNA compile target generation. May be one of GNA_TARGET_2_0, GNA_TARGET_3_0. By default, generation corresponds to the GNA HW available in the system or the latest fully supported generation by the software. See the GNA Plugin's GNA_COMPILE_TARGET config option description. -memory_reuse_off Optional. Disables memory optimizations for compiled model. - Available target devices: CPU GNA GPU VPU + Available target devices: CPU GNA GPU NPU .. _model-preparation-speech: diff --git a/samples/cpp/speech_sample/speech_sample.hpp b/samples/cpp/speech_sample/speech_sample.hpp index 9ba602a55e3d39..0bc3a24c950d51 100644 --- a/samples/cpp/speech_sample/speech_sample.hpp +++ b/samples/cpp/speech_sample/speech_sample.hpp @@ -24,7 +24,7 @@ static const char model_message[] = "Required. Path to an .xml file with a train /// @brief message for assigning calculation to device static const char target_device_message[] = - "Optional. Specify a target device to infer on. CPU, GPU, VPU, GNA_AUTO, GNA_HW, " + "Optional. Specify a target device to infer on. CPU, GPU, NPU, GNA_AUTO, GNA_HW, " "GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, " "GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU" " as a secondary (e.g. HETERO:GNA,CPU) are supported. " @@ -274,7 +274,7 @@ bool parse_and_check_command_line(int argc, char* argv[]) { "HETERO:GNA_HW,CPU", "HETERO:GNA_SW_EXACT,CPU", "HETERO:GNA_SW_FP32,CPU", - "VPU"}; + "NPU"}; if (std::find(supportedDevices.begin(), supportedDevices.end(), FLAGS_d) == supportedDevices.end()) { throw std::logic_error("Specified device is not supported."); diff --git a/samples/python/speech_sample/README.md b/samples/python/speech_sample/README.md index ba765f1e127f8a..a4120b10ebfd7d 100644 --- a/samples/python/speech_sample/README.md +++ b/samples/python/speech_sample/README.md @@ -95,7 +95,7 @@ Several execution modes are supported via the ``-d`` flag: - ``CPU`` - All calculations are performed on CPU device using CPU Plugin. - ``GPU`` - All calculations are performed on GPU device using GPU Plugin. -- ``VPU`` - All calculations are performed on VPU device using VPU Plugin. +- ``NPU`` - All calculations are performed on NPU device using NPU Plugin. - ``GNA_AUTO`` - GNA hardware is used if available and the driver is installed. Otherwise, the GNA device is emulated in fast-but-not-bit-exact mode. - ``GNA_HW`` - GNA hardware is used if available and the driver is installed. Otherwise, an error will occur. - ``GNA_SW`` - Deprecated. The GNA device is emulated in fast-but-not-bit-exact mode. @@ -155,7 +155,7 @@ Usage message: Usage for a single file/layer: or . Example of usage for several files/layers: :=,:=. -d DEVICE, --device DEVICE - Optional. Specify a target device to infer on. CPU, GPU, VPU, GNA_AUTO, GNA_HW, GNA_SW_FP32, + Optional. Specify a target device to infer on. CPU, GPU, NPU, GNA_AUTO, GNA_HW, GNA_SW_FP32, GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU as a secondary (e.g. HETERO:GNA,CPU) are supported. The sample will look for a suitable plugin for device specified. Default value is CPU. diff --git a/samples/python/speech_sample/arg_parser.py b/samples/python/speech_sample/arg_parser.py index d6e8c41d83404a..c498eb286df2dd 100644 --- a/samples/python/speech_sample/arg_parser.py +++ b/samples/python/speech_sample/arg_parser.py @@ -32,7 +32,7 @@ def build_arg_parser() -> argparse.ArgumentParser: 'Example of usage for several files/layers: :=,:=.') args.add_argument('-d', '--device', default='CPU', type=str, help='Optional. Specify a target device to infer on. ' - 'CPU, GPU, VPU, GNA_AUTO, GNA_HW, GNA_SW_FP32, GNA_SW_EXACT and HETERO with combination of GNA' + 'CPU, GPU, NPU, GNA_AUTO, GNA_HW, GNA_SW_FP32, GNA_SW_EXACT and HETERO with combination of GNA' ' as the primary device and CPU as a secondary (e.g. HETERO:GNA,CPU) are supported. ' 'The sample will look for a suitable plugin for device specified. Default value is CPU.') args.add_argument('-bs', '--batch_size', type=int, choices=range(1, 9), metavar='[1-8]', diff --git a/src/inference/include/ie/vpu/myriad_config.hpp b/src/inference/include/ie/vpu/myriad_config.hpp index 7fc7d774941526..52d490b87d1b86 100644 --- a/src/inference/include/ie/vpu/myriad_config.hpp +++ b/src/inference/include/ie/vpu/myriad_config.hpp @@ -60,7 +60,7 @@ INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_VPU_CONFIG(MYRIAD_PCIE); INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_VPU_CONFIG(MYRIAD_USB); /** - * @brief Optimize vpu plugin execution to maximize throughput. + * @brief Optimize MYRIAD plugin execution to maximize throughput. * This option should be used with integer value which is the requested number of streams. * The only possible values are: * 1 diff --git a/src/plugins/auto/src/auto_compiled_model.cpp b/src/plugins/auto/src/auto_compiled_model.cpp index 3bfdd51628d18e..a827072bf3234b 100644 --- a/src/plugins/auto/src/auto_compiled_model.cpp +++ b/src/plugins/auto/src/auto_compiled_model.cpp @@ -201,7 +201,7 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const { LOG_WARNING_TAG("deduce optimal infer requset num for auto-batch failed :%s", iie.what()); } real = (std::max)(requests, optimal_batch_size); - } else if (device_info.device_name.find("VPU") != std::string::npos) { + } else if (device_info.device_name.find("NPU") != std::string::npos) { real = 8u; } else { real = upper_bound_streams_num ? 2 * upper_bound_streams_num : default_num_for_tput; diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index 4efcd6e0253ed6..36e9c9f54621a5 100644 --- a/src/plugins/auto/src/auto_schedule.cpp +++ b/src/plugins/auto/src/auto_schedule.cpp @@ -301,10 +301,10 @@ void AutoSchedule::try_to_compile_model(AutoCompileContext& context, const std:: } // need to recompile model, unregister it's priority // there maybe potential issue. - // for example they are dGPU, VPU, iGPU, customer want to compile model with - // configure 0 dGPU, 1 VPU, if dGPU compile failed, - // the result will be not sure, maybe two models are compiled into VPU, - // maybe 0 is compiled to VPU, 1 is compiled to iGPU + // for example they are dGPU, NPU, iGPU, customer want to compile model with + // configure 0 dGPU, 1 NPU, if dGPU compile failed, + // the result will be not sure, maybe two models are compiled into NPU, + // maybe 0 is compiled to NPU, 1 is compiled to iGPU m_plugin->unregister_priority(m_context->m_model_priority, context.m_device_info.unique_name); // remove the current device from device_list auto erase_device = deviceChecker().check_and_return_if_device_in_list(device, device_list, true); diff --git a/src/plugins/auto/src/plugin_config.cpp b/src/plugins/auto/src/plugin_config.cpp index 4fcace66dd3085..0f49680856d1a4 100644 --- a/src/plugins/auto/src/plugin_config.cpp +++ b/src/plugins/auto/src/plugin_config.cpp @@ -8,7 +8,7 @@ namespace auto_plugin { // AUTO will enable the blocklist if // 1.No device priority passed to AUTO/MULTI.(eg. core.compile_model(model, "AUTO", configs);) // 2.No valid device parsed out from device priority (eg. core.compile_model(model, "AUTO:-CPU,-GPU", configs);). -const std::set PluginConfig::device_block_list = {"VPU", "GNA", "notIntelGPU"}; +const std::set PluginConfig::device_block_list = {"NPU", "GNA", "notIntelGPU"}; PluginConfig::PluginConfig() { set_default(); diff --git a/src/plugins/auto/tests/unit/compile_model_metric_test.cpp b/src/plugins/auto/tests/unit/compile_model_metric_test.cpp index 67fac96aabe8dd..05161963605675 100644 --- a/src/plugins/auto/tests/unit/compile_model_metric_test.cpp +++ b/src/plugins/auto/tests/unit/compile_model_metric_test.cpp @@ -192,13 +192,13 @@ TEST_P(ExecNetworkget_propertyOptimalNumInferReq, OPTIMAL_NUMBER_OF_INFER_REQUES metaDevices.push_back({actualDeviceName, metaConfig, actualCustomerNum, ""}); // enable autoBatch unsigned int gpuOptimalBatchNum = 8; - unsigned int keembayOptimalBatchNum = 1; + unsigned int npuOptimalBatchNum = 1; ov::hint::PerformanceMode mode = ov::hint::PerformanceMode::THROUGHPUT; std::tuple rangeOfStreams = std::make_tuple(1, 3); ON_CALL(*core, get_property(StrEq(ov::test::utils::DEVICE_GPU), StrEq(ov::optimal_batch_size.name()), _)) .WillByDefault(RETURN_MOCK_VALUE(gpuOptimalBatchNum)); ON_CALL(*core, get_property(StrEq(ov::test::utils::DEVICE_KEEMBAY), StrEq(ov::optimal_batch_size.name()), _)) - .WillByDefault(RETURN_MOCK_VALUE(keembayOptimalBatchNum)); + .WillByDefault(RETURN_MOCK_VALUE(npuOptimalBatchNum)); ON_CALL(*core, get_property(_, StrEq(ov::range_for_streams.name()), _)) .WillByDefault(RETURN_MOCK_VALUE(rangeOfStreams)); ON_CALL(*core, get_property(_, StrEq(ov::hint::performance_mode.name()), _)) diff --git a/src/plugins/auto/tests/unit/get_device_list.cpp b/src/plugins/auto/tests/unit/get_device_list.cpp index 50837ae17f1d38..5fc8d4eedb4b43 100644 --- a/src/plugins/auto/tests/unit/get_device_list.cpp +++ b/src/plugins/auto/tests/unit/get_device_list.cpp @@ -7,8 +7,8 @@ using Config = std::map; using namespace ov::mock_auto_plugin; -const std::vector availableDevs = {"CPU", "GPU", "VPU"}; -const std::vector availableDevsWithId = {"CPU", "GPU.0", "GPU.1", "VPU"}; +const std::vector availableDevs = {"CPU", "GPU", "NPU"}; +const std::vector availableDevsWithId = {"CPU", "GPU.0", "GPU.1", "NPU"}; using Params = std::tuple; using ConfigParams = std::tuple< std::vector, // Available devices retrieved from Core @@ -96,8 +96,8 @@ const std::vector testConfigsWithId = {Params{" ", " "}, Params{"CPU,,GPU", "CPU,GPU.0,GPU.1"}, Params{"CPU, ,GPU", "CPU, ,GPU.0,GPU.1"}, Params{"CPU,GPU,GPU.1", "CPU,GPU.0,GPU.1"}, - Params{"CPU,GPU,VPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,VPU,INVALID_DEVICE"}, - Params{"VPU,GPU,CPU,-GPU.0", "VPU,GPU.1,CPU"}, + Params{"CPU,GPU,NPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,NPU,INVALID_DEVICE"}, + Params{"NPU,GPU,CPU,-GPU.0", "NPU,GPU.1,CPU"}, Params{"-GPU.0,GPU,CPU", "GPU.1,CPU"}, Params{"-GPU.0,GPU", "GPU.1"}, Params{"-GPU,GPU.0", "GPU.0"}, @@ -131,13 +131,13 @@ const std::vector testConfigs = {Params{" ", " "}, Params{"CPU,GPU,GPU.0", "CPU,GPU"}, Params{"CPU,GPU,GPU.1", "CPU,GPU,GPU.1"}, Params{"CPU,GPU.1,GPU", "CPU,GPU.1,GPU"}, - Params{"CPU,VPU", "CPU,VPU"}, - Params{"CPU,-VPU", "CPU"}, + Params{"CPU,NPU", "CPU,NPU"}, + Params{"CPU,-NPU", "CPU"}, Params{"INVALID_DEVICE", "INVALID_DEVICE"}, Params{"CPU,-INVALID_DEVICE", "CPU"}, Params{"CPU,INVALID_DEVICE", "CPU,INVALID_DEVICE"}, Params{"-CPU,INVALID_DEVICE", "INVALID_DEVICE"}, - Params{"CPU,GPU,VPU", "CPU,GPU,VPU"}}; + Params{"CPU,GPU,NPU", "CPU,GPU,NPU"}}; const std::vector testConfigsWithIdNotInteldGPU = {Params{" ", " "}, Params{"", "CPU,GPU.0"}, @@ -147,8 +147,8 @@ const std::vector testConfigsWithIdNotInteldGPU = {Params{" ", " "}, Params{"CPU,,GPU", "CPU,GPU.0,GPU.1"}, Params{"CPU, ,GPU", "CPU, ,GPU.0,GPU.1"}, Params{"CPU,GPU,GPU.1", "CPU,GPU.0,GPU.1"}, - Params{"CPU,GPU,VPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,VPU,INVALID_DEVICE"}, - Params{"VPU,GPU,CPU,-GPU.0", "VPU,GPU.1,CPU"}, + Params{"CPU,GPU,NPU,INVALID_DEVICE", "CPU,GPU.0,GPU.1,NPU,INVALID_DEVICE"}, + Params{"NPU,GPU,CPU,-GPU.0", "NPU,GPU.1,CPU"}, Params{"-GPU.0,GPU,CPU", "GPU.1,CPU"}, Params{"-GPU.0,GPU", "GPU.1"}, Params{"-GPU,GPU.0", "GPU.0"}, diff --git a/src/plugins/auto/tests/unit/select_device_failed_test.cpp b/src/plugins/auto/tests/unit/select_device_failed_test.cpp index 5559621260d45d..92afffef4b6f82 100644 --- a/src/plugins/auto/tests/unit/select_device_failed_test.cpp +++ b/src/plugins/auto/tests/unit/select_device_failed_test.cpp @@ -127,7 +127,7 @@ TEST_P(AutoLoadFailedTest, LoadCNNetWork) { metaDevices.push_back(std::move(devInfo)); // set the return value of SelectDevice - // for example if there are three device, if will return GPU on the first call, and then MYRIAD + // for example if there are three device, if will return GPU on the first call, and then NPU // at last CPU ON_CALL(*plugin, select_device(Property(&std::vector::size, Eq(selDevsSize)), _, _)) .WillByDefault(Return(metaDevices[deviceConfigs.size() - selDevsSize])); @@ -181,12 +181,12 @@ TEST_P(AutoLoadFailedTest, LoadCNNetWork) { // { true, false, GENERAL, 3 device, 2, 3, 2} // // there are three devices for loading -// CPU load for accelerator success, but GPU will load faild and then select MYRIAD and load again +// CPU load for accelerator success, but GPU will load faild and then select NPU and load again // LoadExeNetworkImpl will not throw exception and can continue to run, -// it will select twice, first select GPU, second select MYRIAD -// it will load network three times(CPU, GPU, MYRIAD) +// it will select twice, first select GPU, second select NPU +// it will load network three times(CPU, GPU, NPU) // the inference request num is loadSuccessCount * optimalNum, in this test case optimalNum is 2 -// so inference request num is 4 (CPU 2, MYRIAD 2) +// so inference request num is 4 (CPU 2, NPU 2) // const std::vector testConfigs = { ConfigParams{true, diff --git a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/include/api_conformance_helpers.hpp b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/include/api_conformance_helpers.hpp index bcf27f17fed6ae..bdde3438192bd6 100644 --- a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/include/api_conformance_helpers.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/include/api_conformance_helpers.hpp @@ -17,7 +17,7 @@ inline const std::string get_plugin_lib_name_by_device(const std::string& device { "HETERO", "openvino_hetero_plugin" }, { "BATCH", "openvino_auto_batch_plugin" }, { "MULTI", "openvino_auto_plugin" }, - { "VPU", "openvino_intel_vpu_plugin" }, + { "NPU", "openvino_intel_npu_plugin" }, { "CPU", "openvino_intel_cpu_plugin" }, { "GNA", "openvino_intel_gna_plugin" }, { "GPU", "openvino_intel_gpu_plugin" }, diff --git a/src/tests/test_utils/common_test_utils/CMakeLists.txt b/src/tests/test_utils/common_test_utils/CMakeLists.txt index 5fd7af8ce5d28e..a03a69b6120e32 100644 --- a/src/tests/test_utils/common_test_utils/CMakeLists.txt +++ b/src/tests/test_utils/common_test_utils/CMakeLists.txt @@ -85,7 +85,7 @@ function(add_common_utils ADD_TARGET_NAME) endfunction() -# Keep old name so that library can be used from VPU repo +# Keep old name so that library can be used from NPU repo set(TARGET_NAME commonTestUtils) set(NEW_TARGET_NAME common_test_utils) diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/common_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/common_utils.hpp index 57f5852e887fc3..f639a1b2192633 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/common_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/common_utils.hpp @@ -196,7 +196,7 @@ size_t getVmRSSInKB(); } // namespace test } // namespace ov -// openvino_contrib and vpu repo use CommonTestUtils:: +// openvino_contrib and NPU repo use CommonTestUtils:: // so we need to add these names to CommonTestUtils namespace namespace CommonTestUtils { using ov::test::utils::vec2str; diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp index e9c554f02fa2bb..7141cd85790921 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp @@ -483,7 +483,7 @@ OPENVINO_SUPPRESS_DEPRECATED_END } // namespace ov -// openvino_contrib and vpu repo use CommonTestUtils:: +// openvino_contrib and NPU repo use CommonTestUtils:: // so we need to add these names to CommonTestUtils namespace namespace CommonTestUtils { using ov::test::utils::ie_abs; diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp index 28ba2d44a359d4..cb97b06a530e19 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp @@ -365,7 +365,7 @@ class MockPlugin : public ov::IPlugin { } // namespace ov -// vpu repo uses CommonTestUtils:: +// NPU repo uses CommonTestUtils:: // so we need to add these names to CommonTestUtils namespace namespace CommonTestUtils { using ov::test::utils::fileExists; diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_common.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_common.hpp index f832f32dbbb29a..1480e6bbd5d589 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_common.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_common.hpp @@ -18,7 +18,7 @@ class TestsCommon; // Temporal WA for applications.ai.vpu-accelerators.vpux-plugin repo // It requires to have TestCommon name in CommonTestUtils namespace -// Need to change namespace in VPU repo and then remove this WA +// Need to change namespace in NPU repo and then remove this WA namespace CommonTestUtils { using ov::test::TestsCommon; } // namespace CommonTestUtils diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_constants.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_constants.hpp index 4e8c11e3ad3a20..3b1b8327c744b6 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_constants.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_constants.hpp @@ -50,7 +50,7 @@ const unsigned int maxFileNameLength = 140; } // namespace test } // namespace ov -// openvino_contrib and vpu repo use CommonTestUtils:: +// openvino_contrib and NPU repo use CommonTestUtils:: // so we need to add these names to CommonTestUtils namespace namespace CommonTestUtils { using ov::test::utils::DEVICE_AUTO; diff --git a/src/tests/test_utils/common_test_utils/src/test_constants.cpp b/src/tests/test_utils/common_test_utils/src/test_constants.cpp index c9338438075467..7018d0283f1548 100644 --- a/src/tests/test_utils/common_test_utils/src/test_constants.cpp +++ b/src/tests/test_utils/common_test_utils/src/test_constants.cpp @@ -12,8 +12,8 @@ const char *DEVICE_AUTO = "AUTO"; const char *DEVICE_CPU = "CPU"; const char *DEVICE_GNA = "GNA"; const char *DEVICE_GPU = "GPU"; +const char *DEVICE_KEEMBAY = "NPU"; const char *DEVICE_BATCH = "BATCH"; -const char *DEVICE_KEEMBAY = "VPU"; const char *DEVICE_MULTI = "MULTI"; const char *DEVICE_TEMPLATE = "TEMPLATE"; const char *DEVICE_HETERO = "HETERO"; diff --git a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/crash_handler.hpp b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/crash_handler.hpp index b59d4b8646f4fd..f8cc7858452797 100644 --- a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/crash_handler.hpp +++ b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/crash_handler.hpp @@ -36,7 +36,7 @@ class CrashHandler { } // namespace test } // namespace ov -// openvino_contrib and vpu repo use CommonTestUtils:: +// openvino_contrib and NPU repo use CommonTestUtils:: // so we need to add these names to CommonTestUtils namespace namespace CommonTestUtils { using ov::test::utils::env; diff --git a/tests/time_tests/.automation/auto_plugin_test_config.yml b/tests/time_tests/.automation/auto_plugin_test_config.yml index 27cb4f05c74ed5..0a884da23815fa 100644 --- a/tests/time_tests/.automation/auto_plugin_test_config.yml +++ b/tests/time_tests/.automation/auto_plugin_test_config.yml @@ -1,392 +1,392 @@ - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf @@ -394,280 +394,280 @@ name: AUTO name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: AUTO:CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: AUTO:GPU,CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf diff --git a/tests/time_tests/.automation/desktop_test_config.yml b/tests/time_tests/.automation/desktop_test_config.yml index 30149dd929d0c5..a21ebe0d201a8d 100644 --- a/tests/time_tests/.automation/desktop_test_config.yml +++ b/tests/time_tests/.automation/desktop_test_config.yml @@ -1,448 +1,448 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf \ No newline at end of file diff --git a/tests/time_tests/.automation/desktop_test_config_cache.yml b/tests/time_tests/.automation/desktop_test_config_cache.yml index 94a2c8bedc9453..a24be9412896ce 100644 --- a/tests/time_tests/.automation/desktop_test_config_cache.yml +++ b/tests/time_tests/.automation/desktop_test_config_cache.yml @@ -1,7 +1,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx @@ -9,7 +9,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16 framework: onnx @@ -17,7 +17,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx @@ -25,7 +25,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml + path: ${NPU_MODELS_PKG}/resnet-50-pytorch/onnx/FP16-INT8/resnet-50-pytorch.xml name: resnet-50-pytorch precision: FP16-INT8 framework: onnx @@ -33,7 +33,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe @@ -41,7 +41,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16/mobilenet-v2.xml name: mobilenet-v2 precision: FP16 framework: caffe @@ -49,7 +49,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe @@ -57,7 +57,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml + path: ${NPU_MODELS_PKG}/mobilenet-v2/caffe/FP16-INT8/mobilenet-v2.xml name: mobilenet-v2 precision: FP16-INT8 framework: caffe @@ -65,7 +65,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf @@ -73,7 +73,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16 framework: tf @@ -81,7 +81,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf @@ -89,7 +89,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/faster-rcnn-resnet101-coco-sparse-60-0001/tf/FP16-INT8/faster-rcnn-resnet101-coco-sparse-60-0001.xml name: faster-rcnn-resnet101-coco-sparse-60-0001 precision: FP16-INT8 framework: tf @@ -97,7 +97,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf @@ -105,7 +105,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16/googlenet-v1.xml name: googlenet-v1 precision: FP16 framework: tf @@ -113,7 +113,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf @@ -121,7 +121,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml + path: ${NPU_MODELS_PKG}/googlenet-v1/tf/FP16-INT8/googlenet-v1.xml name: googlenet-v1 precision: FP16-INT8 framework: tf @@ -129,7 +129,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf @@ -137,7 +137,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16/googlenet-v3.xml name: googlenet-v3 precision: FP16 framework: tf @@ -145,7 +145,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf @@ -153,7 +153,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml + path: ${NPU_MODELS_PKG}/googlenet-v3/tf/FP16-INT8/googlenet-v3.xml name: googlenet-v3 precision: FP16-INT8 framework: tf @@ -161,7 +161,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe @@ -169,7 +169,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16/ssd512.xml name: ssd512 precision: FP16 framework: caffe @@ -177,7 +177,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe @@ -185,7 +185,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml + path: ${NPU_MODELS_PKG}/ssd512/caffe/FP16-INT8/ssd512.xml name: ssd512 precision: FP16-INT8 framework: caffe @@ -193,7 +193,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf @@ -201,7 +201,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16 framework: tf @@ -209,7 +209,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf @@ -217,7 +217,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-0001/tf/FP16-INT8/yolo-v2-ava-0001.xml name: yolo-v2-ava-0001 precision: FP16-INT8 framework: tf @@ -225,7 +225,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf @@ -233,7 +233,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16 framework: tf @@ -241,7 +241,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf @@ -249,7 +249,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-35-0001/tf/FP16-INT8/yolo-v2-ava-sparse-35-0001.xml name: yolo-v2-ava-sparse-35-0001 precision: FP16-INT8 framework: tf @@ -257,7 +257,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf @@ -265,7 +265,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16 framework: tf @@ -273,7 +273,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf @@ -281,7 +281,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-ava-sparse-70-0001/tf/FP16-INT8/yolo-v2-ava-sparse-70-0001.xml name: yolo-v2-ava-sparse-70-0001 precision: FP16-INT8 framework: tf @@ -289,7 +289,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf @@ -297,7 +297,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16 framework: tf @@ -305,7 +305,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf @@ -313,7 +313,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-0001/tf/FP16-INT8/yolo-v2-tiny-ava-0001.xml name: yolo-v2-tiny-ava-0001 precision: FP16-INT8 framework: tf @@ -321,7 +321,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf @@ -329,7 +329,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16 framework: tf @@ -337,7 +337,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf @@ -345,7 +345,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-30-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-30-0001.xml name: yolo-v2-tiny-ava-sparse-30-0001 precision: FP16-INT8 framework: tf @@ -353,7 +353,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf @@ -361,7 +361,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16 framework: tf @@ -369,7 +369,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf @@ -377,7 +377,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/yolo-v2-tiny-ava-sparse-60-0001/tf/FP16-INT8/yolo-v2-tiny-ava-sparse-60-0001.xml name: yolo-v2-tiny-ava-sparse-60-0001 precision: FP16-INT8 framework: tf @@ -385,7 +385,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe @@ -393,7 +393,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16/squeezenet1.1.xml name: squeezenet1.1 precision: FP16 framework: caffe @@ -401,7 +401,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe @@ -409,7 +409,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml + path: ${NPU_MODELS_PKG}/squeezenet1.1/caffe/FP16-INT8/squeezenet1.1.xml name: squeezenet1.1 precision: FP16-INT8 framework: caffe @@ -417,7 +417,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf @@ -425,7 +425,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16 framework: tf @@ -433,7 +433,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf @@ -441,7 +441,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-0001/tf/FP16-INT8/icnet-camvid-ava-0001.xml name: icnet-camvid-ava-0001 precision: FP16-INT8 framework: tf @@ -449,7 +449,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf @@ -457,7 +457,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16 framework: tf @@ -465,7 +465,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf @@ -473,7 +473,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-30-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-30-0001.xml name: icnet-camvid-ava-sparse-30-0001 precision: FP16-INT8 framework: tf @@ -481,7 +481,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf @@ -489,7 +489,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16 framework: tf @@ -497,7 +497,7 @@ - device: name: CPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf @@ -505,7 +505,7 @@ - device: name: GPU model: - path: ${VPUX_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml + path: ${NPU_MODELS_PKG}/icnet-camvid-ava-sparse-60-0001/tf/FP16-INT8/icnet-camvid-ava-sparse-60-0001.xml name: icnet-camvid-ava-sparse-60-0001 precision: FP16-INT8 framework: tf diff --git a/tests/time_tests/test_runner/test_timetest.py b/tests/time_tests/test_runner/test_timetest.py index a090161394fe9b..f7d7600b28115b 100644 --- a/tests/time_tests/test_runner/test_timetest.py +++ b/tests/time_tests/test_runner/test_timetest.py @@ -43,7 +43,7 @@ def test_timetest(instance, executable, niter, cl_cache_dir, model_cache, model_ :param niter: number of times to run executable :param cl_cache_dir: directory to store OpenCL cache :param cpu_cache: flag to enable model CPU cache - :param vpu_compiler: flag to change VPU compiler type + :param npu_compiler: flag to change NPU compiler type :param perf_hint: performance hint (optimize device for latency or throughput settings) :param model_cache_dir: directory to store IE model cache :param test_info: custom `test_info` field of built-in `request` pytest fixture diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake index 3b9d9dc5b0fe4f..47b23885e95efe 100644 --- a/thirdparty/dependencies.cmake +++ b/thirdparty/dependencies.cmake @@ -572,14 +572,14 @@ endif() # if(ENABLE_SAMPLES) - # Note: VPU requires 3.9.0 version, because it contains 'nlohmann::ordered_json' + # Note: NPU requires 3.9.0 version, because it contains 'nlohmann::ordered_json' find_package(nlohmann_json 3.9.0 QUIET) if(nlohmann_json_FOUND) # conan and vcpkg create imported target nlohmann_json::nlohmann_json else() add_subdirectory(thirdparty/json EXCLUDE_FROM_ALL) - # this is required only because of VPU plugin reused this + # this is required only because of NPU plugin reused this openvino_developer_export_targets(COMPONENT openvino_common TARGETS nlohmann_json) # for nlohmann library versions older than v3.0.0 diff --git a/tools/benchmark_tool/openvino/tools/benchmark/utils/constants.py b/tools/benchmark_tool/openvino/tools/benchmark/utils/constants.py index d9e3ca2ae71802..1fb45e1f4a2ae3 100644 --- a/tools/benchmark_tool/openvino/tools/benchmark/utils/constants.py +++ b/tools/benchmark_tool/openvino/tools/benchmark/utils/constants.py @@ -1,7 +1,7 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -VPU_DEVICE_NAME = 'VPU' +NPU_DEVICE_NAME = 'NPU' CPU_DEVICE_NAME = 'CPU' GPU_DEVICE_NAME = 'GPU' HETERO_DEVICE_NAME = 'HETERO' @@ -22,7 +22,7 @@ DEVICE_DURATION_IN_SECS = { CPU_DEVICE_NAME: 60, GPU_DEVICE_NAME: 60, - VPU_DEVICE_NAME: 60, + NPU_DEVICE_NAME: 60, GNA_DEVICE_NAME: 60, UNKNOWN_DEVICE_TYPE: 120 } diff --git a/tools/pot/README_dev.md b/tools/pot/README_dev.md index 785e409edd416f..d524ec5bb59d89 100644 --- a/tools/pot/README_dev.md +++ b/tools/pot/README_dev.md @@ -13,7 +13,7 @@ Post-Training Optimization Tool includes standalone command-line tool and Python * Per-channel quantization for Convolutional and Fully-Connected layers. * Multiple domains: Computer Vision, Recommendation Systems. * Ability to implement custom calibration pipeline via supported [API](openvino/tools/pot/api/README.md). -* Compression for different HW targets such as CPU, GPU, VPU. +* Compression for different HW targets such as CPU, GPU, NPU. * Post-training sparsity. ## Usage diff --git a/tools/pot/docs/BestPractices.md b/tools/pot/docs/BestPractices.md index ab15576a06d8b8..bee4d8fbcadca5 100644 --- a/tools/pot/docs/BestPractices.md +++ b/tools/pot/docs/BestPractices.md @@ -14,7 +14,7 @@ the fastest and easiest way to get a quantized model. It requires only some unan .. note:: - POT uses inference on the CPU during model optimization. It means that ability to infer the original floating-point model is essential for model optimization. In case of the 8-bit quantization, it is recommended to run POT on the same CPU architecture when optimizing for CPU or VNNI-based CPU when quantizing for a non-CPU device, such as GPU, VPU, or GNA. It should help to avoid the impact of the :doc:`saturation issue ` that occurs on AVX and SSE-based CPU devices. + POT uses inference on the CPU during model optimization. It means that ability to infer the original floating-point model is essential for model optimization. In case of the 8-bit quantization, it is recommended to run POT on the same CPU architecture when optimizing for CPU or VNNI-based CPU when quantizing for a non-CPU device, such as GPU, NPU, or GNA. It should help to avoid the impact of the :doc:`saturation issue ` that occurs on AVX and SSE-based CPU devices. Improving accuracy after the Default Quantization @@ -32,7 +32,7 @@ Parameters of the Default Quantization algorithm with basic settings are present # the quantization scheme. For the CPU: # performance - symmetric quantization of weights and activations. # mixed - symmetric weights and asymmetric activations. - # accuracy - the same as "mixed" for CPU, GPU, and GNA devices; asymmetric weights and activations for VPU device. + # accuracy - the same as "mixed" for CPU, GPU, and GNA devices; asymmetric weights and activations for NPU device. "stat_subset_size": 300 # Size of the subset to calculate activations statistics that can be used # for quantization parameters calculation. } diff --git a/tools/pot/docs/DefaultQuantizationUsage.md b/tools/pot/docs/DefaultQuantizationUsage.md index 674d08ba815fc3..ec2edbacca6742 100644 --- a/tools/pot/docs/DefaultQuantizationUsage.md +++ b/tools/pot/docs/DefaultQuantizationUsage.md @@ -90,7 +90,7 @@ Default Quantization algorithm has mandatory and optional parameters which are d * ``"target_device"`` - the following options are available: - * ``"ANY"`` (or ``"CPU"``) - default option to quantize models for CPU, GPU, or VPU + * ``"ANY"`` (or ``"CPU"``) - default option to quantize models for CPU, GPU, or NPU * ``"CPU_SPR"`` - to quantize models for CPU SPR (4th Generation Intel® Xeon® Scalable processor family) * ``"GNA"``, ``"GNA3"``, ``"GNA3.5"`` - to quantize models for GNA devices respectively. diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/README.md b/tools/pot/openvino/tools/pot/algorithms/quantization/README.md index 0444889bf4494e..3b8b9f352e5761 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/README.md +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/README.md @@ -2,9 +2,9 @@ ## Introduction -The primary optimization feature of the Post-training Optimization Tool (POT) is the uniform integer quantization which allows substantially increasing inference performance and reducing the model size. Different HW platforms can support different integer precisions and POT is designed to support all of them, for example, 8-bit for CPU, GPU, VPU, 16-bit for GNA. Moreover, POT makes the specification of HW settings transparent for the user by introducing a concept of the `target_device` parameter. +The primary optimization feature of the Post-training Optimization Tool (POT) is the uniform integer quantization which allows substantially increasing inference performance and reducing the model size. Different HW platforms can support different integer precisions and POT is designed to support all of them, for example, 8-bit for CPU, GPU, NPU, 16-bit for GNA. Moreover, POT makes the specification of HW settings transparent for the user by introducing a concept of the `target_device` parameter. -> **NOTE**: There is a special `target_device: "ANY"` which leads to portable quantized models compatible with CPU, GPU, and VPU devices. GNA-quantized models are compatible only with CPU. +> **NOTE**: There is a special `target_device: "ANY"` which leads to portable quantized models compatible with CPU, GPU, and NPU devices. GNA-quantized models are compatible only with CPU. During the quantization process, the POT tool runs inference of the optimizing model to estimate quantization parameters for input activations of the quantizable operation. It means that a calibration dataset is required to perform quantization. This dataset may have or not have annotation depending on the quantization algorithm that is used. diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware/algorithm.py b/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware/algorithm.py index d08c970f1af7b5..b1c29d88872bc7 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware/algorithm.py +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware/algorithm.py @@ -17,7 +17,7 @@ def __init__(self, config, engine): algos_by_devices = { 'ANY': 'AccuracyAwareCommon', 'CPU': 'AccuracyAwareCommon', - 'VPU': 'AccuracyAwareCommon', + 'NPU': 'AccuracyAwareCommon', 'GPU': 'AccuracyAwareCommon', 'GNA': 'AccuracyAwareGNA', 'GNA3': 'AccuracyAwareGNA', diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware_common/mixed_precision.py b/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware_common/mixed_precision.py index 70011eb9cccc56..c99e9733fae6db 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware_common/mixed_precision.py +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/accuracy_aware_common/mixed_precision.py @@ -31,11 +31,11 @@ def __init__(self, config, engine): self.original_quantization_config.weights.bits = 8 self.original_quantization_config.activations.bits = 8 self._config.convert_to_mixed_preset = False - self._restrict_for_vpu = True + self._restrict_for_npu = True self._engine.calculate_metrics = True def _can_set_fq_to_low_bitwidth(self, node): - if self._restrict_for_vpu: + if self._restrict_for_npu: return (nu.get_node_output(node, 0)[0].type == 'Convolution') and \ ('group' not in nu.get_node_output(node, 0)[0]) return nu.get_node_output(node, 0)[0].type in OPERATIONS_WITH_WEIGHTS diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/fake_quantize_configuration.py b/tools/pot/openvino/tools/pot/algorithms/quantization/fake_quantize_configuration.py index 4642201b558d94..35733a07b84163 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/fake_quantize_configuration.py +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/fake_quantize_configuration.py @@ -528,7 +528,7 @@ def _get_node_valuable_descendant(node): def change_configurations_by_model_type(model, config, fq_configuration, hardware_config): - if config['model_type'] == 'transformer' and config['target_device'] in ['ANY', 'CPU', 'CPU_SPR', 'GPU', 'VPU']: + if config['model_type'] == 'transformer' and config['target_device'] in ['ANY', 'CPU', 'CPU_SPR', 'GPU', 'NPU']: change_configurations_by_model_type_transformer(model, fq_configuration, hardware_config) diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/utils.py b/tools/pot/openvino/tools/pot/algorithms/quantization/utils.py index 9ad333a72bfcf5..be69ad8bc637a2 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/utils.py +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/utils.py @@ -21,7 +21,7 @@ 'GNA3': 'gna3.json', 'GNA3.5': 'gna3.json', 'GPU': 'gpu.json', # Same as cpu.json but without LSTM/GRUSequence quantization - 'VPU': 'vpu.json', + 'NPU': 'npu.json', 'CPU_SPR': 'cpu.json'} diff --git a/tools/pot/openvino/tools/pot/configs/config.py b/tools/pot/openvino/tools/pot/configs/config.py index 9c55cbd8e4901a..0b5b41adc30bbf 100644 --- a/tools/pot/openvino/tools/pot/configs/config.py +++ b/tools/pot/openvino/tools/pot/configs/config.py @@ -347,7 +347,7 @@ def _configure_algo_params(self): aliases = {'symmetric': 'performance', 'asymmetric': 'accuracy'} preset = aliases.get(preset, preset) presets_aliases_by_device = { - 'VPU': {'accuracy': 'accuracy'}, + 'NPU': {'accuracy': 'accuracy'}, 'GNA': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, 'GNA3': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, 'GNA3.5': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, diff --git a/tools/pot/openvino/tools/pot/graph/vpu_patterns.py b/tools/pot/openvino/tools/pot/graph/npu_patterns.py similarity index 92% rename from tools/pot/openvino/tools/pot/graph/vpu_patterns.py rename to tools/pot/openvino/tools/pot/graph/npu_patterns.py index 5da9861a34ecbc..44a7012f19286d 100644 --- a/tools/pot/openvino/tools/pot/graph/vpu_patterns.py +++ b/tools/pot/openvino/tools/pot/graph/npu_patterns.py @@ -4,7 +4,7 @@ from openvino.tools.pot.graph.pattern_utils import get_clamp_mult_const_pattern, \ get_softmax_reshape_transpose_gather_matmul_pattern -def get_vpu_ignored_patterns(): +def get_npu_ignored_patterns(): return { 'blocks': [get_softmax_reshape_transpose_gather_matmul_pattern()], 'activations': [get_clamp_mult_const_pattern()], diff --git a/tools/pot/openvino/tools/pot/graph/utils.py b/tools/pot/openvino/tools/pot/graph/utils.py index 30844760d58348..1358c74ae9f2fc 100644 --- a/tools/pot/openvino/tools/pot/graph/utils.py +++ b/tools/pot/openvino/tools/pot/graph/utils.py @@ -10,7 +10,7 @@ from openvino.tools.pot.version import get_version from .cpu_patterns import get_cpu_ignored_patterns, get_cpu_spr_ignored_patterns from .gpu_patterns import get_gpu_ignored_patterns -from .vpu_patterns import get_vpu_ignored_patterns +from .npu_patterns import get_npu_ignored_patterns from .gna_patterns import get_gna_ignored_patterns, get_gna3_ignored_patterns from .special_operations import QUANTIZE_AGNOSTIC_OPERATIONS from .node_utils import get_all_node_outputs, get_input_shape @@ -19,7 +19,7 @@ 'ANY': get_cpu_ignored_patterns(), 'CPU': get_cpu_ignored_patterns(), 'GPU': get_gpu_ignored_patterns(), - 'VPU': get_vpu_ignored_patterns(), + 'NPU': get_npu_ignored_patterns(), 'GNA': get_gna_ignored_patterns(), 'GNA3': get_gna3_ignored_patterns(), 'GNA3.5': get_gna3_ignored_patterns(), diff --git a/tools/pot/tests/test_target_device.py b/tools/pot/tests/test_target_device.py index d42d294c8aedbc..2e6a8e429b1aa1 100644 --- a/tools/pot/tests/test_target_device.py +++ b/tools/pot/tests/test_target_device.py @@ -7,7 +7,7 @@ DEVICE = [ 'CPU', 'GPU', - 'VPU' + 'NPU' ] From 5386e11fe46bc5ea6fb5669a5eaee36fb5449498 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 01:53:11 +0400 Subject: [PATCH 15/51] Update pytest requirement in /src/bindings/python (#18232) Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/5.0.0...7.4.0) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ilya Lavrenov --- src/bindings/python/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings/python/constraints.txt b/src/bindings/python/constraints.txt index cabd454463101f..d4c8d587644996 100644 --- a/src/bindings/python/constraints.txt +++ b/src/bindings/python/constraints.txt @@ -2,7 +2,7 @@ numpy>=1.16.6,<1.26 # Python bindings, frontends # pytest -pytest>=5.0,<7.4 +pytest>=5.0,<7.5 pytest-dependency==0.5.1 pytest-html==3.2.0 pytest-timeout==2.1.0 From 575f497c8bd496c72be1f983961bdb9cb0ac0dd6 Mon Sep 17 00:00:00 2001 From: Roman Lyamin Date: Thu, 10 Aug 2023 04:50:49 +0400 Subject: [PATCH 16/51] [GPU] Fix data race in CompilationContext (#19103) --- src/plugins/intel_gpu/src/graph/compilation_context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/compilation_context.cpp b/src/plugins/intel_gpu/src/graph/compilation_context.cpp index 76bc86f48994f4..c1f483200c9a38 100644 --- a/src/plugins/intel_gpu/src/graph/compilation_context.cpp +++ b/src/plugins/intel_gpu/src/graph/compilation_context.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // - #include "compilation_context.hpp" #include #include @@ -22,9 +21,10 @@ class CompilationContext : public ICompilationContext { return; auto promise = std::make_shared>(); - futures.emplace_back(promise->get_future()); std::lock_guard lock(_mutex); + futures.emplace_back(promise->get_future()); + if (_task_keys.find(key) == _task_keys.end()) { _task_keys.insert(key); if (_task_executor != nullptr) { From f683fabcbf70981231eed7b830cb49a31cae1369 Mon Sep 17 00:00:00 2001 From: hyunback kim Date: Thu, 10 Aug 2023 10:58:57 +0900 Subject: [PATCH 17/51] [GPU] Add Disable Winograd convolution debug config. (#18701) Signed-off-by: hyunback --- .../include/intel_gpu/runtime/debug_configuration.hpp | 1 + src/plugins/intel_gpu/src/graph/layout_optimizer.cpp | 4 ++++ src/plugins/intel_gpu/src/runtime/debug_configuration.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp index ea632ee4ac584b..febf41a557f6e9 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp @@ -121,6 +121,7 @@ class debug_configuration { std::vector forced_impl_types; // Force implementation type either ocl or onednn int max_kernels_per_batch; // Maximum number of kernels in a batch during compiling kernels int disable_async_compilation; // Disable async compilation + int disable_winograd_conv; // Disable Winograd conv int disable_dynamic_impl; // Disable dynamic implementation int disable_runtime_buffer_fusing; // Disable runtime buffer fusing int disable_memory_reuse; // Disable memmory reuse among layers diff --git a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp index 00f75f37fb7765..005b9a218233a5 100644 --- a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp +++ b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp @@ -505,6 +505,10 @@ bool should_use_winograd_2x3_s1(const convolution_node& node, return false; // cases when NOT to use winograd + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->disable_winograd_conv == 1) + return false; + auto prim = node.get_primitive(); if (input_layout.data_type != data_types::f16 || input_layout.feature() % 64 != 0 // current algorithm is effective for ifm to be multiply of 64 diff --git a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp b/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp index 4e83f10924116f..084d0095dd27c3 100644 --- a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp +++ b/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp @@ -134,9 +134,12 @@ static void print_help_messages() { " For primitives fc, gemm, do, reduce, concat are supported. Separated by space."); message_list.emplace_back("OV_GPU_MaxKernelsPerBatch", "Maximum number of kernels in a batch during compiling kernels"); message_list.emplace_back("OV_GPU_DisableAsyncCompilation", "Disable async compilation"); + message_list.emplace_back("OV_GPU_DisableWinogradConv", "Disable Winograd convolution"); message_list.emplace_back("OV_GPU_DisableDynamicImpl", "Disable dynamic implementation"); message_list.emplace_back("OV_GPU_DisableRuntimeBufferFusing", "Disable runtime buffer fusing"); message_list.emplace_back("OV_GPU_DisableMemoryReuse", "Disable memory reuse"); + message_list.emplace_back("OV_GPU_DisableBuildTimeWeightReorderForDynamicNodes", "Disable build time weight reorder for dynmaic nodes."); + message_list.emplace_back("OV_GPU_DisableRuntimeSkipReorder", "Disable runtime skip reorder."); message_list.emplace_back("OV_GPU_DisablePrimitiveFusing", "Disable primitive fusing"); message_list.emplace_back("OV_GPU_DumpIteration", "Dump n-th execution of network, separated by space."); message_list.emplace_back("OV_GPU_MemPreallocationOptions", "Controls buffer pre-allocation feature. Expects 4 values separated by space in" @@ -188,6 +191,7 @@ debug_configuration::debug_configuration() , serialize_compile(0) , max_kernels_per_batch(0) , disable_async_compilation(0) + , disable_winograd_conv(0) , disable_dynamic_impl(0) , disable_runtime_buffer_fusing(0) , disable_memory_reuse(0) @@ -225,6 +229,7 @@ debug_configuration::debug_configuration() get_gpu_debug_env_var("ForceImplTypes", forced_impl_types_str); get_gpu_debug_env_var("MaxKernelsPerBatch", max_kernels_per_batch); get_gpu_debug_env_var("DisableAsyncCompilation", disable_async_compilation); + get_gpu_debug_env_var("DisableWinogradConv", disable_winograd_conv); get_gpu_debug_env_var("DisableDynamicImpl", disable_dynamic_impl); get_gpu_debug_env_var("DisableRuntimeBufferFusing", disable_runtime_buffer_fusing); get_gpu_debug_env_var("DisableMemoryReuse", disable_memory_reuse); From d91d72c89cad6d172cbc74faad48bfcd1b731c13 Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Thu, 10 Aug 2023 09:43:08 +0400 Subject: [PATCH 18/51] [GPU] RandomUniform new shape inference for dynamism support (#19087) --- .../intel_gpu/primitives/random_uniform.hpp | 27 +-- .../src/graph/include/random_uniform_inst.h | 13 ++ .../intel_gpu/src/graph/random_uniform.cpp | 57 ++++- .../src/plugin/ops/random_uniform.cpp | 38 +++- .../dynamic/random_uniform.cpp | 208 ++++++++++++++++++ .../shape_infer/random_uniform_si_test.cpp | 143 ++++++++++++ .../test_cases/random_uniform_gpu_test.cpp | 48 ++-- .../shared_test_classes/base/ov_subgraph.hpp | 2 + .../src/base/ov_subgraph.cpp | 18 +- .../src/single_layer/random_uniform.cpp | 12 +- 10 files changed, 505 insertions(+), 61 deletions(-) create mode 100644 src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/random_uniform.cpp create mode 100644 src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp index 3bdc74faea71d2..02c86cb80d0af1 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp @@ -20,8 +20,7 @@ struct random_uniform : public primitive_base { random_uniform() : primitive_base("", {}), global_seed(0), op_seed(0), - output_shape{}, - output_format(format::type::any) {} + output_shape{} {} DECLARE_OBJECT_TYPE_SERIALIZATION @@ -36,20 +35,26 @@ struct random_uniform : public primitive_base { */ random_uniform(const primitive_id &id, const std::vector &inputs, const data_types &data_type, const uint64_t global_seed, - const uint64_t op_seed, const tensor output_shape, - const format output_format, + const uint64_t op_seed, const ov::Shape output_shape, const padding &output_padding = padding()) : primitive_base(id, inputs, {output_padding}, {optional_data_type{data_type}}), global_seed(global_seed), op_seed(op_seed), - output_shape(output_shape), - output_format(output_format) {} + output_shape(output_shape) {} + + random_uniform(const primitive_id &id, const std::vector &inputs, + const data_types &data_type, const uint64_t global_seed, + const uint64_t op_seed, const padding &output_padding = padding()) + : primitive_base(id, inputs, {output_padding}, + {optional_data_type{data_type}}), + global_seed(global_seed), + op_seed(op_seed), + output_shape() {} const uint64_t global_seed; const uint64_t op_seed; - const tensor output_shape; - const format output_format; + const ov::Shape output_shape; size_t hash() const override { size_t seed = primitive::hash(); @@ -73,17 +78,13 @@ struct random_uniform : public primitive_base { ob << global_seed; ob << op_seed; ob << output_shape; - ob << make_data(&output_format.value, sizeof(format::type)); } void load(BinaryInputBuffer& ib) override { primitive_base::load(ib); ib >> *const_cast(&global_seed); ib >> *const_cast(&op_seed); - ib >> *const_cast(&output_shape); - format::type tmp_type = format::type::any; - ib >> make_data(&tmp_type, sizeof(format::type)); - *const_cast(&output_format) = format(tmp_type); + ib >> *const_cast(&output_shape); } }; diff --git a/src/plugins/intel_gpu/src/graph/include/random_uniform_inst.h b/src/plugins/intel_gpu/src/graph/include/random_uniform_inst.h index 4768a702d0833b..fa44522d019bee 100644 --- a/src/plugins/intel_gpu/src/graph/include/random_uniform_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/random_uniform_inst.h @@ -9,6 +9,17 @@ namespace cldnn { +template <> +struct typed_program_node : public typed_program_node_base { + using parent = typed_program_node_base; + +public: + using parent::parent; + + program_node& input(size_t index = 0) const { return get_dependency(index); } + std::vector get_shape_infer_dependencies() const override { return {0}; } +}; + using random_uniform_node = typed_program_node; template<> @@ -17,6 +28,8 @@ class typed_primitive_inst : public typed_primitive_inst_base + static std::vector calc_output_layouts(random_uniform_node const& /*node*/, const kernel_impl_params& impl_param); static layout calc_output_layout(random_uniform_node const &node, kernel_impl_params const& impl_param); static std::string to_string(random_uniform_node const &node); diff --git a/src/plugins/intel_gpu/src/graph/random_uniform.cpp b/src/plugins/intel_gpu/src/graph/random_uniform.cpp index 325f180608ca89..31ab7894ac760f 100644 --- a/src/plugins/intel_gpu/src/graph/random_uniform.cpp +++ b/src/plugins/intel_gpu/src/graph/random_uniform.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "random_uniform_inst.h" #include "primitive_type_base.h" -#include -#include -#include +#include "json_object.h" + +#include "random_uniform_shape_inference.hpp" namespace cldnn { GPU_DEFINE_PRIMITIVE_TYPE_ID(random_uniform) @@ -17,9 +17,56 @@ random_uniform_inst::typed_primitive_inst(network& network, random_uniform_node layout random_uniform_inst::calc_output_layout(random_uniform_node const &node, kernel_impl_params const& impl_param) { auto primitive = impl_param.typed_desc(); - return {*primitive->output_data_types[0], primitive->output_format, primitive->output_shape}; + auto format = format::get_default_format(primitive->output_shape.size()); + + return {primitive->output_shape, *primitive->output_data_types[0], format}; } +template +std::vector random_uniform_inst::calc_output_layouts(random_uniform_node const& /*node*/, kernel_impl_params const& impl_param) { + auto desc = impl_param.typed_desc(); + auto output_data_type = desc->output_data_types[0].value_or(impl_param.get_input_layout().data_type); + + std::vector output_shapes; + std::vector input_shapes = { impl_param.get_input_layout(0).get_partial_shape(), + impl_param.get_input_layout(1).get_partial_shape(), + impl_param.get_input_layout(2).get_partial_shape() }; + + auto& memory_deps = impl_param.memory_deps; + std::map const_data; + + auto run_shape_infer = [&]() { + ov::op::v8::RandomUniform op; + if (memory_deps.count(1) > 0 && memory_deps.count(2) > 0) { + auto min_val = memory_deps.at(1); + cldnn::mem_lock min_val_lock(min_val, impl_param.get_stream()); + const_data.emplace(1, make_host_tensor(min_val->get_layout(), min_val_lock.data())); + + auto max_val = memory_deps.at(2); + cldnn::mem_lock max_val_lock(max_val, impl_param.get_stream()); + const_data.emplace(2, make_host_tensor(max_val->get_layout(), max_val_lock.data())); + + return ov::op::v8::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); + } else { + return ov::op::v8::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); + } + }; + + if (memory_deps.count(0) > 0) { + auto output_shape = memory_deps.at(0); + cldnn::mem_lock output_shape_lock(output_shape, impl_param.get_stream()); + const_data.emplace(0, make_host_tensor(output_shape->get_layout(), output_shape_lock.data())); + + output_shapes = run_shape_infer(); + } else { + output_shapes = run_shape_infer(); + } + + return { layout{output_shapes[0], output_data_type, format::get_default_format(output_shapes[0].size())} }; +} + +template std::vector random_uniform_inst::calc_output_layouts(random_uniform_node const& node, const kernel_impl_params& impl_param); + std::string random_uniform_inst::to_string(random_uniform_node const &node) { auto node_info = node.desc_to_json(); json_composite random_uniform_info; diff --git a/src/plugins/intel_gpu/src/plugin/ops/random_uniform.cpp b/src/plugins/intel_gpu/src/plugin/ops/random_uniform.cpp index 18f7b7cc5089de..916c5520914d53 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/random_uniform.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/random_uniform.cpp @@ -15,17 +15,33 @@ namespace { void CreateRandomUniformOp(Program &p, const std::shared_ptr &op) { auto inputs = p.GetInputInfo(op); - auto output_shape = op->get_output_shape(0); - cldnn::format outputFormat = cldnn::format::get_default_format(output_shape.size()); - - auto random_uniform_prim = cldnn::random_uniform(layer_type_name_ID(op), - inputs, - cldnn::element_type_to_data_type(op->get_out_type()), - op->get_global_seed(), - op->get_op_seed(), - tensor_from_dims(output_shape), - outputFormat); - p.add_primitive(*op, random_uniform_prim); + auto input_pshape = op->get_input_partial_shape(0); + auto output_pshape = op->get_output_partial_shape(0); + + OPENVINO_ASSERT(input_pshape.is_static(), "[GPU] Dynamic input of RandomUniform leads to dynamic output rank, but GPU doesn't support it yet"); + + if (output_pshape.is_static() && !p.use_new_shape_infer()) { + auto output_shape = output_pshape.get_shape(); + // Extend to 4D shape + output_shape.insert(output_shape.end(), 4 - output_shape.size(), 1ul); + + auto random_uniform_prim = cldnn::random_uniform(layer_type_name_ID(op), + inputs, + cldnn::element_type_to_data_type(op->get_out_type()), + op->get_global_seed(), + op->get_op_seed(), + output_shape); + p.add_primitive(*op, random_uniform_prim); + } else { + OPENVINO_ASSERT(input_pshape.size() == 1, "[GPU] RandomUniform expects 1D input, got ", input_pshape.size()); + + auto random_uniform_prim = cldnn::random_uniform(layer_type_name_ID(op), + inputs, + cldnn::element_type_to_data_type(op->get_out_type()), + op->get_global_seed(), + op->get_op_seed()); + p.add_primitive(*op, random_uniform_prim); + } } } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/random_uniform.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/random_uniform.cpp new file mode 100644 index 00000000000000..de0a2321658e5e --- /dev/null +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/random_uniform.cpp @@ -0,0 +1,208 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph_functions/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" + +using namespace ngraph; +using namespace ov::test; + +namespace GPULayerTestsDefinitions { + +typedef std::tuple< + std::vector, // Input shapes + std::pair, // Min value, Max value + std::pair, // Global seed, operation seed + ElementType, // Network precision + TargetDevice, // Device name + std::map // Additional network configuration +> RandomUnifromDynamicGPUTestParamsSet; + +class RandomUnifromDynamicGPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + RandomUnifromDynamicGPUTestParamsSet basicParamsSet = obj.param; + std::ostringstream result; + std::vector input_shapes; + std::pair min_max_values; + std::pair seeds; + ElementType precision; + TargetDevice target_device; + std::map additionalConfig; + std::tie(input_shapes, min_max_values, seeds, precision, target_device, additionalConfig) = basicParamsSet; + + result << "shape="; + for (const auto& shape : input_shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + for (const auto& actual_shape : shape.second) { + result << ov::test::utils::partialShape2str({actual_shape}) << "_"; + } + } + result << "precision=" << precision << "_"; + result << "min_max_values=" << min_max_values.first << "_" << min_max_values.second << "_"; + result << "seeds=" << seeds.first << "_" << seeds.second << "_"; + result << "target_device=" << target_device; + return result.str(); + } + +protected: + void init_input_shapes(const std::vector& shapes) { + if (shapes.empty()) { + targetStaticShapes = {{}}; + return; + } + size_t targetStaticShapeSize = shapes.front().second.size(); + for (size_t i = 1; i < shapes.size(); ++i) { + if (targetStaticShapeSize < shapes[i].second.size()) { + targetStaticShapeSize = shapes[i].second.size(); + } + } + targetStaticShapes.resize(targetStaticShapeSize); + + for (const auto& shape : shapes) { + auto dynShape = shape.first; + inputDynamicShapes.push_back(dynShape); + for (size_t i = 0; i < targetStaticShapeSize; ++i) { + targetStaticShapes[i].push_back(i < shape.second.size() ? shape.second.at(i) : shape.second.back()); + } + } + } + + template + void set_tensor_value(T scalar, ov::Tensor& tensor) { + #define CASE(X) \ + case X: { \ + auto *dataPtr = tensor.data::value_type>(); \ + dataPtr[0] = static_cast::value_type>(scalar); \ + break; \ + } + + switch (tensor.get_element_type()) { + CASE(ElementType::boolean) + CASE(ElementType::i8) + CASE(ElementType::i16) + CASE(ElementType::i32) + CASE(ElementType::i64) + CASE(ElementType::u8) + CASE(ElementType::u16) + CASE(ElementType::u32) + CASE(ElementType::u64) + CASE(ElementType::bf16) + CASE(ElementType::f16) + CASE(ElementType::f32) + CASE(ElementType::f64) + CASE(ElementType::u1) + CASE(ElementType::i4) + CASE(ElementType::u4) + default: OPENVINO_THROW("Unsupported element type: ", tensor.get_element_type()); + } + } + + void generate_inputs(const std::vector& targetInputStaticShapes) override { + inputs.clear(); + const auto& funcInputs = function->inputs(); + + auto generate_input = [&](size_t index, ElementType element_type) { + ov::Tensor tensor(element_type, targetInputStaticShapes[index]); + if (index != 0) { + auto scalar_val = index == 1 ? min_max_values.first : min_max_values.second; + set_tensor_value(scalar_val, tensor); + } + inputs.insert({funcInputs[index].get_node_shared_ptr(), tensor}); + }; + + for (size_t i = 0; i < targetInputStaticShapes.size(); ++i) + generate_input(i, funcInputs[i].get_element_type()); + } + + void SetUp() override { + RandomUnifromDynamicGPUTestParamsSet basicParamsSet = this->GetParam(); + std::vector shapes; + ElementType netType; + std::map additionalConfig; + std::pair seeds; + + ov::ParameterVector params; + std::tie(shapes, min_max_values, seeds, netType, targetDevice, additionalConfig) = basicParamsSet; + + init_input_shapes(shapes); + + params = builder::makeDynamicParams(netType, inputDynamicShapes); + + const auto shape_of = std::make_shared(params[0]); + const auto random_uniform = std::make_shared(shape_of, params[1], params[2], netType, seeds.first, seeds.second); + + ov::ResultVector results = {std::make_shared(random_uniform)}; + function = std::make_shared(results, params, "random_uniform_test"); + } + + precisions_map get_ref_precisions_convert_map() override { + // Do not convert reference function from FP16 to FP32 precision, since in case of RandomUniform operation + // data type is matter + return {}; + } + +private: + std::pair min_max_values; +}; + + +TEST_P(RandomUnifromDynamicGPUTest, CompareWithRefs) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + run(); +} + +namespace { +std::map emptyAdditionalConfig; +const std::vector> dynInputShapes = { + { + {{ov::PartialShape::dynamic(4)}, {{1, 2, 3, 4}, {1, 1, 5, 5}, {2, 3, 4, 5}}}, + {{1}, {{1}}}, + {{1}, {{1}}} + }, + { + {{ov::PartialShape::dynamic(3)}, {{1, 2, 3}, {1, 1, 5}, {2, 3, 4}}}, + {{1}, {{1}}}, + {{1}, {{1}}} + }, + { + {{ov::PartialShape::dynamic(2)}, {{1, 2}, {1, 1}, {2, 3}}}, + {{1}, {{1}}}, + {{1}, {{1}}} + }, + { + {{ov::PartialShape::dynamic(1)}, {{1}, {2}, {3}}}, + {{1}, {{1}}}, + {{1}, {{1}}} + }, +}; + +const std::vector> min_max_values = { + {10, 30}, +}; + +const std::vector> seeds = { + {100, 10}, +}; + +const std::vector netPrecisions = { + ElementType::i32, + ElementType::f32, + ElementType::f16, +}; + +const auto testParams_smoke = ::testing::Combine(::testing::ValuesIn(dynInputShapes), + ::testing::ValuesIn(min_max_values), + ::testing::ValuesIn(seeds), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU), + ::testing::Values(emptyAdditionalConfig)); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_random_uniform, RandomUnifromDynamicGPUTest, + testParams_smoke, RandomUnifromDynamicGPUTest::getTestCaseName); + +} // namespace +} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp b/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp new file mode 100644 index 00000000000000..36a793b7ba3365 --- /dev/null +++ b/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp @@ -0,0 +1,143 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "test_utils.h" + +#include +#include +#include + +#include "random_uniform_inst.h" + +#include "program_wrapper.h" + +using namespace cldnn; +using namespace ::tests; + +namespace shape_infer_tests { + +struct random_uniform_si_test_params { + ov::PartialShape expected_out_pshape; + data_types out_data_type; + std::pair min_max_vals; +}; + +class random_uniform_si_test : public testing::TestWithParam { }; + +TEST_P(random_uniform_si_test, shape_infer) { + auto p = GetParam(); + auto& engine = get_test_engine(); + + cldnn::program prog(engine); + std::vector> input_prims; + std::vector input_prim_ids; + std::vector input_layouts; + const size_t num_inputs = 3; + + for (size_t idx = 0; idx < num_inputs; idx++) { + auto in_layout = layout{{1}, p.out_data_type, format::bfyx}; + if (idx == 0) { + auto input_pshape = ov::PartialShape{static_cast(p.expected_out_pshape.size())}; + in_layout = layout{input_pshape, data_types::i64, format::bfyx}; + } + input_layouts.push_back(in_layout); + + auto prim_id = "input_" + std::to_string(idx); + auto const_data_prim = std::make_shared(prim_id, in_layout); + input_prims.push_back(const_data_prim); + input_prim_ids.push_back(input_info(prim_id)); + } + + auto random_uniform_prim = std::make_shared("random_uniform", input_prim_ids, p.out_data_type, 0, 0); + auto& random_uniform_node = prog.get_or_create(random_uniform_prim); + + for (auto& iprim : input_prims) { + auto& input_node = prog.get_or_create(iprim); + program_wrapper::add_connection(prog, input_node, random_uniform_node); + } + + auto params = random_uniform_node.get_kernel_impl_params(); + params->memory_deps.clear(); + auto get_mem = [&](size_t idx, float val) -> memory::ptr { + auto in_layout = input_layouts[idx]; + auto allocated_mem = engine.allocate_memory(in_layout); + switch (p.out_data_type) { + case data_types::f16: + set_values(allocated_mem, {float_to_half(val)}); + break; + case data_types::f32: + set_values(allocated_mem, {static_cast::type>(val)}); + break; + case data_types::i32: + set_values(allocated_mem, {static_cast::type>(val)}); + break; + case data_types::i64: + set_values(allocated_mem, {static_cast::type>(val)}); + break; + case data_types::i8: + set_values(allocated_mem, {static_cast::type>(val)}); + break; + case data_types::u8: + set_values(allocated_mem, {static_cast::type>(val)}); + break; + case data_types::bin: + default: + break; + } + return allocated_mem; + }; + + if (p.expected_out_pshape.is_static()) { + auto input_mem = engine.allocate_memory(input_layouts[0]); + set_values(input_mem, p.expected_out_pshape.get_shape()); + params->memory_deps.emplace(0, input_mem); + } + + params->memory_deps.emplace(1, get_mem(1, p.min_max_vals.first)); + params->memory_deps.emplace(2, get_mem(2, p.min_max_vals.second)); + + if (p.min_max_vals.first < p.min_max_vals.second) { + auto res = random_uniform_inst::calc_output_layouts(random_uniform_node, *params); + + auto expected_out_layout = layout{p.expected_out_pshape, p.out_data_type, format::get_default_format(p.expected_out_pshape.size())}; + ASSERT_EQ(res.size(), 1); + ASSERT_EQ(res[0], expected_out_layout); + } else { + ASSERT_ANY_THROW(random_uniform_inst::calc_output_layouts(random_uniform_node, *params)); + } +} + +INSTANTIATE_TEST_SUITE_P(smoke, random_uniform_si_test, + testing::ValuesIn(std::vector{ + {ov::PartialShape{2}, data_types::i32, {0, 10}}, + {ov::PartialShape{2}, data_types::i8, {0, 10}}, + {ov::PartialShape{2}, data_types::u8, {0, 10}}, + {ov::PartialShape{2}, data_types::i64, {0, 10}}, + {ov::PartialShape{2}, data_types::i32, {0, 10}}, + {ov::PartialShape{2}, data_types::f32, {0, 10}}, + {ov::PartialShape{2}, data_types::f16, {0, 10}}, + {ov::PartialShape{2,4}, data_types::i32, {0, 10}}, + {ov::PartialShape{2,4}, data_types::f32, {0, 10}}, + {ov::PartialShape{2,4,3}, data_types::i32, {0, 10}}, + {ov::PartialShape{2,4,3}, data_types::f32, {0, 10}}, + {ov::PartialShape{2,4,3,2}, data_types::i32, {0, 10}}, + {ov::PartialShape{2,4,3,2}, data_types::f32, {0, 10}}, + {ov::PartialShape{2,4,3,1,2}, data_types::i32, {0, 10}}, + {ov::PartialShape{2,4,3,1,2}, data_types::f32, {0, 10}}, + + // Dynamic output shape + {ov::PartialShape::dynamic(1), data_types::f32, {0, 10}}, + {ov::PartialShape::dynamic(2), data_types::f32, {0, 10}}, + {ov::PartialShape::dynamic(3), data_types::f32, {0, 10}}, + {ov::PartialShape::dynamic(4), data_types::f32, {0, 10}}, + {ov::PartialShape::dynamic(5), data_types::f32, {0, 10}}, + + // Incorrect min/max values + {ov::PartialShape{2}, data_types::i32, {20, 20}}, + {ov::PartialShape{2,4,3,1,2}, data_types::i32, {20, 10}}, + {ov::PartialShape::dynamic(1), data_types::f32, {20, 20}}, + {ov::PartialShape::dynamic(5), data_types::f32, {20, 10}}, + })); + +}; // shape_infer_tests diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/random_uniform_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/random_uniform_gpu_test.cpp index f414c915e30b7e..62950ea1985cf5 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/random_uniform_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/random_uniform_gpu_test.cpp @@ -18,8 +18,7 @@ using namespace ::tests; */ template struct RandomUniformParams { - tensor output_tensor; - format f; + ov::Shape output_shape; T min_val; T max_val; uint64_t global_seed; @@ -36,20 +35,20 @@ struct random_uniform_gpu_test : public ::testing::TestWithParam params = testing::TestWithParam >::GetParam(); auto &engine = get_test_engine(); + auto format = format::get_default_format(params.output_shape.size()); auto shape = engine.allocate_memory( - {data_type, params.f, {1, 1, static_cast(params.output_tensor.sizes().size()), 1}}); + {{1, 1, 1, static_cast(params.output_shape.size())}, data_type, format}); auto min_val = engine.allocate_memory(layout(data_type, format::bfyx, {1, 1, 1, 1})); auto max_val = engine.allocate_memory(layout(data_type, format::bfyx, {1, 1, 1, 1})); - set_values(shape, params.output_tensor.sizes()); + set_values(shape, params.output_shape); set_values(min_val, {params.min_val}); set_values(max_val, {params.max_val}); topology topology; topology.add( random_uniform("random_uniform", { input_info("shape"), input_info("min_val"), input_info("max_val") }, data_type, params.global_seed, - params.op_seed, params.output_tensor, - params.f)); + params.op_seed, params.output_shape)); topology.add(input_layout("shape", shape->get_layout())); topology.add(input_layout("min_val", min_val->get_layout())); topology.add(input_layout("max_val", max_val->get_layout())); @@ -78,11 +77,11 @@ struct PrintToStringParamName { template std::string operator()(const testing::TestParamInfo > ¶m) { std::stringstream buf; - buf << " output tensor" << param.param.output_tensor.to_string() - << " min_value " << param.param.min_val - << " max_value " << param.param.max_val - << " global_seed " << param.param.global_seed - << " op_seed " << param.param.op_seed; + buf << "output_tensor_" << param.param.output_shape + << "_min_value_" << param.param.min_val + << "_max_value_" << param.param.max_val + << "_global_seed_" << param.param.global_seed + << "_op_seed_" << param.param.op_seed; return buf.str(); } @@ -91,11 +90,11 @@ struct PrintToStringParamName { template<> std::string PrintToStringParamName::operator()(const testing::TestParamInfo > ¶m) { std::stringstream buf; - buf << " output tensor" << param.param.output_tensor.to_string() - << " min_value " << static_cast(param.param.min_val) - << " max_value " << static_cast(param.param.max_val) - << " global_seed " << param.param.global_seed - << " op_seed " << param.param.op_seed; + buf << "output_tensor_" << param.param.output_shape + << "_min_value_" << static_cast(param.param.min_val) + << "_max_value_" << static_cast(param.param.max_val) + << "_global_seed_" << param.param.global_seed + << "_op_seed_" << param.param.op_seed; return buf.str(); } @@ -124,7 +123,7 @@ TEST_P(random_uniform_gpu_test_f16, random_f16) { INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_int32, random_uniform_gpu_test_i32, ::testing::Values( - RandomUniformParams{tensor(1, 1, 2, 3), format::bfyx, 50, 100, 80, 100, + RandomUniformParams{ov::Shape{1, 1, 3, 2}, 50, 100, 80, 100, std::vector{ 65, 70, 56, 59, 82, 92 @@ -135,7 +134,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_int32, INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_int64, random_uniform_gpu_test_i64, ::testing::Values( - RandomUniformParams{tensor(1, 1, 5, 4, 3), format::bfzyx, -2600, 3700, 755, + RandomUniformParams{ov::Shape{1, 1, 3, 4, 5}, -2600, 3700, 755, 951, { 2116L, -1581L, 2559L, -339L, -1660L, 519L, 90L, @@ -151,11 +150,17 @@ INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_int64, ), PrintToStringParamName()); - INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_f32, random_uniform_gpu_test_f32, ::testing::Values( - RandomUniformParams{tensor(1, 1, 3, 3), format::bfyx, 0.0, 1.0, 150, 10, + RandomUniformParams{ov::Shape{1, 1, 3, 3}, 0.0, 1.0, 150, 10, + { + 0.7011236, 0.30539632, 0.93931055, + 0.9456035, 0.11694777, 0.50770056, + 0.5197197, 0.22727466, 0.991374 + } + }, + RandomUniformParams{ov::Shape{3, 3}, 0.0, 1.0, 150, 10, { 0.7011236, 0.30539632, 0.93931055, 0.9456035, 0.11694777, 0.50770056, @@ -165,11 +170,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_f32, ), PrintToStringParamName()); - INSTANTIATE_TEST_SUITE_P(smoke_random_uniform_f16, random_uniform_gpu_test_f16, ::testing::Values( - RandomUniformParams{tensor(1, 1, 3, 2, 4), format::bfzyx, half_t(-1.5), + RandomUniformParams{ov::Shape{1, 1, 4, 2, 3}, half_t(-1.5), half_t(-1.0), 150, 10, {half_t(-1.19726562), half_t(-1.09667969), half_t(-1.08398438), half_t(-1.30859375), diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp index bca975fe636433..9ee6d25fc06c72 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp @@ -5,6 +5,7 @@ #pragma once #include "openvino/core/model.hpp" +#include "transformations/convert_precision.hpp" #include "common_test_utils/test_common.hpp" #include "functional_test_utils/ov_plugin_cache.hpp" @@ -69,6 +70,7 @@ class SubgraphBaseTest : public ov::test::TestsCommon { virtual std::vector calculate_refs(); virtual std::vector get_plugin_outputs(); + virtual precisions_map get_ref_precisions_convert_map(); friend void core_configuration(SubgraphBaseTest* test); }; diff --git a/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp b/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp index 3e49a6d3b06820..e1ac460de2e586 100644 --- a/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp +++ b/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp @@ -261,14 +261,12 @@ void SubgraphBaseTest::infer() { inferRequest.infer(); } -std::vector SubgraphBaseTest::calculate_refs() { - using InputsMap = std::map, ov::Tensor>; - - auto functionToProcess = functionRefs->clone(); +precisions_map SubgraphBaseTest::get_ref_precisions_convert_map() { //TODO: remove this conversions as soon as function interpreter fully support bf16 and f16 precisions_map precisions = { { ngraph::element::bf16, ngraph::element::f32 } }; + auto convert_added = false; for (const auto ¶m : function->get_parameters()) { for (size_t i = 0; i < param->get_output_size(); i++) { @@ -281,11 +279,21 @@ std::vector SubgraphBaseTest::calculate_refs() { } } } + if (!convert_added) { precisions.insert({ ngraph::element::f16, ngraph::element::f32}); } + + return precisions; +} + +std::vector SubgraphBaseTest::calculate_refs() { + using InputsMap = std::map, ov::Tensor>; + + auto functionToProcess = functionRefs->clone(); + precisions_map convert_precisions = get_ref_precisions_convert_map(); pass::Manager manager; - manager.register_pass(precisions); + manager.register_pass(convert_precisions); manager.run_passes(functionToProcess); functionToProcess->validate_nodes_and_infer_types(); diff --git a/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp b/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp index 122bb7d438d1bc..f4f97a53e3c8c0 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp @@ -63,13 +63,15 @@ void RandomUniformLayerTest::SetUp() { std::string targetName; std::tie(output_shape, randomUniformParams, global_seed, op_seed, targetDevice) = this->GetParam(); const auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(randomUniformParams.precision); - auto out_shape_ = std::make_shared(ov::element::i64, - ov::Shape{output_shape.size()}, - output_shape); + + // Use Parameter as input with desired precision to properly configure execution configuration + // in CoreConfiguration() function + auto input = std::make_shared(precision, output_shape); + auto shape_of = std::make_shared(input); auto min_value = createConstant(randomUniformParams.precision, randomUniformParams.min_value); auto max_value = createConstant(randomUniformParams.precision, randomUniformParams.max_value); - auto random_uniform = std::make_shared(out_shape_, + auto random_uniform = std::make_shared(shape_of, min_value, max_value, precision, @@ -77,7 +79,7 @@ void RandomUniformLayerTest::SetUp() { op_seed); ngraph::ResultVector results{std::make_shared(random_uniform)}; - function = std::make_shared(results, ngraph::ParameterVector{}, "random_uniform"); + function = std::make_shared(results, ngraph::ParameterVector{input}, "random_uniform"); } void RandomUniformLayerTest::ConvertRefsParams() { From 32a6a31de21a27ebbde6591e6702958c1c421e51 Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Thu, 10 Aug 2023 10:59:32 +0400 Subject: [PATCH 19/51] [GPU] Prevent Conv's input data type changing at reorder_inputs pass (#19042) --- .../graph_optimizer/add_required_reorders.cpp | 17 ++++++++-- .../src/graph/include/pass_manager.h | 2 +- .../passes/add_required_reorders_test.cpp | 31 +++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp index 5f39d55342b9cd..a11964c38787ae 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp @@ -27,11 +27,14 @@ If not than required reorder is added to the network. /* Add a reorder in between node and usr */ -void add_required_reorders::add_reorder(program& p, program_node* node, program_node* usr) { +void add_required_reorders::add_reorder(program& p, program_node* node, program_node* usr, bool keep_original_dt) { layout reorder_layout = node->get_output_layout(); reorder_layout.format = usr->get_output_layout().format; reorder_layout.data_type = usr->get_output_layout().data_type; + if (keep_original_dt) + reorder_layout.data_type = node->get_output_layout().data_type; + auto new_reorder = std::make_shared(node->id() + "_reorder_" + usr->id(), node->id(), reorder_layout); auto& new_reorder_node = p.get_or_create(new_reorder); new_reorder_node.set_output_layout(reorder_layout, false); @@ -376,8 +379,16 @@ void add_required_reorders::run(program& p) { continue; } - if (usr->get_output_layout() != node.first->get_output_layout()) - add_reorder(p, node.first, usr); + if (usr->get_output_layout() != node.first->get_output_layout()) { + // Preserve original data type to prevent Convolution input data type from changing + // in the following sequence: Node(U8, unsupported format) -> Conv(FP16, bfyx). + // Without this condition, inserted reorder will change Conv's input to FP16, instead of + // expected U8 format. + bool keep_original_dt = false; + if (usr->is_type()) + keep_original_dt = true; + add_reorder(p, node.first, usr, keep_original_dt); + } } } } diff --git a/src/plugins/intel_gpu/src/graph/include/pass_manager.h b/src/plugins/intel_gpu/src/graph/include/pass_manager.h index 2ea466764d5131..de9ec170096d22 100644 --- a/src/plugins/intel_gpu/src/graph/include/pass_manager.h +++ b/src/plugins/intel_gpu/src/graph/include/pass_manager.h @@ -57,7 +57,7 @@ class add_required_reorders : public base_pass { private: void run(program& p) override; - void add_reorder(program& p, program_node* node, program_node* usr); + void add_reorder(program& p, program_node* node, program_node* usr, bool keep_original_dt = false); }; class add_reshape_to_primitives : public base_pass { diff --git a/src/plugins/intel_gpu/tests/unit/passes/add_required_reorders_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/add_required_reorders_test.cpp index 75a955155ed45a..cb65717800d681 100644 --- a/src/plugins/intel_gpu/tests/unit/passes/add_required_reorders_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/passes/add_required_reorders_test.cpp @@ -116,6 +116,37 @@ TEST(add_required_reorders, eltwise_input_reorder) { ASSERT_EQ(eltwise_node.get_output_layout().format, format::bfzyx); } +TEST(add_required_reorders, prevent_input_dt_changing_for_convs) { + auto& engine = get_test_engine(); + + int input_b = 1, input_f = 16, input_y = 3, input_x = 3; + int output_b = input_b, output_f = 16, output_y = 6, output_x = 6; + + auto input_mem = engine.allocate_memory({ {input_b, input_f, input_y, input_x}, data_types::u8, format::bs_fs_yx_bsv16_fsv32 }); + auto input2_mem = engine.allocate_memory({ {input_b, input_f, input_y, input_x}, data_types::u8, format::bs_fs_yx_bsv16_fsv32 }); + auto weights_mem = engine.allocate_memory({ {16, 16, 1, 1}, data_types::i8, format::bfyx }); + + auto input = input_layout("input", input_mem->get_layout()); + auto input_const = data("input_const", input2_mem); + auto weights = data("weights", weights_mem); + auto eltwise1 = eltwise("eltwise1", input_info("input"), input_info("input_const"), eltwise_mode::sum); + auto conv1 = convolution("conv1", input_info("eltwise1"), "weights", "", 1, { 1, 1 }, { 1, 1 }, { 1, 1 }, { 2, 2 }, false); + auto output_reorder = reorder("reorder", input_info("conv1"), { data_types::f32, format::bfyx, { output_b, output_f, output_y, output_x } }); + + topology topology_test(input, input_const, eltwise1, weights, conv1, output_reorder); + + ExecutionConfig config_test = get_test_default_config(engine); + ov::intel_gpu::ImplementationDesc conv1_impl_test = { format::bfyx, "", impl_types::ocl }; + config_test.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ { "conv1", conv1_impl_test } })); + + auto prog = program::build_program(engine, topology_test, config_test, false, true); + program_wrapper::apply_opt_pass(*prog); + + ASSERT_NE(prog, nullptr); + ASSERT_TRUE(prog->has_node("conv1")); + ASSERT_EQ(prog->get_node("conv1").get_input_layout(0).data_type, data_types::u8); +} + TEST(add_required_reorders, skip_adding_reorder_batch_axis_padding) { auto& engine = get_test_engine(); From 9deef1480a6d4131deae89cbbeb295ac070e984c Mon Sep 17 00:00:00 2001 From: Eddy Kim Date: Thu, 10 Aug 2023 16:38:32 +0900 Subject: [PATCH 20/51] updated to init onednn attr (#19055) --- .../intel_gpu/src/graph/include/program_node.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/include/program_node.h b/src/plugins/intel_gpu/src/graph/include/program_node.h index b455b6e740b937..fb254ba757888d 100644 --- a/src/plugins/intel_gpu/src/graph/include/program_node.h +++ b/src/plugins/intel_gpu/src/graph/include/program_node.h @@ -386,8 +386,16 @@ struct program_node { std::vector& get_fused_primitives() { return fused_prims; } #ifdef ENABLE_ONEDNN_FOR_GPU - const std::shared_ptr& get_onednn_primitive_attributes() const { return onednn_attrs; } - std::shared_ptr& get_onednn_primitive_attributes() { return onednn_attrs; } + const std::shared_ptr& get_onednn_primitive_attributes() const { + if (onednn_attrs == nullptr) + const_cast(this)->init_onednn_primitive_attributes(); + return onednn_attrs; + } + std::shared_ptr& get_onednn_primitive_attributes() { + if (onednn_attrs == nullptr) + init_onednn_primitive_attributes(); + return onednn_attrs; + } const std::vector& get_fused_primitives_onednn() const { return fused_prims_onednn; } std::vector& get_fused_primitives_onednn() { return fused_prims_onednn; } From f5f221a3a9c97ac2bb160fc5be76b2e35f6d71e4 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Thu, 10 Aug 2023 10:28:36 +0200 Subject: [PATCH 21/51] [PT FE] Refactor aten::flatten and aten::transpose conversion (#19098) * [PT FE] Refactor aten::flatten and aten::transpose conversion * Fix code style * Fix codestyle --- .../pytorch/src/op/fake_quantize.cpp | 2 +- src/frontends/pytorch/src/op/flatten.cpp | 22 +++++-------------- src/frontends/pytorch/src/op/transpose.cpp | 11 ++-------- src/frontends/pytorch/src/op/unflatten.cpp | 6 +++-- src/frontends/pytorch/src/utils.cpp | 6 +---- src/frontends/pytorch/src/utils.hpp | 4 +--- src/frontends/pytorch/src/utils_quantize.cpp | 2 +- .../layer_tests/pytorch_tests/test_flatten.py | 4 +++- .../test_native_multi_head_attention.py | 6 ++--- 9 files changed, 21 insertions(+), 42 deletions(-) diff --git a/src/frontends/pytorch/src/op/fake_quantize.cpp b/src/frontends/pytorch/src/op/fake_quantize.cpp index fdb3548156b01f..0cc0113ded77c7 100644 --- a/src/frontends/pytorch/src/op/fake_quantize.cpp +++ b/src/frontends/pytorch/src/op/fake_quantize.cpp @@ -67,7 +67,7 @@ OutputVector translate_fake_quantize_per_channel_affine(const NodeContext& conte auto rank = std::get<1>(get_shape_rank(context, input_node)); auto ones = std::make_shared(const_1, rank); - auto normalized_axis = normalize_axis(context, axis, input_node); + auto normalized_axis = normalize_axis(context, axis, rank); // Create vector of length of rank filled with ones, except single -1 value at place selected by axis element. auto new_shape = std::make_shared(ones, normalized_axis, const_neg_1, const_0); // Reshape scale and zero point to tensor of the same rank as input, having shape 1 everywhere except dimension diff --git a/src/frontends/pytorch/src/op/flatten.cpp b/src/frontends/pytorch/src/op/flatten.cpp index 6022661c3aa8cf..3ff896cefd83d5 100644 --- a/src/frontends/pytorch/src/op/flatten.cpp +++ b/src/frontends/pytorch/src/op/flatten.cpp @@ -21,14 +21,6 @@ using namespace ov::op; OutputVector translate_flatten(const NodeContext& context) { num_inputs_check(context, 1, 3); auto x = context.get_input(0); - int64_t start_dim = 0; - int64_t end_dim = -1; - if (!context.input_is_none(1)) { - start_dim = context.const_input(1); - } - if (!context.input_is_none(2)) { - end_dim = context.const_input(2); - } Output shape; Output rank; std::tie(shape, rank) = get_shape_rank(context, x, true); @@ -38,20 +30,16 @@ OutputVector translate_flatten(const NodeContext& context) { if (!context.input_is_none(1)) { start_dim_node = context.get_input(1); } else { - start_dim_node = v0::Constant::create(element::i32, Shape{}, {start_dim}); + start_dim_node = v0::Constant::create(element::i32, Shape{}, {0}); } if (!context.input_is_none(2)) { end_dim_node = context.get_input(2); } else { - end_dim_node = v0::Constant::create(element::i32, Shape{}, {end_dim}); - } - if (start_dim < 0) { - start_dim_node = context.mark_node(std::make_shared(rank, start_dim_node)); - } - if (end_dim < 0) { - end_dim_node = context.mark_node(std::make_shared(rank, end_dim_node)); + end_dim_node = v0::Constant::create(element::i32, Shape{}, {-1}); } - // Slice shape from begin and end, then concat with -1, if slice return empty tensor concat shuold still be able to + start_dim_node = normalize_axis(context, start_dim_node, rank); + end_dim_node = normalize_axis(context, end_dim_node, rank); + // Slice shape from begin and end, then concat with -1, if slice return empty tensor concat should still be able to // work with it auto zero = v0::Constant::create(element::i32, Shape{1}, {0}); auto one = v0::Constant::create(element::i32, Shape{1}, {1}); diff --git a/src/frontends/pytorch/src/op/transpose.cpp b/src/frontends/pytorch/src/op/transpose.cpp index 51fd4c3eae6457..3ea5ef17283ffe 100644 --- a/src/frontends/pytorch/src/op/transpose.cpp +++ b/src/frontends/pytorch/src/op/transpose.cpp @@ -24,19 +24,12 @@ using namespace ov::op; OutputVector translate_transpose(const NodeContext& context) { num_inputs_check(context, 3, 3); - auto dim0 = context.const_input(1); - auto dim1 = context.const_input(2); Output rank; std::tie(std::ignore, rank) = get_shape_rank(context, context.get_input(0), true); - // Use opset::If for dim normalization auto dim0_node = context.get_input(1); auto dim1_node = context.get_input(2); - if (dim0 < 0) { - dim0_node = std::make_shared(rank, dim0_node); - } - if (dim1 < 0) { - dim1_node = std::make_shared(rank, dim1_node); - } + dim0_node = normalize_axis(context, dim0_node, rank); + dim1_node = normalize_axis(context, dim1_node, rank); auto start = v0::Constant::create(element::i32, {}, {0}); auto step = v0::Constant::create(element::i32, {}, {1}); auto range = std::make_shared(start, rank, step, element::i32); diff --git a/src/frontends/pytorch/src/op/unflatten.cpp b/src/frontends/pytorch/src/op/unflatten.cpp index 673efbc1480161..a913398eb35a51 100644 --- a/src/frontends/pytorch/src/op/unflatten.cpp +++ b/src/frontends/pytorch/src/op/unflatten.cpp @@ -28,11 +28,13 @@ OutputVector translate_unflatten(const NodeContext& context) { if (context.get_input_type(2).is()) { sizes = concat_list_construct(sizes); } - auto input_shape = context.mark_node(std::make_shared(input, element::i32)); + Output input_shape; + Output rank; + std::tie(input_shape, rank) = get_shape_rank(context, input); auto zero_1d = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0})); auto one_1d = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1})); dim = context.mark_node(std::make_shared(dim, element::i32)); - dim = normalize_axis(context, dim, input); + dim = normalize_axis(context, dim, rank); sizes = context.mark_node(std::make_shared(sizes, element::i32)); auto max_int = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {std::numeric_limits::max()})); auto dim_plus_one = context.mark_node(std::make_shared(dim, one_1d)); diff --git a/src/frontends/pytorch/src/utils.cpp b/src/frontends/pytorch/src/utils.cpp index 929ac8b251d454..2c26feee8981ff 100644 --- a/src/frontends/pytorch/src/utils.cpp +++ b/src/frontends/pytorch/src/utils.cpp @@ -117,11 +117,7 @@ std::shared_ptr get_axes_range(const NodeContext& context, int input_id) { return context.mark_node(std::make_shared(start, reduced_rank, step, element::i32)); }; -std::shared_ptr normalize_axis(const NodeContext& context, - const Output& axis, - const Output& input_node) { - Output rank; - std::tie(std::ignore, rank) = get_shape_rank(context, input_node); +Output normalize_axis(const NodeContext& context, const Output& axis, const Output& rank) { auto axis_rank = context.mark_node(std::make_shared(axis, rank)); auto is_less = context.mark_node(std::make_shared(axis_rank, rank)); auto new_axis = context.mark_node(std::make_shared(is_less, axis_rank, axis)); diff --git a/src/frontends/pytorch/src/utils.hpp b/src/frontends/pytorch/src/utils.hpp index 175f80e77d9181..565476e7974ad8 100644 --- a/src/frontends/pytorch/src/utils.hpp +++ b/src/frontends/pytorch/src/utils.hpp @@ -39,9 +39,7 @@ Output reshape_kernel_for_group(const NodeContext& context, const Output get_axes_range(const NodeContext& context, int input_id); -std::shared_ptr normalize_axis(const NodeContext& context, - const Output& axis, - const Output& input_node); +Output normalize_axis(const NodeContext& context, const Output& axis, const Output& input_node); std::shared_ptr numel(const NodeContext& context, const Output& x); diff --git a/src/frontends/pytorch/src/utils_quantize.cpp b/src/frontends/pytorch/src/utils_quantize.cpp index aee7d74eca9c51..5af546f3d5be5d 100644 --- a/src/frontends/pytorch/src/utils_quantize.cpp +++ b/src/frontends/pytorch/src/utils_quantize.cpp @@ -90,7 +90,7 @@ Output quantize(const NodeContext& context, const auto rank = std::get<1>(get_shape_rank(context, input_convert, false, element::i32)); const auto ones = context.mark_node(std::make_shared(one, rank)); - const auto normalized_axis = normalize_axis(context, axis_convert, input_convert); + const auto normalized_axis = normalize_axis(context, axis_convert, rank); const auto new_shape = context.mark_node(std::make_shared(ones, normalized_axis, neg_one, zero)); diff --git a/tests/layer_tests/pytorch_tests/test_flatten.py b/tests/layer_tests/pytorch_tests/test_flatten.py index 1702d3bf525038..31345dc749df52 100644 --- a/tests/layer_tests/pytorch_tests/test_flatten.py +++ b/tests/layer_tests/pytorch_tests/test_flatten.py @@ -27,7 +27,9 @@ def forward(self, x): return aten_flatten(dim0, dim1), ref_net, "aten::flatten" - @pytest.mark.parametrize("dim0,dim1", [[0, 1], + @pytest.mark.parametrize("dim0,dim1", [[0, -1], + [-2, -1], + [0, 1], [0, 2], [0, 3], [1, 2], diff --git a/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py b/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py index 95304109604b97..41e737dba6221d 100644 --- a/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py +++ b/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py @@ -31,13 +31,13 @@ def __init__(self, mask, need_weights, average_attn_weights) -> None: # Float masks raise a warning in PyTorch and are (incorrectly) converted to bool, # which later returns NaNs as MHA's output if mask == 0: - self.mask = torch.from_numpy(np.random.randint(0, 2, (SEQ_LENGTH, SEQ_LENGTH)).astype(np.bool)) + self.mask = torch.from_numpy(np.random.randint(0, 2, (SEQ_LENGTH, SEQ_LENGTH)).astype("bool")) self.mask_type = 0 elif mask == 1: - self.mask = torch.from_numpy(np.random.randint(0, 2, (BATCH_SIZE, SEQ_LENGTH)).astype(np.bool)) + self.mask = torch.from_numpy(np.random.randint(0, 2, (BATCH_SIZE, SEQ_LENGTH)).astype("bool")) self.mask_type = 1 elif mask == 2: - self.mask = torch.from_numpy(np.random.randint(0, 2, (BATCH_SIZE, NUM_HEADS, SEQ_LENGTH, SEQ_LENGTH)).astype(np.bool)) + self.mask = torch.from_numpy(np.random.randint(0, 2, (BATCH_SIZE, NUM_HEADS, SEQ_LENGTH, SEQ_LENGTH)).astype("bool")) self.mask_type = 2 else: self.mask = None From 6b9ab0c21ec59d98413cd1efd67e814943b290b1 Mon Sep 17 00:00:00 2001 From: HARI CHAND BALASUBRAMANIAM Date: Thu, 10 Aug 2023 17:37:51 +0800 Subject: [PATCH 22/51] Create build.yml (#18928) * Create build.yml Build issue template for customers to report any build or installation-related issue. * Update build.yml amended as suggested --- .github/ISSUE_TEMPLATE/build.yml | 95 ++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/build.yml diff --git a/.github/ISSUE_TEMPLATE/build.yml b/.github/ISSUE_TEMPLATE/build.yml new file mode 100644 index 00000000000000..d65a546dac2027 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/build.yml @@ -0,0 +1,95 @@ +name: Build Issue Report +description: This report is for the build/installation issue +title: "[Build]: " +labels: ["build", "support_request"] +body: + - type: markdown + attributes: + value: | + Please provide all the necessary information to expedite the response. + - type: input + id: ov_version + attributes: + label: OpenVINO Version + description: OpenVINO version, branch, or tag in OpenVINO GitHub + placeholder: 2021.4.0 LTS / Master Branch / tag 2022.3.0 + validations: + required: true + - type: dropdown + id: os + attributes: + label: Operating System + description: What OS are you using? + options: + - Ubuntu 18.04 (LTS) + - Ubuntu 20.04 (LTS) + - Ubuntu 22.04 (LTS) + - Windows System + - Red Hat Enterprise Linux 8 + - OpenSUSE + - Android System + - Raspbian Stretch OS + - macOS Systems for Intel CPU + - macOS Systems for Apple Silicon + - WebAssembly + - WSL2 for Windows + - Other (Please specify in description) + validations: + required: true + - type: dropdown + id: architecture + attributes: + label: Hardware Architecture + description: What is your hardware architecture used in this test? + options: + - x86 (64 bits) + - x86 (32 bits) + - ARM (64 bits) + - ARM (32 bits) + - RISC-V + - Other (please specify in the description) + validations: + required: true + - type: textarea + id: target_platform + attributes: + label: Target Platform + description: | + You can also provide us full system log with the following command + Windows cmd - "systeminfo" + Linux terminal - "lscpu" and "lscpu -e" + placeholder: Paste your full platform/system information here + validations: + required: false + - type: textarea + id: build_description + attributes: + label: Build issue description + description: What issue are you facing during the build/installation? + placeholder: Please provide a detailed description of what happened + validations: + required: true + - type: textarea + id: build_script + attributes: + label: Build scrip or step-by-step to reproduce + description: How can we reproduce your issue? + placeholder: Please provide detailed instructions on how to reproduce the issue + validations: + required: false + - type: textarea + id: build_logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so there is no need for backticks. + render: shell + - type: checkboxes + id: terms + attributes: + label: Issue submission checklist + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/intel/intel-one-mono/blob/main/CODE_OF_CONDUCT.md) + options: + - label: I report the issue. It's not a question + required: true + - label: I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found the solution + required: true From 7d192c923931cc13ec5d6d0cbf26467dcc0557b2 Mon Sep 17 00:00:00 2001 From: Zhang Yi Date: Thu, 10 Aug 2023 17:38:16 +0800 Subject: [PATCH 23/51] Update mlas with i32 build fix (#19107) --- src/plugins/intel_cpu/thirdparty/mlas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/thirdparty/mlas b/src/plugins/intel_cpu/thirdparty/mlas index 1d68240b511432..c215a2c97b47ed 160000 --- a/src/plugins/intel_cpu/thirdparty/mlas +++ b/src/plugins/intel_cpu/thirdparty/mlas @@ -1 +1 @@ -Subproject commit 1d68240b5114326604c3f5af47ac1c098e30b254 +Subproject commit c215a2c97b47ed01be7675f75bc463c820ac6e6d From cde08932710b566454dbf4046523582b29ec857c Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Thu, 10 Aug 2023 13:43:45 +0400 Subject: [PATCH 24/51] [GPU] Use ov::Tensor intead of ngraph::HostTensor (#18925) --- .../include/tensor_data_accessor.hpp | 3 + .../include/intel_gpu/runtime/memory.hpp | 14 --- .../intel_gpu/runtime/tensor_accessor.hpp | 89 +++++++++++++++++ .../intel_gpu/src/graph/CMakeLists.txt | 3 +- .../intel_gpu/src/graph/arg_max_min.cpp | 8 +- .../intel_gpu/src/graph/batch_to_space.cpp | 14 +-- src/plugins/intel_gpu/src/graph/border.cpp | 95 +++++++----------- src/plugins/intel_gpu/src/graph/broadcast.cpp | 9 +- src/plugins/intel_gpu/src/graph/crop.cpp | 10 +- src/plugins/intel_gpu/src/graph/gather.cpp | 4 +- .../intel_gpu/src/graph/impls/cpu/range.cpp | 8 +- .../src/graph/include/primitive_inst.h | 1 + .../src/graph/non_max_suppression.cpp | 4 +- src/plugins/intel_gpu/src/graph/one_hot.cpp | 4 +- src/plugins/intel_gpu/src/graph/prior_box.cpp | 4 +- .../intel_gpu/src/graph/random_uniform.cpp | 8 +- src/plugins/intel_gpu/src/graph/range.cpp | 8 +- src/plugins/intel_gpu/src/graph/reduce.cpp | 4 +- src/plugins/intel_gpu/src/graph/reshape.cpp | 6 +- .../intel_gpu/src/graph/space_to_batch.cpp | 14 +-- .../intel_gpu/src/graph/strided_slice.cpp | 14 +-- .../tests/unit/shape_infer/pad_si_test.cpp | 98 +++++++++++++++++-- 22 files changed, 274 insertions(+), 148 deletions(-) create mode 100644 src/plugins/intel_gpu/include/intel_gpu/runtime/tensor_accessor.hpp diff --git a/src/core/shape_inference/include/tensor_data_accessor.hpp b/src/core/shape_inference/include/tensor_data_accessor.hpp index 41c48641ad9ab2..300d859561b6da 100644 --- a/src/core/shape_inference/include/tensor_data_accessor.hpp +++ b/src/core/shape_inference/include/tensor_data_accessor.hpp @@ -18,6 +18,9 @@ class ITensorAccessor { * @return Tensor to data at port. */ virtual Tensor operator()(size_t port) const = 0; + +protected: + ~ITensorAccessor() = default; }; /** diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp index 2e6ceedbee7105..647a10581b4b65 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp @@ -9,8 +9,6 @@ #include "event.hpp" #include "engine_configuration.hpp" -#include "ngraph/runtime/host_tensor.hpp" - #include #ifdef ENABLE_ONEDNN_FOR_GPU @@ -247,16 +245,4 @@ inline std::vector read_vector(cldnn::memory::ptr mem, const cldnn::stream& s return out_vecs; } -inline std::shared_ptr make_host_tensor(layout l, void* memory_pointer) { - ov::element::Type et = data_type_to_element_type(l.data_type); - - return std::make_shared(et, l.get_shape(), memory_pointer); -} - -inline ov::Tensor make_tensor(layout l, void* memory_pointer) { - ov::element::Type et = data_type_to_element_type(l.data_type); - - return ov::Tensor(et, l.get_shape(), memory_pointer); -} - } // namespace cldnn diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor_accessor.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor_accessor.hpp new file mode 100644 index 00000000000000..1072c1bdf7fe80 --- /dev/null +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor_accessor.hpp @@ -0,0 +1,89 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/runtime/tensor.hpp" +#include "tensor_data_accessor.hpp" + +#include "memory.hpp" +#include "layout.hpp" + +namespace cldnn { + +inline ov::Tensor make_tensor(const layout& l, void* memory_pointer) { + ov::element::Type et = data_type_to_element_type(l.data_type); + + return ov::Tensor(et, l.get_shape(), memory_pointer); +} + +struct TensorsContainer final { + using MemoryMap = std::unordered_map; + using TensorsMap = std::unordered_map; + + TensorsContainer(const cldnn::stream* stream, const std::map& deps_map = {}) + : m_stream(stream) + , m_memories(deps_map.begin(), deps_map.end()) { } + + ~TensorsContainer() { + for (auto& port : m_locked_memories) { + m_memories.at(port)->unlock(*m_stream); + } + } + + void emplace(size_t port, cldnn::memory::ptr mem) { + m_memories.emplace(port, mem); + } + + void emplace(size_t port, const ov::Tensor& tensor) { + auto res = m_tensors.emplace(port, tensor); + OPENVINO_ASSERT(res.first != m_tensors.end()); + } + + template + void emplace(size_t port, std::vector& vector, data_types dt = data_types::i64) { + ov::Shape shape{vector.size()}; + auto tensor = make_tensor({shape, dt, format::bfyx}, static_cast(vector.data())); + m_tensors.emplace(port, tensor); + } + + size_t size() const { return m_tensors.size(); } + ov::Tensor operator[](std::size_t port) const { + if (m_memories.count(port) > 0) { + m_locked_memories.insert(port); + auto mem = m_memories.at(port); + auto ptr = mem->lock(*m_stream, cldnn::mem_lock_type::read); + return make_tensor(mem->get_layout(), ptr); + } else if (m_tensors.count(port) > 0) { + return m_tensors.at(port); + } else { + OPENVINO_THROW("[GPU] Can't get tensor for ", port, " port!\n"); + } + } + +private: + const cldnn::stream* m_stream; + MemoryMap m_memories; + TensorsMap m_tensors; + + mutable std::set m_locked_memories = {}; +}; + +class TensorAccessor final : public ov::ITensorAccessor { +public: + explicit TensorAccessor(const TensorsContainer& container) : m_container(container) { } + + ov::Tensor operator()(size_t port) const override { + return m_container[port]; + } + +private: + const TensorsContainer& m_container; +}; + +inline cldnn::TensorAccessor make_tensor_accessor(const TensorsContainer& c) { + return cldnn::TensorAccessor(c); +} + +} // namespace cldnn diff --git a/src/plugins/intel_gpu/src/graph/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/CMakeLists.txt index efefc017cc6a0e..1f46bdfa82bb48 100644 --- a/src/plugins/intel_gpu/src/graph/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/graph/CMakeLists.txt @@ -33,10 +33,9 @@ target_include_directories(${TARGET_NAME} PUBLIC target_compile_options(${TARGET_NAME} PRIVATE $<$:$,/Os,-Os>>) -target_link_libraries(${TARGET_NAME} PUBLIC OpenCL::OpenCL) +target_link_libraries(${TARGET_NAME} PUBLIC OpenCL::OpenCL ov_shape_inference) target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_kernels openvino_intel_gpu_runtime - ov_shape_inference openvino::itt openvino::runtime::dev openvino::runtime) diff --git a/src/plugins/intel_gpu/src/graph/arg_max_min.cpp b/src/plugins/intel_gpu/src/graph/arg_max_min.cpp index 28e3d41cae04d4..47303ece86cd82 100644 --- a/src/plugins/intel_gpu/src/graph/arg_max_min.cpp +++ b/src/plugins/intel_gpu/src/graph/arg_max_min.cpp @@ -87,17 +87,17 @@ std::vector arg_max_min_inst::calc_output_layouts(arg_max_min_node const auto& constant_mem = impl_param.memory_deps; if (desc->top_k > 0) { - std::map const_data; + std::unordered_map const_data; auto topk = desc->top_k; - auto top_k_tensor = std::make_shared(ov::element::u32, ov::Shape{1}, static_cast(&topk)); + auto top_k_tensor = ov::Tensor(ov::element::u32, ov::Shape{1}, static_cast(&topk)); const_data = { {1, top_k_tensor} }; output_shapes = ov::op::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else if (constant_mem.count(1)) { - std::map const_data; + std::unordered_map const_data; auto target_shape_mem = constant_mem.at(1); cldnn::mem_lock target_shape_lock(target_shape_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(target_shape_mem->get_layout(), target_shape_lock.data())); + const_data.emplace(1, make_tensor(target_shape_mem->get_layout(), target_shape_lock.data())); output_shapes = ov::op::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else { diff --git a/src/plugins/intel_gpu/src/graph/batch_to_space.cpp b/src/plugins/intel_gpu/src/graph/batch_to_space.cpp index 59f51491e26212..b09f2bab6b9bbd 100644 --- a/src/plugins/intel_gpu/src/graph/batch_to_space.cpp +++ b/src/plugins/intel_gpu/src/graph/batch_to_space.cpp @@ -112,7 +112,7 @@ std::vector batch_to_space_inst::calc_output_layouts(batch_to_space_node end_shape }; - std::map const_data; + std::unordered_map const_data; if (desc->shape_constant) { auto block_sizes = tensor_to_vec(block_data, input0_format); auto begin_sizes = tensor_to_vec(begin_data, input0_format); @@ -122,9 +122,9 @@ std::vector batch_to_space_inst::calc_output_layouts(batch_to_space_node auto begin_values = static_cast(begin_sizes.data()); auto end_values = static_cast(end_sizes.data()); - auto block_tensor = make_host_tensor({ block_shape, data_types::i32, input0_format }, block_values); - auto begin_tensor = make_host_tensor({ begin_shape, data_types::i32, input0_format }, begin_values); - auto end_tensor = make_host_tensor({ end_shape, data_types::i32, input0_format }, end_values); + auto block_tensor = make_tensor({ block_shape, data_types::i32, input0_format }, block_values); + auto begin_tensor = make_tensor({ begin_shape, data_types::i32, input0_format }, begin_values); + auto end_tensor = make_tensor({ end_shape, data_types::i32, input0_format }, end_values); const_data.emplace(1, block_tensor); const_data.emplace(2, begin_tensor); @@ -140,9 +140,9 @@ std::vector batch_to_space_inst::calc_output_layouts(batch_to_space_node cldnn::mem_lock lock2(begin_mem, impl_param.get_stream()); cldnn::mem_lock lock3(end_mem, impl_param.get_stream()); - auto block_tensor = make_host_tensor(block_mem->get_layout(), lock1.data()); - auto begin_tensor = make_host_tensor(begin_mem->get_layout(), lock2.data()); - auto end_tensor = make_host_tensor(end_mem->get_layout(), lock3.data()); + auto block_tensor = make_tensor(block_mem->get_layout(), lock1.data()); + auto begin_tensor = make_tensor(begin_mem->get_layout(), lock2.data()); + auto end_tensor = make_tensor(end_mem->get_layout(), lock3.data()); const_data.emplace(1, block_tensor); const_data.emplace(2, begin_tensor); diff --git a/src/plugins/intel_gpu/src/graph/border.cpp b/src/plugins/intel_gpu/src/graph/border.cpp index 2f5eef40093c4d..2e662781b01d4a 100644 --- a/src/plugins/intel_gpu/src/graph/border.cpp +++ b/src/plugins/intel_gpu/src/graph/border.cpp @@ -3,6 +3,7 @@ // #include "border_inst.h" +#include "intel_gpu/runtime/tensor_accessor.hpp" #include "pad_shape_inference.hpp" #include "intel_gpu/runtime/error_handler.hpp" @@ -41,85 +42,55 @@ std::vector border_inst::calc_output_layouts(border_node const& /*node*/ output_type = impl_param.get_fused_output_layout().data_type; } + size_t in_rank = input0_layout.get_partial_shape().size(); + ov::op::v1::Pad op; op.set_pad_mode(desc->pad_mode); const bool is_begin_mem = (desc->non_constant_input_mask & border::PAD_NON_CONST_INPUT::BEGIN); const bool is_end_mem = (desc->non_constant_input_mask & border::PAD_NON_CONST_INPUT::END); - layout pads_begin_layout, pads_end_layout; - if (is_begin_mem) { - pads_begin_layout = impl_param.get_input_layout(1); - } - if (is_end_mem) { - pads_end_layout = is_begin_mem ? impl_param.get_input_layout(2) : impl_param.get_input_layout(1); + const size_t begin_mem_idx = is_begin_mem ? 1 : 0; + const size_t end_mem_idx = is_begin_mem ? 2 : 1; + + auto& memory_deps = impl_param.memory_deps; + if ((is_begin_mem && memory_deps.count(begin_mem_idx) == 0) || + (is_end_mem && memory_deps.count(end_mem_idx) == 0)) { + return {layout{ShapeType::dynamic(static_cast(in_rank)), input0_layout.data_type, input0_layout.format}}; } - ShapeType pads_begin_shape = is_begin_mem ? pads_begin_layout.get() : ov::Shape{ desc->pads_begin.size() }; - ShapeType pads_end_shape = is_end_mem ? pads_end_layout.get() : ov::Shape{ desc->pads_end.size() }; - std::vector output_shapes; + int64_t begin_size = desc->pads_begin.size(); + int64_t end_size = desc->pads_end.size(); + + layout pads_begin_layout = is_begin_mem ? impl_param.get_input_layout(begin_mem_idx) : layout({ begin_size }, data_types::i64, format::bfyx); + layout pads_end_layout = is_end_mem ? impl_param.get_input_layout(end_mem_idx) : layout({ end_size }, data_types::i64, format::bfyx); + std::vector input_shapes = { input0_layout.get(), - pads_begin_shape, - pads_end_shape, + pads_begin_layout.get(), + pads_end_layout.get(), }; - auto& memory_deps = impl_param.memory_deps; - std::map const_data; - auto ta = ov::make_tensor_accessor(const_data); - - if ((is_begin_mem && memory_deps.count(1)) && (is_end_mem && memory_deps.count(2))) { - auto pads_begin_mem = memory_deps.at(1); - cldnn::mem_lock pads_begin_lock(pads_begin_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(pads_begin_mem->get_layout(), pads_begin_lock.data())); - - auto pads_end_mem = memory_deps.at(2); - cldnn::mem_lock pads_end_lock(pads_end_mem, impl_param.get_stream()); - const_data.emplace(2, make_host_tensor(pads_end_mem->get_layout(), pads_end_lock.data())); - - output_shapes = ov::op::shape_infer(&op, input_shapes, ta); - } else if ((is_begin_mem || is_end_mem) && memory_deps.count(1)) { - if (is_begin_mem) { - auto pads_begin_mem = memory_deps.at(1); - cldnn::mem_lock pads_begin_lock(pads_begin_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(pads_begin_mem->get_layout(), pads_begin_lock.data())); - - auto pads_end_data = desc->pads_end; - auto pads_end_tensor = make_host_tensor({pads_end_shape, data_types::i64, format::bfyx}, static_cast(pads_end_data.data())); - const_data.emplace(2, pads_end_tensor); - - output_shapes = ov::op::shape_infer(&op, input_shapes, ta); - } else { - auto pads_begin_data = desc->pads_begin; - auto pads_begin_tensor = make_host_tensor({pads_begin_shape, data_types::i64, format::bfyx}, static_cast(pads_begin_data.data())); - const_data.emplace(1, pads_begin_tensor); - - auto pads_end_mem = memory_deps.at(1); - cldnn::mem_lock pads_end_lock(pads_end_mem, impl_param.get_stream()); - const_data.emplace(2, make_host_tensor(pads_end_mem->get_layout(), pads_end_lock.data())); - - output_shapes = ov::op::shape_infer(&op, input_shapes, ta); - } - } else { - std::ptrdiff_t val = desc->pad_value; + TensorsContainer const_data(&impl_param.get_stream()); - auto pads_begin_data = desc->pads_begin; - if (is_begin_mem && desc->pad_mode == ov::op::PadMode::CONSTANT) { - pads_begin_data = {val, val, val, val}; - } - auto pads_begin_tensor = make_host_tensor({pads_begin_shape, data_types::i64, format::bfyx}, static_cast(pads_begin_data.data())); - const_data.emplace(1, pads_begin_tensor); + auto pads_begin_data = desc->pads_begin; + auto pads_end_data = desc->pads_end; - auto pads_end_data = desc->pads_end; - if (is_end_mem && desc->pad_mode == ov::op::PadMode::CONSTANT) { - pads_end_data = {val, val, val, val}; - } - auto pads_end_tensor = make_host_tensor({pads_end_shape, data_types::i64, format::bfyx}, static_cast(pads_end_data.data())); - const_data.emplace(2, pads_end_tensor); + if (is_begin_mem) { + const_data.emplace(1, memory_deps.at(begin_mem_idx)); + } else { + const_data.emplace(1, make_tensor(pads_begin_layout, static_cast(pads_begin_data.data()))); + } - output_shapes = ov::op::shape_infer(&op, input_shapes, ta); + if (is_end_mem) { + const_data.emplace(2, memory_deps.at(end_mem_idx)); + } else { + const_data.emplace(2, make_tensor(pads_end_layout, static_cast(pads_end_data.data()))); } + auto ta = cldnn::make_tensor_accessor(const_data); + std::vector output_shapes = ov::op::shape_infer(&op, input_shapes, ta); + format output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size()); return { layout{output_shapes[0], output_type, output_format} }; diff --git a/src/plugins/intel_gpu/src/graph/broadcast.cpp b/src/plugins/intel_gpu/src/graph/broadcast.cpp index bc4eaab28a9816..fdce54766b26dd 100644 --- a/src/plugins/intel_gpu/src/graph/broadcast.cpp +++ b/src/plugins/intel_gpu/src/graph/broadcast.cpp @@ -61,11 +61,11 @@ std::vector broadcast_inst::calc_output_layouts(broadcast_node const& /* auto axes_mapping = desc->axes_mapping.to_vector(); ShapeType axes_mapping_shape = ov::Shape{axes_mapping.size()}; - std::map const_data; + std::unordered_map const_data; if (third_input_needed) { input_shapes.emplace_back(axes_mapping_shape); - auto axes_mapping_tensor = make_host_tensor({axes_mapping_shape, data_types::i64, format::bfyx}, + auto axes_mapping_tensor = make_tensor({axes_mapping_shape, data_types::i64, format::bfyx}, static_cast(axes_mapping.data())); const_data.emplace(2, axes_mapping_tensor); } @@ -74,12 +74,11 @@ std::vector broadcast_inst::calc_output_layouts(broadcast_node const& /* if (constant_mem.count(1)) { auto target_shape_mem = constant_mem.at(1); cldnn::mem_lock target_shape_lock(target_shape_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(target_shape_mem->get_layout(), target_shape_lock.data())); + const_data.emplace(1, make_tensor(target_shape_mem->get_layout(), target_shape_lock.data())); output_shapes = ov::op::v3::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else if (impl_param.input_layouts.size() == 1) { // predefined pattern shape - auto target_shape_tensor = make_host_tensor({pattern_shape, data_types::i64, format::bfyx}, - static_cast(target_shape.data())); + auto target_shape_tensor = make_tensor({pattern_shape, data_types::i64, format::bfyx}, static_cast(target_shape.data())); const_data.emplace(1, target_shape_tensor); output_shapes = ov::op::v3::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else if (impl_param.input_layouts.size() >= 2) { diff --git a/src/plugins/intel_gpu/src/graph/crop.cpp b/src/plugins/intel_gpu/src/graph/crop.cpp index 78b993d5d6ed99..f103738baeb864 100644 --- a/src/plugins/intel_gpu/src/graph/crop.cpp +++ b/src/plugins/intel_gpu/src/graph/crop.cpp @@ -56,17 +56,17 @@ std::vector crop_inst::calc_output_layouts(const crop_node& /*node*/, co // TODO: calling shape_infer for all cropped outpus is redundant... Need to optimize. if (desc->op_mode == cldnn::crop_ngraph_op_mode::variadic_split) { - std::map const_data; + std::unordered_map const_data; OPENVINO_ASSERT(impl_param.memory_deps.count(1) > 0, "[GPU] Can't find Crop(ngraph VariadicSplit op mode) axis values memory dependency"); auto axis_values_mem = impl_param.memory_deps.at(1); cldnn::mem_lock axis_values_mem_lock(axis_values_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(axis_values_mem->get_layout(), axis_values_mem_lock.data())); + const_data.emplace(1, make_tensor(axis_values_mem->get_layout(), axis_values_mem_lock.data())); if (impl_param.memory_deps.count(2) > 0) { auto split_length_mem = impl_param.memory_deps.at(2); cldnn::mem_lock split_length_mem_lock(split_length_mem, impl_param.get_stream()); - const_data.emplace(2, make_host_tensor(split_length_mem->get_layout(), split_length_mem_lock.data())); + const_data.emplace(2, make_tensor(split_length_mem->get_layout(), split_length_mem_lock.data())); ov::op::v1::VariadicSplit op; output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); @@ -76,12 +76,12 @@ std::vector crop_inst::calc_output_layouts(const crop_node& /*node*/, co return { layout{out_shape, input0_layout.data_type, input0_layout.format } }; } } else if (desc->op_mode == cldnn::crop_ngraph_op_mode::split) { - std::map const_data; + std::unordered_map const_data; OPENVINO_ASSERT(impl_param.memory_deps.count(1) > 0, "[GPU] Can't find Crop(ngraph Split op mode) axis values memory dependency"); auto axis_values_mem = impl_param.memory_deps.at(1); cldnn::mem_lock axis_values_mem_lock(axis_values_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(axis_values_mem->get_layout(), axis_values_mem_lock.data())); + const_data.emplace(1, make_tensor(axis_values_mem->get_layout(), axis_values_mem_lock.data())); ov::op::v1::Split op; op.set_num_splits(desc->num_splits); diff --git a/src/plugins/intel_gpu/src/graph/gather.cpp b/src/plugins/intel_gpu/src/graph/gather.cpp index daa3416ad3235d..985ac85131dd05 100644 --- a/src/plugins/intel_gpu/src/graph/gather.cpp +++ b/src/plugins/intel_gpu/src/graph/gather.cpp @@ -88,8 +88,8 @@ std::vector gather_inst::calc_output_layouts(gather_node const& /*node*/ int64_t axis = desc->axis; - auto axis_tensor = std::make_shared(ov::element::i64, ov::Shape{1}, static_cast(&axis)); - std::map> const_data = {{2, axis_tensor}}; + auto axis_tensor = ov::Tensor(ov::element::i64, ov::Shape{1}, static_cast(&axis)); + std::unordered_map const_data = {{2, axis_tensor}}; output_shapes = ov::op::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); format output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size()); diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp index a482925dfd8bec..e4318334b17060 100644 --- a/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp @@ -46,8 +46,8 @@ struct range_impl : public typed_primitive_impl { auto ev = stream.create_user_event(false); auto params = instance.get_impl_params(); - ov::HostTensorVector input_host_tensors; - ov::HostTensorVector output_host_tensors; + ov::TensorVector input_host_tensors; + ov::TensorVector output_host_tensors; std::vector input_mem_ptrs; for (size_t i = 0; i < instance.dependencies().size(); i++) @@ -58,9 +58,9 @@ struct range_impl : public typed_primitive_impl { cldnn::mem_lock output_lock(output_mem_ptr, stream); for (size_t i = 0; i < input_mem_ptrs.size(); i++) - input_host_tensors.push_back(make_host_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read))); + input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read))); - output_host_tensors.push_back(make_host_tensor(params->output_layouts[0], output_lock.data())); + output_host_tensors.push_back(make_tensor(params->output_layouts[0], output_lock.data())); if (!op) { const auto output_dt = params->get_output_layout().data_type; diff --git a/src/plugins/intel_gpu/src/graph/include/primitive_inst.h b/src/plugins/intel_gpu/src/graph/include/primitive_inst.h index 098b44226aa4dd..3244ad20b49869 100644 --- a/src/plugins/intel_gpu/src/graph/include/primitive_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/primitive_inst.h @@ -8,6 +8,7 @@ #include "intel_gpu/runtime/event.hpp" #include "intel_gpu/runtime/memory.hpp" #include "intel_gpu/runtime/lru_cache.hpp" +#include "intel_gpu/runtime/tensor_accessor.hpp" #include "intel_gpu/graph/network.hpp" #include "intel_gpu/runtime/utils.hpp" #include "program_node.h" diff --git a/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp index 0ed005788965d4..bc156ccc75fda4 100644 --- a/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp +++ b/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp @@ -38,12 +38,12 @@ std::vector non_max_suppression_inst::calc_output_layouts(non_max_suppre }; auto& memory_deps = impl_param.memory_deps; - std::map const_data; + std::unordered_map const_data; if (memory_deps.count(2)) { auto max_output_boxes_per_class_mem = memory_deps.at(2); cldnn::mem_lock max_output_boxes_per_class_lock(max_output_boxes_per_class_mem, impl_param.get_stream()); - auto max_output_boxes_per_class_tensor = make_host_tensor(max_output_boxes_per_class_mem->get_layout(), + auto max_output_boxes_per_class_tensor = make_tensor(max_output_boxes_per_class_mem->get_layout(), max_output_boxes_per_class_lock.data()); const_data.emplace(2, max_output_boxes_per_class_tensor); diff --git a/src/plugins/intel_gpu/src/graph/one_hot.cpp b/src/plugins/intel_gpu/src/graph/one_hot.cpp index 32dd93633bed0c..01116bd987c263 100644 --- a/src/plugins/intel_gpu/src/graph/one_hot.cpp +++ b/src/plugins/intel_gpu/src/graph/one_hot.cpp @@ -67,8 +67,8 @@ std::vector one_hot_inst::calc_output_layouts(const one_hot_node& /*node int64_t depth = desc->depth; - auto depth_tensor = std::make_shared(ov::element::i64, ov::Shape{1}, static_cast(&depth)); - std::map> const_data = { + auto depth_tensor = ov::Tensor(ov::element::i64, ov::Shape{1}, static_cast(&depth)); + std::unordered_map const_data = { {1, depth_tensor} }; std::vector output_shapes = diff --git a/src/plugins/intel_gpu/src/graph/prior_box.cpp b/src/plugins/intel_gpu/src/graph/prior_box.cpp index 191d3cc947dba0..899f0db6f2ba4a 100644 --- a/src/plugins/intel_gpu/src/graph/prior_box.cpp +++ b/src/plugins/intel_gpu/src/graph/prior_box.cpp @@ -440,7 +440,7 @@ std::vector prior_box_inst::calc_output_layouts(prior_box_node const& /* impl_param.get_input_layout(1).get() }; std::vector output_shapes = {ShapeType()}; - std::map const_data; + std::unordered_map const_data; auto& memory_deps = impl_param.memory_deps; @@ -451,7 +451,7 @@ std::vector prior_box_inst::calc_output_layouts(prior_box_node const& /* cldnn::mem_lock output_size_lock(output_size_mem, impl_param.get_stream()); cldnn::mem_lock img_size_lock(img_size_mem, impl_param.get_stream()); - const_data.emplace(0, make_host_tensor(output_size_mem->get_layout(), output_size_lock.data())); + const_data.emplace(0, make_tensor(output_size_mem->get_layout(), output_size_lock.data())); auto p_param = const_cast(&impl_param); if (output_size_mem->get_layout().data_type == cldnn::data_types::i64) { diff --git a/src/plugins/intel_gpu/src/graph/random_uniform.cpp b/src/plugins/intel_gpu/src/graph/random_uniform.cpp index 31ab7894ac760f..6d665caa4890c0 100644 --- a/src/plugins/intel_gpu/src/graph/random_uniform.cpp +++ b/src/plugins/intel_gpu/src/graph/random_uniform.cpp @@ -33,18 +33,18 @@ std::vector random_uniform_inst::calc_output_layouts(random_uniform_node impl_param.get_input_layout(2).get_partial_shape() }; auto& memory_deps = impl_param.memory_deps; - std::map const_data; + std::unordered_map const_data; auto run_shape_infer = [&]() { ov::op::v8::RandomUniform op; if (memory_deps.count(1) > 0 && memory_deps.count(2) > 0) { auto min_val = memory_deps.at(1); cldnn::mem_lock min_val_lock(min_val, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(min_val->get_layout(), min_val_lock.data())); + const_data.emplace(1, make_tensor(min_val->get_layout(), min_val_lock.data())); auto max_val = memory_deps.at(2); cldnn::mem_lock max_val_lock(max_val, impl_param.get_stream()); - const_data.emplace(2, make_host_tensor(max_val->get_layout(), max_val_lock.data())); + const_data.emplace(2, make_tensor(max_val->get_layout(), max_val_lock.data())); return ov::op::v8::shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else { @@ -55,7 +55,7 @@ std::vector random_uniform_inst::calc_output_layouts(random_uniform_node if (memory_deps.count(0) > 0) { auto output_shape = memory_deps.at(0); cldnn::mem_lock output_shape_lock(output_shape, impl_param.get_stream()); - const_data.emplace(0, make_host_tensor(output_shape->get_layout(), output_shape_lock.data())); + const_data.emplace(0, make_tensor(output_shape->get_layout(), output_shape_lock.data())); output_shapes = run_shape_infer(); } else { diff --git a/src/plugins/intel_gpu/src/graph/range.cpp b/src/plugins/intel_gpu/src/graph/range.cpp index c1dae775f19ee2..0b57793bb6650a 100644 --- a/src/plugins/intel_gpu/src/graph/range.cpp +++ b/src/plugins/intel_gpu/src/graph/range.cpp @@ -34,21 +34,21 @@ std::vector range_inst::calc_output_layouts(range_node const& /*node*/, std::vector output_shapes = {ShapeType::dynamic(1)}; std::vector input_shapes = {ov::Shape(), ov::Shape(), ov::Shape()}; - std::map const_data; + std::unordered_map const_data; auto& memory_deps = impl_param.memory_deps; if (memory_deps.count(0) > 0 && memory_deps.count(1) > 0 && memory_deps.count(2) > 0) { auto start_mem = memory_deps.at(0); cldnn::mem_lock start_mem_lock(start_mem, impl_param.get_stream()); - const_data.emplace(0, make_host_tensor(start_mem->get_layout(), start_mem_lock.data())); + const_data.emplace(0, make_tensor(start_mem->get_layout(), start_mem_lock.data())); auto stop_mem = memory_deps.at(1); cldnn::mem_lock stop_mem_lock(stop_mem, impl_param.get_stream()); - const_data.emplace(1, make_host_tensor(stop_mem->get_layout(), stop_mem_lock.data())); + const_data.emplace(1, make_tensor(stop_mem->get_layout(), stop_mem_lock.data())); auto step_mem = memory_deps.at(2); cldnn::mem_lock step_mem_lock(step_mem, impl_param.get_stream()); - const_data.emplace(2, make_host_tensor(step_mem->get_layout(), step_mem_lock.data())); + const_data.emplace(2, make_tensor(step_mem->get_layout(), step_mem_lock.data())); output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } diff --git a/src/plugins/intel_gpu/src/graph/reduce.cpp b/src/plugins/intel_gpu/src/graph/reduce.cpp index d5a66fb0acb2d0..ee57a7984a4173 100644 --- a/src/plugins/intel_gpu/src/graph/reduce.cpp +++ b/src/plugins/intel_gpu/src/graph/reduce.cpp @@ -107,8 +107,8 @@ std::vector reduce_inst::calc_output_layouts(reduce_node const& /*node*/ std::vector output_shapes = {ShapeType()}; auto axes = desc->axes; - auto axes_tensor = std::make_shared(ov::element::i64, ov::Shape{axes.size()}, axes.data()); - std::map> const_data = {{1, axes_tensor}}; + auto axes_tensor = ov::Tensor(ov::element::i64, ov::Shape{axes.size()}, axes.data()); + std::unordered_map const_data = {{1, axes_tensor}}; auto ta = ov::make_tensor_accessor(const_data); // shape infer by mode diff --git a/src/plugins/intel_gpu/src/graph/reshape.cpp b/src/plugins/intel_gpu/src/graph/reshape.cpp index 2d04188a3c3a7d..9fc276469fb7c8 100644 --- a/src/plugins/intel_gpu/src/graph/reshape.cpp +++ b/src/plugins/intel_gpu/src/graph/reshape.cpp @@ -85,7 +85,7 @@ std::vector reshape_inst::calc_output_layouts(reshape_node const& /*node pattern_shape, }; - std::map const_data; + std::unordered_map const_data; const auto ta = ov::make_tensor_accessor(const_data); auto run_shape_infer = [&](reshape::reshape_mode mode) { @@ -120,13 +120,13 @@ std::vector reshape_inst::calc_output_layouts(reshape_node const& /*node cldnn::mem_lock pattern_lock(pattern_mem, impl_param.get_stream()); auto pattern_ptr = pattern_lock.data(); - auto pattern_tensor = make_host_tensor(pattern_mem->get_layout(), pattern_ptr); + auto pattern_tensor = make_tensor(pattern_mem->get_layout(), pattern_ptr); const_data.emplace(1, pattern_tensor); run_shape_infer(prim->mode); } else { auto pattern_data = prim->output_pattern; - auto pattern_tensor = make_host_tensor({pattern_shape, data_types::i64, format::bfyx}, static_cast(pattern_data.data())); + auto pattern_tensor = make_tensor({pattern_shape, data_types::i64, format::bfyx}, static_cast(pattern_data.data())); const_data.emplace(1, pattern_tensor); run_shape_infer(prim->mode); diff --git a/src/plugins/intel_gpu/src/graph/space_to_batch.cpp b/src/plugins/intel_gpu/src/graph/space_to_batch.cpp index 61fa6d45ed220a..159778951d8b81 100644 --- a/src/plugins/intel_gpu/src/graph/space_to_batch.cpp +++ b/src/plugins/intel_gpu/src/graph/space_to_batch.cpp @@ -101,7 +101,7 @@ std::vector space_to_batch_inst::calc_output_layouts(space_to_batch_node end_shape }; - std::map const_data; + std::unordered_map const_data; if (desc->shape_constant) { auto block_sizes = tensor_to_vec(block_data, input0_format); auto begin_sizes = tensor_to_vec(begin_data, input0_format); @@ -111,9 +111,9 @@ std::vector space_to_batch_inst::calc_output_layouts(space_to_batch_node auto begin_values = static_cast(begin_sizes.data()); auto end_values = static_cast(end_sizes.data()); - auto block_tensor = make_host_tensor({ block_shape, data_types::i32, input0_format }, block_values); - auto begin_tensor = make_host_tensor({ begin_shape, data_types::i32, input0_format }, begin_values); - auto end_tensor = make_host_tensor({ end_shape, data_types::i32, input0_format }, end_values); + auto block_tensor = make_tensor({ block_shape, data_types::i32, input0_format }, block_values); + auto begin_tensor = make_tensor({ begin_shape, data_types::i32, input0_format }, begin_values); + auto end_tensor = make_tensor({ end_shape, data_types::i32, input0_format }, end_values); const_data.emplace(1, block_tensor); const_data.emplace(2, begin_tensor); @@ -129,9 +129,9 @@ std::vector space_to_batch_inst::calc_output_layouts(space_to_batch_node cldnn::mem_lock lock2(begin_mem, impl_param.get_stream()); cldnn::mem_lock lock3(end_mem, impl_param.get_stream()); - auto block_tensor = make_host_tensor(block_mem->get_layout(), lock1.data()); - auto begin_tensor = make_host_tensor(begin_mem->get_layout(), lock2.data()); - auto end_tensor = make_host_tensor(end_mem->get_layout(), lock3.data()); + auto block_tensor = make_tensor(block_mem->get_layout(), lock1.data()); + auto begin_tensor = make_tensor(begin_mem->get_layout(), lock2.data()); + auto end_tensor = make_tensor(end_mem->get_layout(), lock3.data()); const_data.emplace(1, block_tensor); const_data.emplace(2, begin_tensor); diff --git a/src/plugins/intel_gpu/src/graph/strided_slice.cpp b/src/plugins/intel_gpu/src/graph/strided_slice.cpp index 3f334e58ee8d05..2bd2fcd0c483fb 100644 --- a/src/plugins/intel_gpu/src/graph/strided_slice.cpp +++ b/src/plugins/intel_gpu/src/graph/strided_slice.cpp @@ -67,12 +67,12 @@ std::vector strided_slice_inst::calc_output_layouts(strided_slice_node c op.set_shrink_axis_mask(desc->shrink_axis_mask); op.set_ellipsis_mask_mask(desc->ellipsis_mask); - std::map const_data; + std::unordered_map const_data; const auto ta = ov::make_tensor_accessor(const_data); if (!begin_data.empty() && !end_data.empty() && !strides_data.empty()) { - auto begin_tensor = make_host_tensor({ begin_shape, data_types::i64, format::bfyx }, static_cast(begin_data.data())); - auto end_tensor = make_host_tensor({ end_shape, data_types::i64, format::bfyx }, static_cast(end_data.data())); - auto strides_tensor = make_host_tensor({ strides_shape, data_types::i64, format::bfyx }, static_cast(strides_data.data())); + auto begin_tensor = make_tensor({ begin_shape, data_types::i64, format::bfyx }, static_cast(begin_data.data())); + auto end_tensor = make_tensor({ end_shape, data_types::i64, format::bfyx }, static_cast(end_data.data())); + auto strides_tensor = make_tensor({ strides_shape, data_types::i64, format::bfyx }, static_cast(strides_data.data())); const_data.emplace(1, begin_tensor); const_data.emplace(2, end_tensor); @@ -88,9 +88,9 @@ std::vector strided_slice_inst::calc_output_layouts(strided_slice_node c cldnn::mem_lock lock2(end_mem, impl_param.get_stream()); cldnn::mem_lock lock3(strides_mem, impl_param.get_stream()); - auto begin_tensor = make_host_tensor(begin_mem->get_layout(), lock1.data()); - auto end_tensor = make_host_tensor(end_mem->get_layout(), lock2.data()); - auto strides_tensor = make_host_tensor(strides_mem->get_layout(), lock3.data()); + auto begin_tensor = make_tensor(begin_mem->get_layout(), lock1.data()); + auto end_tensor = make_tensor(end_mem->get_layout(), lock2.data()); + auto strides_tensor = make_tensor(strides_mem->get_layout(), lock3.data()); const_data.emplace(1, begin_tensor); const_data.emplace(2, end_tensor); diff --git a/src/plugins/intel_gpu/tests/unit/shape_infer/pad_si_test.cpp b/src/plugins/intel_gpu/tests/unit/shape_infer/pad_si_test.cpp index 8a507ee45e1c7e..4d931f6cdc97b0 100644 --- a/src/plugins/intel_gpu/tests/unit/shape_infer/pad_si_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/shape_infer/pad_si_test.cpp @@ -177,21 +177,28 @@ INSTANTIATE_TEST_SUITE_P(smoke, pad_test_non_constant_input_begin, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{3, 4, 36, 48}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} }, { layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{{2, -1}, {1, -1}, {4, -1}, {8, -1}}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} + }, + { + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}, + layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, + layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7}, + ov::op::PadMode::EDGE, 1.f, + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} }, { layout{ov::PartialShape::dynamic(2), data_types::f32, format::bfyx}, layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {}, layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {1, 0}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{{2, -1}, {1, -1}}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(2), data_types::f32, format::bfyx} } })); @@ -234,21 +241,21 @@ INSTANTIATE_TEST_SUITE_P(smoke, pad_test_non_constant_input_end, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{3, 4, 36, 48}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} }, { layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 0, 3, 7}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{{2, -1}, {1, -1}, {4, -1}, {8, -1}}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} }, { layout{ov::PartialShape::dynamic(2), data_types::f32, format::bfyx}, layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {1, 0}, layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{{2, -1}, {1, -1}}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(2), data_types::f32, format::bfyx} } })); @@ -294,21 +301,92 @@ INSTANTIATE_TEST_SUITE_P(smoke, pad_test_non_constant_input_begin_end, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{3, 5, 34, 42}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} }, { layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {}, - ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{{2, -1}, {2, -1}, {2, -1}, {2, -1}}, data_types::f32, format::bfyx} + ov::op::PadMode::EDGE, 1.f, + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx} }, { layout{ov::PartialShape::dynamic(2), data_types::f32, format::bfyx}, layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {}, layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {}, ov::op::PadMode::CONSTANT, 1.f, - layout{ov::PartialShape{{2, -1}, {2, -1}}, data_types::f32, format::bfyx} + layout{ov::PartialShape::dynamic(2), data_types::f32, format::bfyx} + } + })); + +class pad_test_non_constant_input_begin_end_with_data : public testing::TestWithParam { }; + +TEST_P(pad_test_non_constant_input_begin_end_with_data, shape_infer) { + auto p = GetParam(); + + auto& engine = get_test_engine(); + + auto input0_prim = std::make_shared("input0", p.in_layout); + auto input1_prim = std::make_shared("input1", p.pads_begin_layout); + auto input2_prim = std::make_shared("input2", p.pads_end_layout); + + auto border_prim = std::make_shared("output", + std::vector({input_info("input0"), input_info("input1"), input_info("input2")}), + border::PAD_NON_CONST_INPUT::BEGIN | border::PAD_NON_CONST_INPUT::END, + p.pads_begin_data, + p.pads_end_data, + p.pad_mode, + p.pad_value); + cldnn::program prog(engine); + + auto& input0_node = prog.get_or_create(input0_prim); + auto& input1_node = prog.get_or_create(input1_prim); + auto& input2_node = prog.get_or_create(input2_prim); + auto& border_node = prog.get_or_create(border_prim); + + program_wrapper::add_connection(prog, input0_node, border_node); + program_wrapper::add_connection(prog, input1_node, border_node); + program_wrapper::add_connection(prog, input2_node, border_node); + + auto begin_mem = engine.allocate_memory(p.pads_begin_layout); + auto end_mem = engine.allocate_memory(p.pads_end_layout); + + set_values(begin_mem, p.pads_begin_data); + set_values(end_mem, p.pads_end_data); + auto impl_params = border_node.get_kernel_impl_params(); + impl_params->memory_deps = { + {1, begin_mem}, + {2, end_mem} + }; + + auto res = border_inst::calc_output_layouts(border_node, *impl_params); + + ASSERT_EQ(res.size(), 1); + ASSERT_EQ(res[0], p.expected_layout); +} + +INSTANTIATE_TEST_SUITE_P(smoke, pad_test_non_constant_input_begin_end_with_data, + testing::ValuesIn(std::vector{ + { + layout{ov::PartialShape{1, 3, 32, 40}, data_types::f32, format::bfyx}, + layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 2, 3, 4}, + layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {3, 2, 1, 0}, + ov::op::PadMode::CONSTANT, 1.f, + layout{ov::PartialShape{5, 7, 36, 44}, data_types::f32, format::bfyx} + }, + { + layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}, + layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {1, 2, 3, 4}, + layout{ov::PartialShape{4}, data_types::i64, format::bfyx}, {3, 2, 1, 0}, + ov::op::PadMode::EDGE, 1.f, + layout{ov::PartialShape{{4, -1}, {4, -1}, {4, -1}, {4, -1}}, data_types::f32, format::bfyx} + }, + { + layout{ov::PartialShape{10, 20}, data_types::f32, format::bfyx}, + layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {1, 2}, + layout{ov::PartialShape{2}, data_types::i64, format::bfyx}, {3, 4}, + ov::op::PadMode::EDGE, 1.f, + layout{ov::PartialShape{14, 26}, data_types::f32, format::bfyx} } })); From d2594200bc11b0c7a079a035a5dfe65a38f9dda9 Mon Sep 17 00:00:00 2001 From: Irina Efode Date: Thu, 10 Aug 2023 17:44:33 +0400 Subject: [PATCH 25/51] [CONFORMANCE] Enabling SubgraphsDumping (#18896) * Change fused_names algo -> cut subgraphs * Added extractor name to serialization dir + meta_info * Uncomment log * Add this_op_cnt to model_info, fix in_info for model * Replace clone node second time to relace input node * fix small problem * small fixes * Switch off repeat extractor * remove model serialization * fused_names * change default device in fused_names extractor * fused_names * Small speed up * Move replace of const by param to cache * Move alignament of in_info to extractorManager * Sort model by size (check mem fragmentation) * Fix problem with opset12 * Update manager.cpp * Serialize cache in case of long * Add test * Update graph_cache.cpp * Update graph_cache.cpp * Graph cache size * test other approach * remove extra * Fix issue with replae * try with 1gb limitatiom * to merge * revert --- .../include/cache/graph_cache.hpp | 13 +- .../include/cache/meta/input_info.hpp | 3 +- .../include/cache/meta/meta_info.hpp | 22 ++- .../include/cache/meta/model_info.hpp | 7 +- .../include/cache/op_cache.hpp | 1 + .../include/matchers/subgraph/fused_names.hpp | 5 + .../include/matchers/subgraph/manager.hpp | 12 +- .../include/matchers/subgraph/subgraph.hpp | 3 + .../subgraphs_dumper/include/utils/model.hpp | 137 +++++++++++++++++- .../subgraphs_dumper/include/utils/node.hpp | 3 + .../subgraphs_dumper/src/cache/cache.cpp | 28 +--- .../src/cache/graph_cache.cpp | 79 ++++++++-- .../src/cache/meta/meta_info.cpp | 72 ++++++++- .../subgraphs_dumper/src/cache/op_cache.cpp | 13 +- .../conformance/subgraphs_dumper/src/main.cpp | 41 ++++-- .../src/matchers/subgraph/fused_names.cpp | 38 ++--- .../src/matchers/subgraph/manager.cpp | 61 +++++++- .../src/matchers/subgraph/repeat_pattern.cpp | 7 +- .../src/matchers/subgraph/subgraph.cpp | 1 - .../subgraphs_dumper/src/utils/model.cpp | 123 ++++------------ .../subgraphs_dumper/src/utils/node.cpp | 35 +++-- .../tests/cache/graph_cache.cpp | 4 +- .../subgraphs_dumper/tests/cache/meta.cpp | 44 +++++- .../tests/matchers/subgraph/fused_names.cpp | 48 +++--- .../tests/matchers/subgraph/manager.cpp | 21 +++ .../matchers/subgraph/repeat_pattern.cpp | 2 +- .../tests/skip_tests_config.cpp | 8 +- .../tests/test_models/model_1.hpp | 78 ++-------- .../tests/test_models/model_2.hpp | 2 +- .../subgraphs_dumper/tests/utils/model.cpp | 40 ++--- .../src/read_ir/read_ir.cpp | 6 + .../src/base/utils/generate_inputs.cpp | 1 + 32 files changed, 614 insertions(+), 344 deletions(-) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/graph_cache.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/graph_cache.hpp index 096112f529a64c..198afd52803dff 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/graph_cache.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/graph_cache.hpp @@ -19,7 +19,7 @@ class GraphCache : public ICache { public: void update_cache(const std::shared_ptr& model, const std::string& model_meta_data, - bool extract_body = true) override; + bool extract_body) override; void serialize_cache() override; static std::shared_ptr& get() { @@ -35,6 +35,7 @@ class GraphCache : public ICache { } void reset_cache() override { + m_graph_cache.clear(); reset(); }; @@ -42,17 +43,21 @@ class GraphCache : public ICache { std::map, MetaInfo> m_graph_cache; ExtractorsManager m_manager = ExtractorsManager(); static std::shared_ptr m_cache_instance; + // cache byte size + size_t m_graph_cache_bytesize = 0; GraphCache() { ExtractorsManager::ExtractorsMap matchers = { - { "fused_names", FusedNamesExtractor::Ptr(new FusedNamesExtractor) }, - { "repeat_pattern", RepeatPatternExtractor::Ptr(new RepeatPatternExtractor) }, + // temporary disabling according mem leaks in CI and not using swap mem + // { "fused_names", FusedNamesExtractor::Ptr(new FusedNamesExtractor) }, + // { "repeat_pattern", RepeatPatternExtractor::Ptr(new RepeatPatternExtractor) }, }; m_manager.set_extractors(matchers); } void update_cache(const std::shared_ptr& model, const std::string& model_path, - const std::map& input_info, size_t model_op_cnt); + std::map& input_info, const std::string& extractor_name, + size_t model_op_cnt); }; } // namespace subgraph_dumper diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/input_info.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/input_info.hpp index 9cd79a3f1b1990..2aaa819520ab04 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/input_info.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/input_info.hpp @@ -52,7 +52,8 @@ struct InputInfo { } }; -using ExtractedPattern = std::pair, std::map>; +// ov_model, input_info, extractor_name +using ExtractedPattern = std::tuple, std::map, std::string>; } // namespace subgraph_dumper } // namespace tools diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/meta_info.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/meta_info.hpp index 1ded7e0044d16f..47572db370acd9 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/meta_info.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/meta_info.hpp @@ -13,18 +13,30 @@ namespace subgraph_dumper { class MetaInfo { public: - MetaInfo(const std::string& model_path = "", const std::map& _input_info = {}, size_t total_op_cnt = 1, size_t model_priority = 1); + MetaInfo(const std::string& model_path = "", const std::map& _input_info = {}, + size_t total_op_cnt = 1, size_t this_op_cnt = 1, const std::string& extractor = "", size_t model_priority = 1); + MetaInfo(std::map _in_info, + std::map _model_info, + std::unordered_set _extractors) : + model_info(_model_info), + input_info(_in_info), + extractors(_extractors) {}; void serialize(const std::string& serialization_path); - void update(const std::string& model_path, const std::map& _input_info, - size_t _total_op_cnt = 1, const std::vector& ignored_inputs = {}); - std::map get_input_info(); - std::map get_model_info(); + void update(const std::string& model_path, const std::map& _input_info, size_t _total_op_cnt = 1, + size_t _this_op_cnt = 1, const std::string& extractor = "", const std::vector& ignored_inputs = {}); + std::map get_input_info() const; + std::map get_model_info() const; + std::string get_any_extractor() const { return *extractors.begin(); } + + static MetaInfo read_meta_from_file(const std::string& meta_path); protected: // { input_node_name: input_info } std::map input_info; // { model_name: model_paths, this_op/graph_cnt, total_op_cnt, model_priority} std::map model_info; + // { extractors } + std::unordered_set extractors; // to store model priority ranges to normilize graph_priority static unsigned long MAX_MODEL_PRIORITY; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/model_info.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/model_info.hpp index 408c6cdcc603b8..e3fa7fec575354 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/model_info.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/meta/model_info.hpp @@ -15,9 +15,10 @@ struct ModelInfo { std::set model_paths; size_t this_op_cnt, total_op_cnt, model_priority; - ModelInfo(const std::string& model_path = "", size_t total_ops_in_model = 1, size_t _model_priority = 1) : - total_op_cnt(total_ops_in_model), model_paths({model_path}), - this_op_cnt(1), model_priority(_model_priority) {} + ModelInfo(const std::string& model_path = "", size_t total_ops_in_model = 1, size_t this_ops_in_model = 1, size_t _model_priority = 1) : + total_op_cnt(total_ops_in_model), this_op_cnt(this_ops_in_model), model_priority(_model_priority) { + model_paths = model_path.empty() ? std::set() : std::set({ model_path }) ; + } bool operator==(const ModelInfo& model_info_ref) const { if (this->model_priority != model_info_ref.model_priority || this->this_op_cnt != model_info_ref.this_op_cnt || diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/op_cache.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/op_cache.hpp index feca24414d63cb..b7f277526a026b 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/op_cache.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/cache/op_cache.hpp @@ -32,6 +32,7 @@ class OpCache : public ICache { } void reset_cache() override { + m_ops_cache.clear(); reset(); }; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/fused_names.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/fused_names.hpp index 84e5a88bd87066..dfc2a7dc995a08 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/fused_names.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/fused_names.hpp @@ -14,11 +14,16 @@ namespace subgraph_dumper { class FusedNamesExtractor : public SubgraphExtractor { public: + FusedNamesExtractor(); std::list extract(const std::shared_ptr &model, bool is_extract_body = true) override; + void set_target_device(const std::string& _device) { device = _device; } protected: std::unordered_set extract_compiled_model_names(const std::shared_ptr& model); + + std::string device; + std::shared_ptr core; }; } // namespace subgraph_dumper diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/manager.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/manager.hpp index e9dad1b9adc0e2..05395b80c15a26 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/manager.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/manager.hpp @@ -16,15 +16,25 @@ class ExtractorsManager { explicit ExtractorsManager(const ExtractorsMap& extractors = {}) : m_extractors(extractors) {} bool match(const std::shared_ptr &model, - const std::shared_ptr &ref); + const std::shared_ptr &ref, + std::map &in_info, + const std::map &in_info_ref); std::list extract(const std::shared_ptr &model, bool is_extract_body = true); void set_extractors(const ExtractorsMap& extractors = {}) { m_extractors = extractors; } ExtractorsMap get_extractors() { return m_extractors; } + std::map align_input_info(const std::shared_ptr& model, + const std::shared_ptr& model_ref, + const std::map &in_info, + const std::map &in_info_ref); + protected: ExtractorsMap m_extractors = {}; + + bool match(const std::shared_ptr &model, + const std::shared_ptr &ref); }; } // namespace subgraph_dumper diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/subgraph.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/subgraph.hpp index b0ab5b79c9e813..44320a8dd34c46 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/subgraph.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/matchers/subgraph/subgraph.hpp @@ -26,7 +26,10 @@ class SubgraphExtractor { return std::list{}; }; + void set_extractor_name(const std::string& _extractor_name) { extractor_name = _extractor_name; } + protected: + std::string extractor_name = ""; FunctionsComparator comparator = FunctionsComparator::no_default() .enable(FunctionsComparator::ATTRIBUTES) .enable(FunctionsComparator::NODES) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/model.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/model.hpp index abaeb3b036e1d6..86f133be09f794 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/model.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/model.hpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "openvino/util/file_util.hpp" @@ -56,7 +58,8 @@ static std::map model_cache_status_to_str = { { ModelCacheStatus::NOT_READ, "not_read_models" }, }; -std::vector find_models(const std::vector &dirs, const std::string& regexp = ".*"); +std::pair, std::pair>> +find_models(const std::vector &dirs, const std::string& regexp = ".*"); // model_cache_status: model_list std::map> cache_models( @@ -67,10 +70,136 @@ std::map> cache_models( void save_model_status_to_file(const std::map>& caching_status, const std::string& output_dir); -std::pair, std::map> +inline ExtractedPattern generate_model(const std::set>& nodes, - const std::shared_ptr& start_node, - std::unordered_set& checked_ops); + std::unordered_set& checked_ops, + const std::string& extractor_name) { + std::unordered_map> model_map; + // to create reults: { out_op_name, out_ports_without_target_inputs } + std::unordered_map> model_output_nodes; + std::map input_info; + ov::ParameterVector params; + { + // prepare map { original_op_name, cloned_op } + size_t functional_op_cnt = 0; + for (const auto& op : nodes) { + auto op_name = op->get_friendly_name(); + checked_ops.insert(op_name); + auto cloned_op = clone_node(op, true, false, op->get_friendly_name()); + model_map.insert({ op_name, cloned_op }); + + size_t output_cnt = op->outputs().size(); + std::vector out_ports(output_cnt); + std::iota(out_ports.begin(), out_ports.end(), 0); + std::unordered_set out_ports_set(out_ports.begin(), out_ports.end()); + model_output_nodes.insert({ op_name, out_ports_set }); + if (!ov::op::util::is_output(op) && !ov::op::util::is_constant(op) && !ov::op::util::is_parameter(op)) { + ++functional_op_cnt; + } + } + + if (functional_op_cnt < 2) { + throw std::runtime_error("Incorrect node number to create model"); + } + // replace new inputs by taken from graph if possible + for (const auto& op : nodes) { + int filled_input_idx = -1; + std::vector not_filled_ports; + auto in_cnt = op->inputs().size(); + auto cloned_op = model_map[op->get_friendly_name()]; + std::map this_input_info = get_input_info_by_node(cloned_op); + for (size_t in_idx = 0; in_idx < in_cnt; ++in_idx) { + auto in_node = op->get_input_node_ptr(in_idx)->shared_from_this(); + for (size_t in_out_idx = 0; in_out_idx < in_node->outputs().size(); ++in_out_idx) { + for (const auto& target_input : in_node->output(in_out_idx).get_target_inputs()) { + auto out_in_node = target_input.get_node()->shared_from_this(); + if (out_in_node == op) { + auto in_node_name = in_node->get_friendly_name(); + auto in_cloned_node = cloned_op->get_input_node_shared_ptr(in_idx); + // if op input node is in subgraph + if (model_map.count(in_node_name)) { + auto in_node = model_map[in_node_name]; + auto in_cloned_friendly_name = in_cloned_node->get_friendly_name(); + ov::replace_output_update_name(in_cloned_node->get_default_output(), in_node->output(in_out_idx)); + in_cloned_node->clear_control_dependencies(); + if (ov::op::util::is_parameter(in_node)) { + auto param = std::dynamic_pointer_cast(in_node); + params.push_back(param); + this_input_info.insert({ in_node->get_friendly_name(), this_input_info[in_cloned_friendly_name]}); + } else if (ov::op::util::is_constant(in_node)) { + auto op_to_replace = std::dynamic_pointer_cast(in_node); + auto param = convert_const_to_param(op_to_replace); + if (param != nullptr) { + params.push_back(param); + } + // insert in_info with updated in_name + this_input_info.insert({ in_node->get_friendly_name(), this_input_info[in_cloned_friendly_name]}); + } + // remove in_info with old name from input info + this_input_info.erase(in_cloned_friendly_name); + filled_input_idx++; + model_output_nodes[in_node_name].erase(in_out_idx); + if (model_output_nodes[in_node_name].empty()) { + model_output_nodes.erase(in_node_name); + } + } else if (ov::op::util::is_parameter(in_cloned_node)) { + auto param = std::dynamic_pointer_cast(in_cloned_node); + params.push_back(param); + } else if (ov::op::util::is_constant(in_cloned_node)) { + auto op_to_replace = std::dynamic_pointer_cast(in_cloned_node); + auto param = convert_const_to_param(op_to_replace); + if (param != nullptr) { + params.push_back(param); + } + } + break; + } + } + if (filled_input_idx == in_idx) { + break; + } + } + } + if (!this_input_info.empty()) { + input_info.insert(this_input_info.begin(), this_input_info.end()); + } + } + } + ov::ResultVector results; + for (const auto& out_node_name : model_output_nodes) { + auto out_node = model_map[out_node_name.first]; + if (ov::op::util::is_output(out_node)) { + results.push_back(std::dynamic_pointer_cast(out_node)); + } else { + for (const auto& out_port_id : out_node_name.second) { + results.push_back(std::make_shared(out_node->output(out_port_id))); + } + } + } + auto model = std::make_shared(results, params); + std::string string_to_hash; + for (const auto& op : model->get_ordered_ops()) { + std::ostringstream result; + result << op->get_type_info(); + for (const auto& in : op->inputs()) { + result << in.get_element_type(); + result << in.get_partial_shape().rank(); + result << in.get_partial_shape().is_static(); + } + for (const auto& out : op->outputs()) { + result << out.get_element_type(); + result << out.get_partial_shape().rank(); + result << out.get_partial_shape().is_static(); + } + string_to_hash += result.str(); + } + for (const auto& in : input_info) { + string_to_hash += (in.second.is_const ? "1" : "0"); + } + auto h1 = std::hash{}(string_to_hash); + model->set_friendly_name(std::to_string(h1)); + return { model, input_info, extractor_name }; +} } // namespace subgraph_dumper } // namespace tools diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp index 02319ab816030f..cc6eea4809c1f2 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp @@ -36,6 +36,9 @@ std::shared_ptr clone_node(std::shared_ptr node, bool is_copy_const_node = false, std::string node_name = ""); + +std::shared_ptr convert_const_to_param(const std::shared_ptr& constant_node); + // all inputs are defined as parameters and contains detailed info in meta std::shared_ptr generate_model_by_node(const std::shared_ptr& node); diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp index 6cb27e749db09d..5dc7017ed9059f 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp @@ -20,31 +20,6 @@ bool ICache::serialize_model(const std::pair, MetaInf const std::string& rel_serialization_dir) { std::shared_ptr model = graph_info.first; MetaInfo meta = graph_info.second; - std::map, std::shared_ptr> nodes; - ov::ParameterVector param_vector; - for (const auto& op : model->get_ordered_ops()) { - std::shared_ptr param = nullptr; - if (ov::op::util::is_parameter(op)) { - param = std::dynamic_pointer_cast(op); - } else if (ov::op::util::is_constant(op)) { - auto op_to_replace = std::dynamic_pointer_cast(op); - if (op_to_replace->get_byte_size() > 1024) { - param = std::make_shared( - op_to_replace->get_output_element_type(0), op_to_replace->get_output_partial_shape(0)); - param->set_friendly_name(op_to_replace->get_friendly_name()); - nodes.insert({ op_to_replace, param }); - } - } - if (param != nullptr) { - param_vector.push_back(param); - } - } - if (!nodes.empty()) { - for (const auto& node : nodes) { - model->replace_node(node.first, node.second); - } - model = std::make_shared(model->get_results(), param_vector); - } std::string model_name = model->get_friendly_name(); std::string abs_searilization_dir = ov::util::path_join({ m_serialization_dir, rel_serialization_dir }); @@ -67,7 +42,8 @@ bool ICache::serialize_model(const std::pair, MetaInf } catch (std::exception &e) { std::cout << "[ ERROR ] Failed to serialize model: " << model_name << ". Exception: " << e.what() << std::endl; - ov::test::utils::removeIRFiles(xml_path, bin_path); + ov::test::utils::removeFile(xml_path); + ov::test::utils::removeFile(bin_path); ov::test::utils::removeFile(meta_path); if (std::string(e.what()).find("Can't open") == std::string::npos) { return false; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp index 86bce528fbff94..034e673a1d6738 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp @@ -2,10 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "openvino/op/util/op_types.hpp" +#include "openvino/util/file_util.hpp" #include "functional_test_utils/ov_plugin_cache.hpp" #include "common_test_utils/graph_comparator.hpp" +#include "common_test_utils/file_utils.hpp" #include "cache/graph_cache.hpp" #include "utils/node.hpp" @@ -26,31 +30,73 @@ void GraphCache::update_cache(const std::shared_ptr& model, return; } while (!extracted_patterns.empty()) { - auto it = extracted_patterns.begin(); - update_cache(it->first, model_meta_data, it->second, model_total_op); + auto it = *extracted_patterns.begin(); + update_cache(std::get<0>(it), model_meta_data, std::get<1>(it), std::get<2>(it), model_total_op); extracted_patterns.pop_front(); } return; } void GraphCache::update_cache(const std::shared_ptr& extracted_model, const std::string& model_path, - const std::map& input_info, size_t model_op_cnt) { - std::shared_ptr model_to_update = nullptr; - for (const auto& cached_model : m_graph_cache) { - if (m_manager.match(cached_model.first, extracted_model)) { - model_to_update = cached_model.first; + std::map& input_info, const std::string& extractor_name, size_t model_op_cnt) { + // todo: check the number 8GB + if (m_graph_cache_bytesize >> 33 > 0) { + std::cout << "[ GRAPH CACHE ][ WARNING ] Cache size > 8 GB. Serialize graph cache" << std::endl; + serialize_cache(); + // m_graph_cache.clear(); + m_graph_cache_bytesize = 0; + } + + auto graph_name = extracted_model->get_friendly_name(); + std::string serialized_model_path = ""; + for (const auto& extractor : m_manager.get_extractors()) { + auto tmp_serialized_model_path = ov::util::path_join({ m_serialization_dir, "subgraph", extractor.first, graph_name + ".xml" }); + if (ov::util::file_exists(serialized_model_path)) { + serialized_model_path = tmp_serialized_model_path; break; } } + + std::shared_ptr model_to_update = nullptr; + // if cached model was serialized + if (!serialized_model_path.empty()) { + std::cout << "[ GRAPH CACHE ][ INFO ] Reading cached model: " << serialized_model_path << std::endl; + auto bin_path = ov::test::utils::replaceExt(serialized_model_path, ".bin"); + auto meta_path = ov::test::utils::replaceExt(serialized_model_path, ".meta"); + auto cached_model = ov::test::utils::PluginCache::get().core()->read_model(serialized_model_path); + auto cached_meta = MetaInfo::read_meta_from_file(meta_path); + + ov::test::utils::removeFile(serialized_model_path); + ov::test::utils::removeFile(bin_path); + ov::test::utils::removeFile(meta_path); + m_graph_cache.insert({ cached_model, cached_meta }); + m_graph_cache_bytesize += cached_model->get_graph_size(); + model_to_update = cached_model; + input_info = m_manager.align_input_info(extracted_model, model_to_update, + input_info, cached_meta.get_input_info()); + } else { + for (const auto& cached_model : m_graph_cache) { + if (m_manager.match(extracted_model, cached_model.first, + input_info, cached_model.second.get_input_info())) { + model_to_update = cached_model.first; + break; + } + } + } + + auto this_op_cnt = extracted_model->get_ops().size() - + extracted_model->get_parameters().size() - extracted_model->get_results().size(); if (model_to_update == nullptr) { - auto meta = MetaInfo(model_path, input_info, model_op_cnt); + auto meta = MetaInfo(model_path, input_info, model_op_cnt, this_op_cnt, extractor_name); m_graph_cache.insert({ extracted_model, meta }); + m_graph_cache_bytesize += extracted_model->get_graph_size(); return; } - m_graph_cache[model_to_update].update(model_path, input_info, model_op_cnt); + m_graph_cache[model_to_update].update(model_path, input_info, model_op_cnt, this_op_cnt, extractor_name); auto cached_model_size = model_to_update->get_graph_size(); auto pattern_model_size = extracted_model->get_graph_size(); if (pattern_model_size < cached_model_size) { + m_graph_cache_bytesize -= (cached_model_size - pattern_model_size); auto meta = m_graph_cache[model_to_update]; m_graph_cache.erase(model_to_update); m_graph_cache.insert({extracted_model, meta}); @@ -58,11 +104,18 @@ void GraphCache::update_cache(const std::shared_ptr& extracted_model, } void GraphCache::serialize_cache() { - for (const auto& cache_item : m_graph_cache) { - serialize_model(cache_item, "subgraph"); - } + // for (const auto& cache_item : m_graph_cache) { + auto it = m_graph_cache.begin(); + while (it != m_graph_cache.end()) { + auto rel_dir = ov::util::path_join({ "subgraph", it->second.get_any_extractor() }); + serialize_model(*it, rel_dir); + m_graph_cache.erase(it->first); + it = m_graph_cache.begin(); + } + auto a = 0; + // } } } // namespace subgraph_dumper } // namespace tools -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/meta/meta_info.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/meta/meta_info.cpp index d9cd0127e7f5b0..90211ff6522471 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/meta/meta_info.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/meta/meta_info.cpp @@ -15,16 +15,20 @@ namespace subgraph_dumper { unsigned long MetaInfo::MIN_MODEL_PRIORITY = std::numeric_limits::max(); unsigned long MetaInfo::MAX_MODEL_PRIORITY = std::numeric_limits::min(); -MetaInfo::MetaInfo(const std::string& _model_path, const std::map& _input_info, size_t _total_op_cnt, size_t model_priority) { +MetaInfo::MetaInfo(const std::string& _model_path, const std::map& _input_info, + size_t _total_op_cnt, size_t _this_op_cnt, const std::string& extractor, size_t model_priority) { unsigned long tmp_graph_priority = _total_op_cnt * model_priority; if (tmp_graph_priority < MIN_MODEL_PRIORITY) MIN_MODEL_PRIORITY = tmp_graph_priority; if (tmp_graph_priority > MAX_MODEL_PRIORITY) MAX_MODEL_PRIORITY = tmp_graph_priority; if (_model_path != "") { - model_info.insert({ get_model_name_by_path(_model_path), ModelInfo(_model_path, _total_op_cnt, model_priority) }); + model_info.insert({ get_model_name_by_path(_model_path), ModelInfo(_model_path, _total_op_cnt, _this_op_cnt, model_priority) }); } if (!_input_info.empty()) { input_info = _input_info; } + if (!extractor.empty()) { + extractors = { extractor }; + } } unsigned long MetaInfo::get_abs_graph_priority() { @@ -42,6 +46,53 @@ double MetaInfo::get_graph_priority() { return diff / delta; } +MetaInfo MetaInfo::read_meta_from_file(const std::string& meta_path) { + pugi::xml_document doc; + doc.load_file(meta_path.c_str()); + std::map model_info; + { + auto model_xml_root = doc.child("meta_info").child("models"); + for (const auto& model_child : model_xml_root.children()) { + ModelInfo tmp_model_info; + tmp_model_info.this_op_cnt = model_child.attribute("this_op_count").as_uint(); + tmp_model_info.total_op_cnt = model_child.attribute("total_op_count").as_uint(); + for (const auto& path : model_child.child("path")) { + tmp_model_info.model_paths.insert(std::string(path.attribute("path").value())); + } + model_info.insert({ std::string(model_child.attribute("name").value()), tmp_model_info }); + } + } + std::map input_info; + { + auto input_info_xml = doc.child("meta_info").child("input_info"); + for (const auto &input : input_info_xml.children()) { + auto in_name = std::string(input.attribute("id").value()); + ov::tools::subgraph_dumper::InputInfo in_info; + in_info.is_const = input.attribute("convert_to_const").as_bool(); + if (std::string(input.attribute("min").value()) != "undefined") { + in_info.ranges.min = input.attribute("min").as_double(); + } else { + in_info.ranges.min = DEFAULT_MIN_VALUE; + } + if (std::string(input.attribute("max").value()) != "undefined") { + in_info.ranges.max = input.attribute("max").as_double(); + } else { + in_info.ranges.min = DEFAULT_MAX_VALUE; + } + input_info.insert({in_name, in_info}); + } + } + std::unordered_set extractors; + { + auto extractors_xml = doc.child("meta_info").child("extractors"); + for (const auto& extractor : extractors_xml.children()) { + extractors.insert(std::string(extractor.attribute("name").value())); + } + } + auto new_meta = MetaInfo(input_info, model_info, extractors); + return new_meta; +} + void MetaInfo::serialize(const std::string& serialization_path) { pugi::xml_document doc; pugi::xml_node root = doc.append_child("meta_info"); @@ -56,6 +107,12 @@ void MetaInfo::serialize(const std::string& serialization_path) { model_node.append_child("path").append_child("model").append_attribute("path").set_value(model_path.c_str()); } } + if (!extractors.empty()) { + auto extractors_node = root.append_child("extractors"); + for (const auto& extractor : extractors) { + extractors_node.append_child("extractor").append_attribute("name").set_value(extractor.c_str()); + } + } double graph_priority = get_graph_priority(); root.append_child("graph_priority").append_attribute("value").set_value(graph_priority); auto ports_info = root.append_child("input_info"); @@ -80,6 +137,8 @@ void MetaInfo::serialize(const std::string& serialization_path) { void MetaInfo::update(const std::string& _model_path, const std::map& _input_info, size_t _total_op_cnt, + size_t _this_op_cnt, + const std::string& extractor, const std::vector& ignored_inputs) { if (input_info.size() != _input_info.size()) { throw std::runtime_error("Incompatible input info!"); @@ -90,7 +149,7 @@ void MetaInfo::update(const std::string& _model_path, model_info.at(model_name).model_paths.insert(_model_path); model_info.at(model_name).total_op_cnt += _total_op_cnt; } - model_info.at(model_name).this_op_cnt++; + model_info.at(model_name).this_op_cnt += _this_op_cnt; } else { model_info.insert({ model_name, ModelInfo(_model_path, _total_op_cnt) });\ } @@ -112,13 +171,16 @@ void MetaInfo::update(const std::string& _model_path, if (abs_graph_priority > MAX_MODEL_PRIORITY) MAX_MODEL_PRIORITY = abs_graph_priority; if (abs_graph_priority < MIN_MODEL_PRIORITY) MIN_MODEL_PRIORITY = abs_graph_priority; } + if (!extractor.empty()) { + extractors.insert(extractor); + } } -std::map MetaInfo::get_input_info() { +std::map MetaInfo::get_input_info() const { return input_info; } -std::map MetaInfo::get_model_info() { +std::map MetaInfo::get_model_info() const { return model_info; } diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp index 703b5a19588f71..06895fbe37d6bd 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp @@ -83,11 +83,12 @@ void OpCache::update_cache(const std::shared_ptr& node, } size_t priority = get_node_priority_by_version(cloned_node); - auto meta = MetaInfo(model_path, get_input_info_by_node(cloned_node), model_op_cnt, priority); + auto meta = MetaInfo(model_path, get_input_info_by_node(cloned_node), model_op_cnt, 1, "", priority); if (find_op_in_cache != nullptr) { - std::cout << "[ INFO ][ OP CACHE ] Update cache node: " << cloned_node->get_type_info().name << - " " << find_op_in_cache->get_friendly_name() << std::endl; - m_ops_cache[find_op_in_cache].update(model_path, get_input_info_by_node(cloned_node), model_op_cnt, ignored_input_names); + // std::cout << "[ INFO ][ OP CACHE ] Update cache node: " << cloned_node->get_type_info().name << cloned_node->get_friendly_name() << + // " " << find_op_in_cache->get_friendly_name() << std::endl; + m_ops_cache[find_op_in_cache].update( + model_path, get_input_info_by_node(cloned_node), model_op_cnt, 1, "", ignored_input_names); } if (find_op_in_cache > cloned_node) { meta = m_ops_cache[find_op_in_cache]; @@ -95,8 +96,8 @@ void OpCache::update_cache(const std::shared_ptr& node, find_op_in_cache = nullptr; } if (find_op_in_cache == nullptr) { - std::cout << "[ INFO ][ OP CACHE ] Insert node: " << cloned_node->get_type_info().name << - " " << cloned_node->get_friendly_name() << " to Cache" << std::endl; + // std::cout << "[ INFO ][ OP CACHE ] Insert node: " << cloned_node->get_type_info().name << + // " " << cloned_node->get_friendly_name() << " to Cache" << std::endl; m_ops_cache.insert({ cloned_node, meta }); } } diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp index 7f723ce5ee204a..5f330f9226442e 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp @@ -20,6 +20,7 @@ int main(int argc, char *argv[]) { std::vector dirs = ov::test::utils::splitStringByDelimiter(FLAGS_input_folders); std::vector models; + std::map> cache_model_status; if (!ov::test::utils::directoryExists(FLAGS_output_folder)) { std::string msg = "Output directory (" + FLAGS_output_folder + ") doesn't not exist! The directory will be created."; @@ -27,7 +28,9 @@ int main(int argc, char *argv[]) { ov::test::utils::createDirectoryRecursive(FLAGS_output_folder); } try { - models = find_models(dirs, FLAGS_path_regex); + auto all_models = find_models(dirs, FLAGS_path_regex); + models = all_models.first; + cache_model_status.insert(all_models.second); } catch (std::runtime_error& e) { std::cout << "[ INFO ] Try 'subgraphsDumper -h' for more information. \nException: " << e.what() << std::endl; return 1; @@ -39,27 +42,39 @@ int main(int argc, char *argv[]) { caches.push_back(OpCache::get()); } if (FLAGS_cache_type == "GRAPH" || FLAGS_cache_type.empty()) { - // todo: iefode: to check and enable it in CI - // std::cout << "[ INFO ] GraphCache is enabled!" << std::endl; - // caches.push_back(GraphCache::get()); + std::cout << "[ INFO ] GraphCache is enabled!" << std::endl; + caches.push_back(GraphCache::get()); } for (auto& cache : caches) { cache->set_serialization_dir(FLAGS_output_folder); } - std::map> cache_model_status; // Upload previously cached graphs to cache if (!FLAGS_local_cache.empty()) { - auto cachedOps = find_models(local_cache_dirs); - cache_model_status = cache_models(caches, cachedOps, FLAGS_extract_body); + auto cached_ops = find_models(local_cache_dirs); + // todo: add normal caching with meta info reading + auto this_cache_model_status = cache_models(caches, cached_ops.first, FLAGS_extract_body); + auto not_read_model = cached_ops.second; + for (auto& model_status : cache_model_status) { + auto& key = model_status.first; + auto& value = model_status.second; + if (not_read_model.first == key) { + value.insert(value.end(), not_read_model.second.begin(), not_read_model.second.end()); + } + if (this_cache_model_status.count(key)) { + value.insert(value.end(), this_cache_model_status[key].begin(), this_cache_model_status[key].end()); + } + } } { - auto tmp_cache_model_status = cache_models(caches, models, FLAGS_extract_body); - cache_model_status.insert(tmp_cache_model_status.begin(), tmp_cache_model_status.end()); - } - for (auto& cache : caches) { - cache->set_serialization_dir(FLAGS_output_folder); - cache->serialize_cache(); + auto this_cache_model_status = cache_models(caches, models, FLAGS_extract_body); + for (auto& model_status : cache_model_status) { + auto& key = model_status.first; + auto& value = model_status.second; + if (this_cache_model_status.count(key)) { + value.insert(value.end(), this_cache_model_status[key].begin(), this_cache_model_status[key].end()); + } + } } save_model_status_to_file(cache_model_status, FLAGS_output_folder); return cache_model_status[ModelCacheStatus::NOT_FULLY_CACHED].empty() && cache_model_status[ModelCacheStatus::NOT_READ].empty(); diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/fused_names.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/fused_names.cpp index e9e4f5435a3119..3eef3eb5b5b896 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/fused_names.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/fused_names.cpp @@ -15,8 +15,7 @@ using namespace ov::tools::subgraph_dumper; std::unordered_set FusedNamesExtractor::extract_compiled_model_names(const std::shared_ptr& model) { - auto core = ov::test::utils::PluginCache::get().core(); - auto compiled_model = core->compile_model(model); + auto compiled_model = core->compile_model(model, device); std::unordered_set compiled_op_name; for (const auto& compiled_op : compiled_model.get_runtime_model()->get_ordered_ops()) { const auto& rt_info = compiled_op->get_rt_info(); @@ -27,6 +26,11 @@ FusedNamesExtractor::extract_compiled_model_names(const std::shared_ptrget_available_devices().begin()); +} + std::list FusedNamesExtractor::extract(const std::shared_ptr &model, bool is_extract_body) { @@ -34,16 +38,23 @@ FusedNamesExtractor::extract(const std::shared_ptr &model, std::list matched_patterns; std::unordered_set checked_ops; std::set> nodes; - std::shared_ptr start_node = nullptr; for (const auto& op : model->get_ordered_ops()) { auto op_name = op->get_friendly_name(); if (is_node_to_skip(op) || checked_ops.count(op_name)) { continue; } - if (start_node == nullptr) { - start_node = op; + if (compiled_op_name.count(op_name)) { + try { + matched_patterns.push_back(generate_model(nodes, checked_ops, extractor_name)); + } catch(std::exception& e) { + if (std::string(e.what()) != "Incorrect node number to create model") { + std::cout << "[ WARNING ] Impossible to generate network and add to GraphCache: " <(op)) { auto ti = ov::as_type_ptr(op); @@ -65,20 +76,13 @@ FusedNamesExtractor::extract(const std::shared_ptr &model, } } } - if (!compiled_op_name.count(op_name)) { - try { - matched_patterns.push_back(generate_model(nodes, start_node, checked_ops)); - } catch(std::exception& e) { - std::cout << "[ ERROR ] Impossible to generate network and add to GraphCache: " < #include "matchers/subgraph/manager.hpp" using namespace ov::tools::subgraph_dumper; @@ -16,12 +16,71 @@ bool ExtractorsManager::match(const std::shared_ptr &model, return false; } +bool ExtractorsManager::match(const std::shared_ptr &model, + const std::shared_ptr &ref, + std::map &in_info, + const std::map &in_info_ref) { + if (match(model, ref)) { + try { + auto new_input_info = align_input_info(model, ref, in_info, in_info_ref); + in_info = new_input_info; + return true; + } catch (...) { + return false; + } + } + return false; +} + +std::map +ExtractorsManager::align_input_info(const std::shared_ptr& model, + const std::shared_ptr& model_ref, + const std::map& in_info, + const std::map& in_info_ref) { + std::map new_input_info = in_info; + bool is_update_required = false; + for (const auto& in_info_item : in_info_ref) { + if (!in_info.count(in_info_item.first)) { + is_update_required = true; + break; + } + } + if (is_update_required) { + std::map new_ref_input_info = in_info_ref; + // align matched model names + auto ref_model_ops = model_ref->get_ordered_ops(); + auto model_ops = model->get_ordered_ops(); + size_t ordered_ops_size = model_ops.size(); + if (ordered_ops_size != ref_model_ops.size()) { + throw std::runtime_error("Matched models are different!"); + } + for (size_t i = 0; i < ordered_ops_size; ++i) { + auto model_op_name = model_ops[i]->get_friendly_name(); + auto model_ref_op_name = ref_model_ops[i]->get_friendly_name(); + if (in_info.count(model_op_name)) { + auto input_info = new_input_info[model_op_name]; + if (input_info.is_const != new_ref_input_info[model_ref_op_name].is_const) { + throw std::runtime_error("Impossible yo update input info!!!"); + } + new_input_info.erase(model_op_name); + new_input_info.insert({ model_ref_op_name, input_info }); + } + } + } + return new_input_info; +} + std::list ExtractorsManager::extract(const std::shared_ptr &model, bool is_extract_body) { std::list result; for (const auto &it : m_extractors) { + auto start = std::chrono::high_resolution_clock::now(); + it.second->set_extractor_name(it.first); auto extracted_patterns = it.second->extract(model, is_extract_body); result.insert(result.end(), extracted_patterns.begin(), extracted_patterns.end()); + auto end = std::chrono::high_resolution_clock::now(); + auto delta = std::chrono::duration_cast(end - start).count(); + std::cout << "[ INFO ][ EXTRACTOR DURATION ] " << it.first << " " << delta << "ms" << std::endl; } return result; } diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/repeat_pattern.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/repeat_pattern.cpp index d98ab6f0287b52..7b293eae252ffc 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/repeat_pattern.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/matchers/subgraph/repeat_pattern.cpp @@ -92,11 +92,12 @@ RepeatPatternExtractor::extract(const std::shared_ptr &model, } for (size_t i = 0; i < start_node_idx.size(); ++i) { try { - to_cache.push_back( - generate_model(nodes[i], ordered_ops[start_node_idx[i]], checked_ops)); + to_cache.push_back(generate_model(nodes[i], checked_ops, extractor_name)); nodes[i].clear(); } catch(std::exception& e) { - std::cout << "[ ERROR ] Impossible to generate network and add to GraphCache: " << e.what() << std::endl; + if (std::string(e.what()) != "Incorrect node number to create model") { + std::cout << "[ WARNING ] Impossible to generate network and add to GraphCache: " < &model, ref_ordered_ops = ref_model->get_ordered_ops(); if (ordered_ops.size() != ref_ordered_ops.size()) return false; - MatchersManager::MatchersMap matchers = { { "generic_single_op", SingleOpMatcher::Ptr(new SingleOpMatcher) }, { "convolutions", ConvolutionsMatcher::Ptr(new ConvolutionsMatcher) }, diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/model.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/model.cpp index eb1d07b709c380..2c9d46bc8877f2 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/model.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/model.cpp @@ -2,96 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/util/file_util.hpp" +#include "functional_test_utils/ov_plugin_cache.hpp" #include "utils/model.hpp" namespace ov { namespace tools { namespace subgraph_dumper { -inline std::unordered_map> -update_nodes(const std::set>& nodes, - const std::shared_ptr& start_node) { - std::unordered_map> model_map; - std::shared_ptr cloned_op = nullptr; - - for (const auto& op : nodes) { - if (ov::op::util::is_parameter(op) || ov::op::util::is_constant(op) || - ov::op::util::is_output(op)) { - continue; - } - cloned_op = clone_node(op, true, false, "Op_" + std::to_string(model_map.size())); - model_map.insert({ op->get_friendly_name(), cloned_op }); - } - - for (const auto& op : nodes) { - if (ov::op::util::is_parameter(op) || ov::op::util::is_constant(op) || - ov::op::util::is_output(op)) { - continue; - } - auto op_name = op->get_friendly_name(); - cloned_op = model_map[op->get_friendly_name()]; - size_t inputs_size = op->inputs().size(); - ov::OutputVector in_out_vector(inputs_size); - int filled_input_idx = -1; - for (size_t in_idx = 0; in_idx < inputs_size; ++in_idx) { - auto in_node = op->get_input_node_ptr(in_idx)->shared_from_this(); - for (size_t in_out_idx = 0; in_out_idx < in_node->outputs().size(); ++in_out_idx) { - for (const auto& target_input : in_node->output(in_out_idx).get_target_inputs()) { - auto out_in_node = target_input.get_node()->shared_from_this(); - if (out_in_node == op) { - auto in_node_name = in_node->get_friendly_name(); - in_out_vector[in_idx] = model_map.count(in_node_name) ? - model_map.at(in_node_name)->output(in_out_idx) : - cloned_op->get_input_node_ptr(in_idx)->output(0); - if (model_map.count(in_node_name)) { - filled_input_idx++; - } - break; - } - } - if (filled_input_idx == in_idx) { - break; - } - } - } - // todo: iefode: check this code - if (filled_input_idx < 0 && op_name != start_node->get_friendly_name()) { - model_map.erase(op_name); - } else if (filled_input_idx >= 0) { - auto name = cloned_op->get_friendly_name(); - model_map[op_name] = cloned_op->clone_with_new_inputs(in_out_vector); - model_map[op_name]->set_friendly_name(name); - } - } - return model_map; -} - -std::pair, std::map> -generate_model(const std::set>& nodes, - const std::shared_ptr& start_node, - std::unordered_set& checked_ops) { - if (nodes.size() < 2) { - throw std::runtime_error("Incorrect node number to create model"); - } - auto model_map = update_nodes(nodes, start_node); - if (model_map.size() < 2) { - throw std::runtime_error("Incorrect node number to create model"); - } - ov::OutputVector results; - std::map input_info; - for (const auto& op : model_map) { - checked_ops.insert(op.first); - auto this_input_info = get_input_info_by_node(op.second); - input_info.insert(this_input_info.begin(), this_input_info.end()); - for (size_t j = 0; j < op.second->outputs().size(); ++j) { - if (op.second->output(j).get_target_inputs().empty()) { - results.push_back(std::make_shared(op.second->output(j))); - } - } - } - return { std::make_shared(results), input_info }; -} - void save_model_status_to_file(const std::map>& caching_status, const std::string& output_dir) { std::string cache_status_path = ov::util::path_join({output_dir, "model_caching_status"}); @@ -104,7 +22,9 @@ void save_model_status_to_file(const std::map find_models(const std::vector &dirs, const std::string& regexp) { +// { models, { not_read_model }} +std::pair, std::pair>> +find_models(const std::vector &dirs, const std::string& regexp) { std::vector models, full_content; for (const auto& dir : dirs) { std::vector dir_content; @@ -120,17 +40,36 @@ std::vector find_models(const std::vector &dirs, const full_content.insert(full_content.end(), dir_content.begin(), dir_content.end()); } } + std::multimap models_sorted_by_size; + std::vector not_read_model; auto in_regex = std::regex(regexp); - for (const auto& file : full_content) { - if (std::regex_match(file, in_regex)) { + for (const auto& model_file : full_content) { + if (std::regex_match(model_file, in_regex)) { try { - models.emplace_back(file); + // models.emplace_back(file); + if (ov::util::file_exists(model_file)) { + auto core = ov::test::utils::PluginCache::get().core(); + auto model_size = core->read_model(model_file)->get_graph_size(); + models_sorted_by_size.insert({ model_size, model_file}); + } else { + continue; + } } catch (std::exception& e) { - std::cout << "[ ERROR ] Impossible to read model: " << file << std::endl << "Exception: " << e.what(); + not_read_model.emplace_back(model_file); + std::cout << "[ ERROR ] Impossible to read model: " << model_file << std::endl << "Exception: " << e.what(); } } } - return models; + // sort model by size with reverse + auto model_cnt = models_sorted_by_size.size(); + models.resize(model_cnt); + auto it = models_sorted_by_size.rbegin(); + for (size_t i = 0; i < model_cnt; ++i) { + models[i] = it->second; + ++it; + } + std::cout << "[ INFO ] Total model number is " << models.size() << std::endl; + return { models, { ModelCacheStatus::NOT_READ, not_read_model } }; } std::map> cache_models( @@ -151,9 +90,7 @@ std::map> cache_models( try { std::shared_ptr function = core->read_model(model); try { - for (auto& cache : caches) { - cache->update_cache(function, model, extract_body); - } + cache->update_cache(function, model, extract_body); } catch (std::exception &e) { std::cout << "[ ERROR ] Model processing failed with exception:" << std::endl << e.what() << std::endl; model_status = ModelCacheStatus::NOT_FULLY_CACHED; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp index ac6eb3adf3c1c6..220d1b00de47d0 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp @@ -10,8 +10,11 @@ namespace subgraph_dumper { std::map get_input_info_by_node(const std::shared_ptr& node) { std::map input_info; for (size_t port_id = 0; port_id < node->get_input_size(); ++port_id) { - InputInfo in_info; std::shared_ptr input_node = node->get_input_node_shared_ptr(port_id); + if (!ov::op::util::is_parameter(input_node) && !ov::op::util::is_constant(input_node)) { + continue; + } + InputInfo in_info; std::string input_name = input_node->get_friendly_name(); if (std::dynamic_pointer_cast(input_node)) { if (ov::shape_size(input_node->get_output_shape(0)) == 0) @@ -80,9 +83,7 @@ std::map get_input_info_by_node(const std::shared_ptr clone_node(std::shared_ptr node, const auto constant_input = ov::get_constant_from_source(node->input(i).get_source_output()); OPENVINO_SUPPRESS_DEPRECATED_END if (constant_input) { - if (is_save_const || constant_input->get_byte_size() <= 1024) { + if (is_save_const || constant_input->get_byte_size() < 1024) { auto in_const = std::make_shared(constant_input->get_element_type(), constant_input->get_shape(), constant_input->get_data_ptr()); @@ -124,8 +125,9 @@ std::shared_ptr clone_node(std::shared_ptr node, param->set_friendly_name(input_name); inputs[i] = param; } - if (!has_parameters && !is_copy_const_node) { - auto cloned_node = clone_node(node, true, true); + std::shared_ptr cloned_node = nullptr; + if (!has_parameters && !is_copy_const_node && !inputs.empty()) { + cloned_node = clone_node(node, true, true, node_name); // std::cout << "The operation: " + node->get_friendly_name() + " does not have parameters! Replace first input to parameter!" << std::endl; auto param = std::make_shared(cloned_node->get_input_element_type(0), cloned_node->get_input_partial_shape(0)); @@ -133,13 +135,26 @@ std::shared_ptr clone_node(std::shared_ptr node, param->set_friendly_name(param_name); auto node_to_replace = cloned_node->get_input_node_shared_ptr(0); ov::replace_node(node_to_replace, param); - return cloned_node; + } else { + cloned_node = node->clone_with_new_inputs(inputs); + cloned_node->set_friendly_name(node_name); } - std::shared_ptr cloned_node = node->clone_with_new_inputs(inputs); - cloned_node->set_friendly_name(node_name); return cloned_node; } +std::shared_ptr convert_const_to_param(const std::shared_ptr& op_to_replace) { + if (op_to_replace->get_byte_size() > 1024) { + auto param = std::make_shared( + op_to_replace->get_output_element_type(0), op_to_replace->get_output_partial_shape(0)); + param->set_friendly_name(op_to_replace->get_friendly_name()); + if (param != nullptr) { + ov::replace_node(op_to_replace, param); + } + return param; + } + return nullptr; +} + std::shared_ptr generate_model_by_node(const std::shared_ptr& node) { static size_t model_cnt = 0; auto cloned_node = clone_node(node); diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp index e09230e04419ef..c7810c5db1af82 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp @@ -87,8 +87,6 @@ class GraphCacheUnitTest : public GraphCacheFuncTest, }; TEST_F(GraphCacheUnitTest, update_cache_by_graph) { - // const std::shared_ptr& model, const std::string& model_path, - // const std::map& input_info, size_t model_op_cnt Model_2 test; auto model_to_cache = test.get(); std::map in_info; @@ -97,7 +95,7 @@ TEST_F(GraphCacheUnitTest, update_cache_by_graph) { in_info.insert({ op->get_friendly_name(), InputInfo()}); } } - this->update_cache(model_to_cache, test_model_path, in_info, model_to_cache->get_ordered_ops().size()); + this->update_cache(model_to_cache, test_model_path, in_info, "test_extractor", model_to_cache->get_ordered_ops().size()); ASSERT_EQ(m_graph_cache.size(), 1); } } // namespace diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp index e47b38545a1589..42d8379f7223e3 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp @@ -64,11 +64,12 @@ class MetaInfoFuncTest : public SubgraphsDumperBaseTest { std::string test_model_path, test_model_name; std::map test_in_info; std::map test_model_info; - std::string test_artifacts_dir; + std::string test_artifacts_dir, test_extractor_name; void SetUp() override { SubgraphsDumperBaseTest::SetUp(); test_model_path = "test_model_path.xml"; + test_extractor_name = "test_extractor"; test_model_name = ov::test::utils::replaceExt(test_model_path, ""); test_in_info = {{ "test_in_0", InputInfo(DEFAULT_MIN_VALUE, 1, true) }}; test_model_info = {{ test_model_name, ModelInfo(test_model_path, 5) }}; @@ -86,7 +87,8 @@ TEST_F(MetaInfoFuncTest, constructor) { ASSERT_NO_THROW(auto meta = MetaInfo(test_model_name)); ASSERT_NO_THROW(auto meta = MetaInfo(test_model_name, test_in_info)); ASSERT_NO_THROW(auto meta = MetaInfo(test_model_name, test_in_info, 2)); - ASSERT_NO_THROW(auto meta = MetaInfo(test_model_name, test_in_info, 3)); + ASSERT_NO_THROW(auto meta = MetaInfo(test_model_name, test_in_info, 3, 1, test_extractor_name)); + ASSERT_NO_THROW(auto meta = MetaInfo(test_model_name, test_in_info, 3, 5, test_extractor_name, 5)); } TEST_F(MetaInfoFuncTest, get_input_info) { @@ -101,9 +103,15 @@ TEST_F(MetaInfoFuncTest, get_model_info) { ASSERT_EQ(test_meta.get_model_info(), test_model_info); } +TEST_F(MetaInfoFuncTest, get_any_extractor) { + auto test_meta = MetaInfo(test_model_path, test_in_info, 5, 3, test_extractor_name); + ASSERT_NO_THROW(test_meta.get_any_extractor()); + ASSERT_EQ(test_meta.get_any_extractor(), test_extractor_name); +} + TEST_F(MetaInfoFuncTest, update) { std::map test_in_info = {{ "test_in_0", InputInfo(DEFAULT_MIN_VALUE, 1, true) }}; - auto test_meta = MetaInfo(test_model_name, test_in_info); + auto test_meta = MetaInfo(test_model_name, test_in_info, 1, 1, test_extractor_name); std::map test_input_info_1 = {{ "test_in_0", InputInfo(0, 1, true) }}; std::string test_model_1 = "test_model_1"; std::string test_model_path_1 = ov::util::path_join({ "path", "to", test_model_1 + ".xml"}); @@ -111,6 +119,7 @@ TEST_F(MetaInfoFuncTest, update) { ASSERT_ANY_THROW(test_meta.update(test_model_path_1, {{ "test_in_1", InputInfo() }})); ASSERT_ANY_THROW(test_meta.update(test_model_path_1, {{ "test_in_0", InputInfo(0, 1, false) }})); ASSERT_NO_THROW(test_meta.update(test_model_path_1, test_input_info_1)); + ASSERT_NO_THROW(test_meta.update(test_model_path_1, test_input_info_1, 1, 2, "test_extractor_1")); ASSERT_NO_THROW(test_meta.update(test_model_path_1, test_input_info_1, 2)); } @@ -135,6 +144,7 @@ class MetaInfoUnitTest : public MetaInfoFuncTest, TEST_F(MetaInfoUnitTest, serialize) { std::string seriliazation_path(ov::util::path_join({test_artifacts_dir, "test_meta.meta"})); + this->extractors = { "extractor_0", "extractor_1" }; this->serialize(seriliazation_path); ASSERT_TRUE(ov::util::file_exists(seriliazation_path)); @@ -170,6 +180,24 @@ TEST_F(MetaInfoUnitTest, serialize) { ASSERT_EQ(input_info[in_xml].ranges.max, max_xml); } } + { + auto extractors_node = doc.child("meta_info").child("extractors"); + std::unordered_set xml_extractors; + for (const auto& in_info_xml : extractors_node.children()) { + xml_extractors.insert(std::string(in_info_xml.attribute("name").value())); + } + ASSERT_EQ(xml_extractors, this->extractors); + } +} + +TEST_F(MetaInfoUnitTest, read_meta_from_file) { + std::string seriliazation_path(ov::util::path_join({test_artifacts_dir, "test_meta.meta"})); + this->extractors = { "extractor_0", "extractor_1" }; + this->serialize(seriliazation_path); + auto new_meta = MetaInfo::read_meta_from_file(seriliazation_path); + ASSERT_TRUE(this->extractors.count(new_meta.get_any_extractor())); + ASSERT_EQ(new_meta.get_input_info(), this->input_info); + ASSERT_EQ(new_meta.get_model_info(), this->model_info); } TEST_F(MetaInfoUnitTest, update) { @@ -185,9 +213,11 @@ TEST_F(MetaInfoUnitTest, update) { ASSERT_EQ(this->model_info[test_model_1].model_paths.size(), 1); ASSERT_EQ(this->model_info[test_model_1].this_op_cnt, 2); test_model_path_1 = ov::util::path_join({ "path", "to", "test", test_model_1 + ".xml"}); - this->update(test_model_path_1, test_meta_1); + this->update(test_model_path_1, test_meta_1, 0, 1, "test_extractor"); ASSERT_EQ(this->model_info[test_model_1].model_paths.size(), 2); ASSERT_EQ(this->model_info[test_model_1].this_op_cnt, 3); + ASSERT_EQ(this->model_info[test_model_1].this_op_cnt, 3); + ASSERT_EQ(this->extractors, std::unordered_set({"test_extractor"})); } TEST_F(MetaInfoUnitTest, get_model_name_by_path) { @@ -204,4 +234,10 @@ TEST_F(MetaInfoUnitTest, get_graph_priority) { ASSERT_TRUE(this->get_graph_priority() >= 0 && this->get_graph_priority() <= 1); } +TEST_F(MetaInfoUnitTest, get_any_extractor) { + auto meta = MetaInfo(test_model_name, test_in_info, 1, 1, "test_extractor"); + ASSERT_NO_THROW(meta.get_any_extractor()); + ASSERT_EQ(meta.get_any_extractor(), "test_extractor"); +} + } // namespace \ No newline at end of file diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/fused_names.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/fused_names.cpp index 96bbe8443c1182..591f01c66cd52f 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/fused_names.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/fused_names.cpp @@ -4,6 +4,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "matchers/subgraph/fused_names.hpp" #include "utils/model.hpp" @@ -21,50 +23,44 @@ using namespace ov::tools::subgraph_dumper; class FusedNamesExtractorTest : public FusedNamesExtractor, public SubgraphsDumperBaseTest { protected: - bool is_match(const std::shared_ptr& model) { - size_t graph_cnt = 0; - { - auto compiled_names = extract_compiled_model_names(model); - std::vector op_cnt; - for (const auto& op : model->get_ordered_ops()) { - if (this->is_node_to_skip(op)) { - op_cnt.push_back(1); - continue; - } - auto op_name = op->get_friendly_name(); - if (!compiled_names.count(op_name)) { - op_cnt.push_back(1); - } else if (op_cnt.size() > 0) { - ++op_cnt[op_cnt.size() - 1]; - } - } - for (const auto& cnt : op_cnt) { - if (cnt > 1) { - ++graph_cnt; - } + void is_match(const std::shared_ptr& model) { + auto models_1 = this->extract(model); + auto models_2 = this->extract(model); + ASSERT_EQ(models_1.size(), models_2.size()); + auto it_model_1 = models_1.begin(); + auto it_model_2 = models_2.begin(); + while (it_model_1 != models_1.end() || it_model_2 != models_2.end()) { + SubgraphExtractor extractor; + ASSERT_TRUE(extractor.match(std::get<0>(*it_model_1), std::get<0>(*it_model_2))); + auto in_info_1 = std::get<1>(*it_model_1); + auto in_info_2 = std::get<1>(*it_model_2); + for (const auto& in_info : in_info_1) { + ASSERT_TRUE(in_info_2.count(in_info.first)); + ASSERT_EQ(in_info_2[in_info.first], in_info.second); } + ASSERT_EQ(std::get<2>(*it_model_1), std::get<2>(*it_model_2)); + ++it_model_1; + ++it_model_2; } - auto models = this->extract(model); - return models.size() == graph_cnt; } }; TEST_F(FusedNamesExtractorTest, extract_0) { auto test_model = Model_0(); auto model = test_model.get(); - ASSERT_TRUE(is_match(model)); + is_match(model); } TEST_F(FusedNamesExtractorTest, extract_1) { auto test_model = Model_1(); auto model = test_model.get(); - ASSERT_TRUE(is_match(model)); + is_match(model); } TEST_F(FusedNamesExtractorTest, extract_2) { auto test_model = Model_2(); auto model = test_model.get(); - ASSERT_TRUE(is_match(model)); + is_match(model); } } // namespace diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/manager.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/manager.cpp index f94a7e7d332fa2..b43ffe33cfb687 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/manager.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/manager.cpp @@ -27,6 +27,7 @@ class ExtractorsManagerTest : public ExtractorsManager, { std::shared_ptr test_parameter = std::make_shared(ov::element::f32, ov::Shape{1, 2}); + test_parameter->set_friendly_name("test_parameter_0"); std::shared_ptr test_abs = std::make_shared(test_parameter); std::shared_ptr test_res = @@ -37,6 +38,7 @@ class ExtractorsManagerTest : public ExtractorsManager, { std::shared_ptr test_parameter = std::make_shared(ov::element::f32, ov::Shape{2, 5}); + test_parameter->set_friendly_name("test_parameter_1"); std::shared_ptr test_abs = std::make_shared(test_parameter); std::shared_ptr test_res = @@ -86,9 +88,28 @@ TEST_F(ExtractorsManagerTest, match) { ASSERT_FALSE(this->match(test_model_0_1, test_model_1)); } +TEST_F(ExtractorsManagerTest, match_with_in_info) { + this->set_extractors(test_map); + std::map test_in_info({{"test_parameter_0", InputInfo()}}), test_in_info_1({{"test_parameter_1", InputInfo(1, 2, true)}}); + ASSERT_NO_THROW(this->match(test_model_0_0, test_model_0_1, test_in_info, test_in_info)); + ASSERT_TRUE(this->match(test_model_0_0, test_model_0_1, test_in_info, test_in_info)); + ASSERT_NO_THROW(this->match(test_model_0_0, test_model_0_1, test_in_info, test_in_info_1)); + ASSERT_FALSE(this->match(test_model_0_0, test_model_0_1, test_in_info, test_in_info_1)); + ASSERT_NO_THROW(this->match(test_model_0_1, test_model_1, test_in_info, test_in_info)); + ASSERT_FALSE(this->match(test_model_0_1, test_model_1, test_in_info, test_in_info)); +} + TEST_F(ExtractorsManagerTest, extract) { this->set_extractors(test_map); ASSERT_NO_THROW(this->extract(test_model_0_0)); } +TEST_F(ExtractorsManagerTest, align_input_info) { + std::map test_in_info({{"test_parameter_0", InputInfo()}}), test_in_info_ref({{"test_parameter_1", InputInfo()}}); + ASSERT_NE(test_in_info, test_in_info_ref); + ASSERT_NO_THROW(this->align_input_info(test_model_0_0, test_model_0_1, test_in_info, test_in_info_ref)); + auto c = this->align_input_info(test_model_0_0, test_model_0_1, test_in_info, test_in_info_ref); + ASSERT_EQ(c, test_in_info_ref); +} + } // namespace diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/repeat_pattern.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/repeat_pattern.cpp index 192a285a49cfae..a9da7845f1098c 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/repeat_pattern.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/matchers/subgraph/repeat_pattern.cpp @@ -27,7 +27,7 @@ class RepeatPatternExtractorTest : public RepeatPatternExtractor, for (const auto& model : models) { bool is_match = false; for (const auto& ref_model : ref_models) { - if (this->match(model.first, ref_model)) { + if (this->match(std::get<0>(model), ref_model)) { is_match = true; ++match_numbers; break; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/skip_tests_config.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/skip_tests_config.cpp index b98b2a51f1a870..ddd305cd46364f 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/skip_tests_config.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/skip_tests_config.cpp @@ -5,12 +5,6 @@ #include "functional_test_utils/skip_tests_config.hpp" std::vector disabledTestPatterns() { - std::vector retVector{ - // todo: enable these tests with graph cache enabling - R"(.*RepeatPatternExtractorTest.*extract_1.*)", - R"(.*ModelUtilsTest.*generate_.*)", - R"(.*GraphCacheFuncTest.*update_cache.*)", - R"(.*FusedNamesExtractorTest.*)", - }; + std::vector retVector {}; return retVector; } diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_1.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_1.hpp index 2af5be4cea1301..5893fb949f774a 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_1.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_1.hpp @@ -11,6 +11,7 @@ #include "openvino/op/relu.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/result.hpp" +#include "openvino/op/subtract.hpp" class Model_1 { public: @@ -23,7 +24,7 @@ class Model_1 { // | | | | // ------------ ------------ // | | - // add add param param + // add Multiply param param // | | | | // ------------------------------- -------------- // | | @@ -33,7 +34,7 @@ class Model_1 { // | | // ------------------------------------------- // | - // Multiply + // subtract // | // result size_t op_idx = 0; @@ -82,16 +83,16 @@ class Model_1 { std::make_shared(test_abs_0_1, 0, 10); test_clamp_0_1->set_friendly_name("Op_" + std::to_string(op_idx++)); - std::shared_ptr test_add_0_0 = - std::make_shared(test_relu_0_0, test_clamp_0_1); - test_add_0_0->set_friendly_name("Op_" + std::to_string(op_idx++)); - std::shared_ptr test_multiply_0_0 = - std::make_shared(test_add_0, test_add_0_0); + std::make_shared(test_relu_0_0, test_clamp_0_1); + test_multiply_0_0->set_friendly_name("Op_" + std::to_string(op_idx++)); + + std::shared_ptr test_multiply_0_1 = + std::make_shared(test_add_0, test_multiply_0_0); test_multiply_0_0->set_friendly_name("Op_" + std::to_string(op_idx++)); std::shared_ptr test_relu_0_1 = - std::make_shared(test_multiply_0_0); + std::make_shared(test_multiply_0_1); test_relu_0_1->set_friendly_name("Op_" + std::to_string(op_idx++)); std::shared_ptr test_parameter_1_0 = @@ -107,8 +108,8 @@ class Model_1 { std::make_shared(test_multiply_1_1); test_relu_1_1->set_friendly_name("Op_" + std::to_string(op_idx++)); - std::shared_ptr test_add = - std::make_shared(test_relu_0_1, test_relu_1_1); + std::shared_ptr test_add = + std::make_shared(test_relu_0_1, test_relu_1_1); test_add->set_friendly_name("Op_" + std::to_string(op_idx++)); std::shared_ptr test_res = @@ -142,67 +143,14 @@ class Model_1 { { std::shared_ptr test_parameter_0 = std::make_shared(ov::element::f32, ov::Shape{1, 2}); - std::shared_ptr test_abs_0 = - std::make_shared(test_parameter_0); - std::shared_ptr test_relu_0 = - std::make_shared(test_abs_0); - std::shared_ptr test_parameter_1 = - std::make_shared(ov::element::f32, ov::Shape{2, 1}); - std::shared_ptr test_add = - std::make_shared(test_relu_0, test_parameter_1); - std::shared_ptr res = - std::make_shared(test_add); - auto ref_model = std::make_shared(ov::ResultVector{res}, - ov::ParameterVector{test_parameter_0, test_parameter_1}); - ref.push_back(ref_model); - } - { - std::shared_ptr test_parameter_0 = - std::make_shared(ov::element::f32, ov::Shape{1, 2}); - std::shared_ptr test_parameter_1 = - std::make_shared(ov::element::f32, ov::Shape{1, 2}); std::shared_ptr test_abs_1 = - std::make_shared(test_parameter_1); + std::make_shared(test_parameter_0); std::shared_ptr test_clamp_1 = std::make_shared(test_abs_1, 0, 10); std::shared_ptr res = std::make_shared(test_clamp_1); auto ref_model = std::make_shared(ov::ResultVector{res}, - ov::ParameterVector{test_parameter_0, test_parameter_1}); - ref.push_back(ref_model); - } - { - std::shared_ptr test_parameter_0 = - std::make_shared(ov::element::f32, ov::Shape{1, 2}); - std::shared_ptr test_parameter_1 = - std::make_shared(ov::element::f32, ov::Shape{1, 2}); - std::shared_ptr test_abs_1 = - std::make_shared(test_parameter_1); - std::shared_ptr test_clamp_1 = - std::make_shared(test_abs_1, 0, 10); - std::shared_ptr test_add = - std::make_shared(test_parameter_0, test_clamp_1); - std::shared_ptr res = - std::make_shared(test_add); - auto ref_model = std::make_shared(ov::ResultVector{res}, - ov::ParameterVector{test_parameter_0, test_parameter_1}); - ref.push_back(ref_model); - } - { - std::shared_ptr test_parameter_0 = - std::make_shared(ov::element::f32, ov::Shape{1, 2}); - std::shared_ptr test_parameter_1 = - std::make_shared(ov::element::f32, ov::Shape{1, 2}); - std::shared_ptr test_abs_1 = - std::make_shared(test_parameter_1); - std::shared_ptr test_clamp_1 = - std::make_shared(test_abs_1, 0, 10); - std::shared_ptr test_add = - std::make_shared(test_parameter_0, test_clamp_1); - std::shared_ptr res = - std::make_shared(test_add); - auto ref_model = std::make_shared(ov::ResultVector{res}, - ov::ParameterVector{test_parameter_0, test_parameter_1}); + ov::ParameterVector{test_parameter_0}); ref.push_back(ref_model); } { diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_2.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_2.hpp index 72d28924354595..fd7a24cbe49e3d 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_2.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/test_models/model_2.hpp @@ -35,7 +35,7 @@ class Model_2 { std::shared_ptr test_parameter_0 = std::make_shared(ov::element::f32, ov::Shape{2, 5}); std::shared_ptr test_abs = - std::make_shared(test_parameter_0); + std::make_shared(test_parameter); std::shared_ptr test_clamp = std::make_shared(test_abs, 0, 10); std::shared_ptr test_relu = diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/utils/model.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/utils/model.cpp index 762623963a8cd6..a5bb560f486e1e 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/utils/model.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/utils/model.cpp @@ -16,21 +16,13 @@ using namespace ov::tools::subgraph_dumper; using ModelUtilsTest = SubgraphsDumperBaseTest; -std::pair, std::set>> +std::set> get_functional_ops(const std::shared_ptr& model) { - std::shared_ptr start_node = nullptr; std::set> nodes; - for (const auto& op : model->get_ordered_ops()) { - if (ov::op::util::is_parameter(op) || ov::op::util::is_output(op)) { - continue; - } - if (start_node == nullptr) { - start_node = op; - } nodes.insert(op); } - return { start_node, nodes }; + return nodes; } TEST_F(ModelUtilsTest, generate_0) { @@ -39,13 +31,8 @@ TEST_F(ModelUtilsTest, generate_0) { { std::unordered_set checked_ops; auto func_ops = get_functional_ops(test_model); - auto model_with_in_info = generate_model(func_ops.second, func_ops.first, checked_ops); - recovered_model = model_with_in_info.first; - for (const auto& op : recovered_model->get_ordered_ops()) { - if (ov::op::util::is_parameter(op) || ov::op::util::is_constant(op)) { - ASSERT_TRUE(model_with_in_info.second.count(op->get_friendly_name())); - } - } + auto model_with_in_info = generate_model(func_ops, checked_ops, "test_extractor"); + recovered_model = std::get<0>(model_with_in_info); } { SubgraphExtractor extractor; @@ -59,13 +46,8 @@ TEST_F(ModelUtilsTest, generate_1) { { std::unordered_set checked_ops; auto func_ops = get_functional_ops(test_model); - auto model_with_in_info = generate_model(func_ops.second, func_ops.first, checked_ops); - recovered_model = model_with_in_info.first; - for (const auto& op : recovered_model->get_ordered_ops()) { - if (ov::op::util::is_parameter(op) || ov::op::util::is_constant(op)) { - ASSERT_TRUE(model_with_in_info.second.count(op->get_friendly_name())); - } - } + auto model_with_in_info = generate_model(func_ops, checked_ops, "test_extractor"); + recovered_model = std::get<0>(model_with_in_info); } { SubgraphExtractor extractor; @@ -79,13 +61,9 @@ TEST_F(ModelUtilsTest, generate_2) { { std::unordered_set checked_ops; auto func_ops = get_functional_ops(test_model); - auto model_with_in_info = generate_model(func_ops.second, func_ops.first, checked_ops); - recovered_model = model_with_in_info.first; - for (const auto& op : recovered_model->get_ordered_ops()) { - if (ov::op::util::is_parameter(op) || ov::op::util::is_constant(op)) { - ASSERT_TRUE(model_with_in_info.second.count(op->get_friendly_name())); - } - } + auto model_with_in_info = generate_model(func_ops, checked_ops, "extract_model"); + recovered_model = std::get<0>(model_with_in_info); + auto in_info = std::get<1>(model_with_in_info); } { SubgraphExtractor extractor; diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp index b5847562404372..7b2e226425981b 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp @@ -239,6 +239,7 @@ void ReadIRTest::SetUp() { auto it = inputMap.find(next_node->get_type_info()); auto tensor = it->second(next_node, function->get_parameter_index(param), param->get_element_type(), param->get_shape()); auto const_node = std::make_shared(tensor); + const_node->set_friendly_name(param->get_friendly_name()); ov::replace_node(param, const_node); parameter_to_remove.push_back(param); utils::ConstRanges::reset(); @@ -246,6 +247,11 @@ void ReadIRTest::SetUp() { for (const auto& param : parameter_to_remove) { function->remove_parameter(param); } + ov::pass::Manager manager; + manager.register_pass("test.xml", "test.bin"); + manager.run_passes(function); + auto b = function->get_parameters(); + auto c = 0; } bool hasDynamic = false; diff --git a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp index 760496faecf83b..609acf31bf2ab1 100644 --- a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp +++ b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp @@ -958,6 +958,7 @@ InputsMap getInputMap() { #include "openvino/opsets/opset9_tbl.hpp" #include "openvino/opsets/opset10_tbl.hpp" #include "openvino/opsets/opset11_tbl.hpp" +#include "openvino/opsets/opset12_tbl.hpp" #include "ov_ops/opset_private_tbl.hpp" #undef _OPENVINO_OP_REG From d6e94212b89524703b4654bc1e81bbaee7379dd6 Mon Sep 17 00:00:00 2001 From: Tomasz Adamowicz Date: Thu, 10 Aug 2023 15:54:51 +0200 Subject: [PATCH 26/51] Temporary deactivation of sporadically failing tests (#19118) --- .../functional/shared_tests_instances/skip_tests_config.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/intel_gna/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_gna/tests/functional/shared_tests_instances/skip_tests_config.cpp index 82efa923997c9b..106b7696ccec40 100644 --- a/src/plugins/intel_gna/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_gna/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -100,5 +100,7 @@ std::vector disabledTestPatterns() { R"(.*smoke_MultiHeteroOVGetMetricPropsTest.*OVGetMetricPropsTest.*(AVAILABLE_DEVICES|OPTIMIZATION_CAPABILITIES|RANGE_FOR_ASYNC_INFER_REQUESTS|RANGE_FOR_STREAMS).*)", // TODO: Issue: 111556 R"(.*SplitConvTest.CompareWithRefImpl.*IS=\(1.(128|256)\).*IC=4.*OC=4.*configItem=GNA_DEVICE_MODE_GNA_SW_FP32)", + // TODO: Issue: 114149 + R"(.*smoke_Decompose2DConv.*)", }; } From 08688178cc48472dfa532939c9fdf653a54b9d26 Mon Sep 17 00:00:00 2001 From: Georgy Krivoruchko Date: Thu, 10 Aug 2023 07:35:45 -0700 Subject: [PATCH 27/51] Updated opset version to the latest (#19119) --- .../op_conformance_runner/src/read_ir/read_ir_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp index 8a0092bc0204e5..0c7fc52e87926b 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir_tests.cpp @@ -39,7 +39,7 @@ TEST_P(ReadIRTest, DISABLED_ImportExport) { ReadIRTest::getTestCaseName); \ // It should point on latest opset which contains biggest list of operations -#include "openvino/opsets/opset10_tbl.hpp" +#include "openvino/opsets/opset12_tbl.hpp" #undef _OPENVINO_OP_REG INSTANTIATE_TEST_SUITE_P(conformance_other, From dab01d286e6dad3f8d6bc8d11d44ea62ad46eff9 Mon Sep 17 00:00:00 2001 From: Georgy Krivoruchko Date: Thu, 10 Aug 2023 07:36:11 -0700 Subject: [PATCH 28/51] Aligned test name with latest master (#19123) --- .../conformance/test_runner/conformance_infra/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp index b501519c15bbce..81d6a212dad7e7 100644 --- a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp @@ -31,7 +31,7 @@ void RegisterTestCustomQueries(void) { "OpImplCheck_CheckPluginImpl($__test_id)"; // Query expected in case of a refused results extTestNames[testName] = "$opName"; - testName = "ReadIR"; + testName = "Inference"; extTestQueries[testName + "_ON_START"] = "ReadIRTest_ReadIR($__test_id, '$opName', '$opSet', '$Type', " "'$targetDevice', '$targetDeviceArch', '$targetDeviceName', '$hashXml', '$pathXml', '$config', " From 8e103bcf39f2fd7847c6a58e6ee7027fa389355d Mon Sep 17 00:00:00 2001 From: Shuangji Yang Date: Fri, 11 Aug 2023 02:25:41 +0800 Subject: [PATCH 29/51] fix bug on conversion of gather to sequeeze (#19012) Co-authored-by: Ivan Tikhonov --- .../common_optimizations/nop_elimination.cpp | 4 ++- .../common_optimizations/nop_elimination.cpp | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp b/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp index 0806a8bc55ee7c..1293e38fe31066 100644 --- a/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp @@ -66,8 +66,10 @@ static bool simplify_gather(shared_ptr node) { if (!constant_indices) return false; // case_3: if input_shape is (1,3,5,5) and axis = 0, indices = 0, then gather is just a Squeeze + const auto constant_indices_size = constant_indices->get_output_shape(0).size(); const auto const_indices = constant_indices->cast_vector(); - if (data.get_shape()[axis] == 1 && const_indices.size() == 1 && const_indices[0] == 0) { + if (data.get_shape()[axis] == 1 && (constant_indices_size == 0 || constant_indices_size == 1) && + const_indices[0] == 0) { auto squeeze = std::make_shared(gather->input_value(0), gather->input_value(2)); squeeze->set_friendly_name(gather->get_friendly_name()); ov::copy_runtime_info(gather, squeeze); diff --git a/src/common/transformations/tests/common_optimizations/nop_elimination.cpp b/src/common/transformations/tests/common_optimizations/nop_elimination.cpp index 3f234a37b1925a..c2cf6b37e05840 100644 --- a/src/common/transformations/tests/common_optimizations/nop_elimination.cpp +++ b/src/common/transformations/tests/common_optimizations/nop_elimination.cpp @@ -1339,6 +1339,34 @@ TEST(nop_elimination, gather_to_squeeze) { run_and_check(func_axis_3); } +TEST(nop_elimination, not_gather_to_squeeze_with_vector_indices) { + auto generate_func = [](int64_t gather_axis) { + ov::Shape shape{3, 3, 4, 4}; + shape[gather_axis] = 1; + auto arg = std::make_shared(element::f32, shape); + auto indices = op::Constant::create(element::i64, Shape{1, 1}, vector{0}); + auto axis = op::Constant::create(element::i64, Shape{}, vector{gather_axis}); + auto gather = std::make_shared(arg, indices, axis); + return std::make_shared(NodeVector{gather}, ParameterVector{arg}); + }; + + auto func_axis_0 = generate_func(0); + auto func_axis_1 = generate_func(1); + auto func_axis_2 = generate_func(2); + auto func_axis_3 = generate_func(3); + pass::Manager pass_manager; + pass_manager.register_pass(); + auto run_and_check = [&](std::shared_ptr& func) { + pass_manager.run_passes(func); + EXPECT_EQ(count_ops_of_type(func), 1); + EXPECT_EQ(count_ops_of_type(func), 0); + }; + run_and_check(func_axis_0); + run_and_check(func_axis_1); + run_and_check(func_axis_2); + run_and_check(func_axis_3); +} + TEST_F(TransformationTestsF, Nopv1Broadcast) { { auto data = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); From 726abefbaa619c55a37445a506b6478abeddee3d Mon Sep 17 00:00:00 2001 From: Anastasiia Pnevskaia Date: Thu, 10 Aug 2023 21:14:13 +0200 Subject: [PATCH 30/51] Update reminder message in MO and OVC. (#19132) * Updated reminder. * Updated reminder. --- tools/mo/openvino/tools/mo/utils/get_ov_update_message.py | 4 ++-- tools/ovc/openvino/tools/ovc/get_ov_update_message.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py b/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py index ca767b1c3f05f8..0bb1ac74bd2c15 100644 --- a/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py +++ b/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py @@ -9,10 +9,10 @@ def get_ov_update_message(): - expected_update_date = datetime.date(year=2023, month=12, day=1) + expected_update_date = datetime.date(year=2024, month=12, day=1) current_date = datetime.date.today() - link = 'https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html?cid=other&source=prod&campid=ww_2023_bu_IOTG_OpenVINO-2023-0&content=upg_all&medium=organic' + link = 'https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html?cid=other&source=prod&campid=ww_2023_bu_IOTG_OpenVINO-2023-1&content=upg_all&medium=organic' return msg_fmt.format(link) if current_date >= expected_update_date else None diff --git a/tools/ovc/openvino/tools/ovc/get_ov_update_message.py b/tools/ovc/openvino/tools/ovc/get_ov_update_message.py index eb94f4e5f7e3b2..fe3f296f87ca85 100644 --- a/tools/ovc/openvino/tools/ovc/get_ov_update_message.py +++ b/tools/ovc/openvino/tools/ovc/get_ov_update_message.py @@ -8,10 +8,10 @@ def get_ov_update_message(): - expected_update_date = datetime.date(year=2023, month=12, day=1) + expected_update_date = datetime.date(year=2024, month=12, day=1) current_date = datetime.date.today() - link = 'https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html?cid=other&source=prod&campid=ww_2023_bu_IOTG_OpenVINO-2023-0&content=upg_all&medium=organic' + link = 'https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html?cid=other&source=prod&campid=ww_2023_bu_IOTG_OpenVINO-2023-1&content=upg_all&medium=organic' return msg_fmt.format(link) if current_date >= expected_update_date else None From 5f71679fb9ec77a9b26ee965c0bdb55ef938937c Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Thu, 10 Aug 2023 21:28:38 +0200 Subject: [PATCH 31/51] [PT FE] Use weight share switch in frontend (#18993) * [PT FE] Use weight share switch in frontend * Return static for function * Update src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py * Fix issue with quantized constants * Add tests for shared --- .../openvino/frontend/pytorch/ts_decoder.py | 42 ++++++++------ .../src/openvino/frontend/pytorch/utils.py | 38 ++++++------ .../test_mo_convert_pytorch.py | 58 +++++++++++++++++++ .../mo/moc_frontend/pytorch_frontend_utils.py | 2 +- .../moc_frontend/pytorch_frontend_utils.py | 2 +- 5 files changed, 105 insertions(+), 37 deletions(-) diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py index e07a23dc5cccc1..1090dce0163ced 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py @@ -7,7 +7,7 @@ from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType from openvino.runtime import op, PartialShape, Type as OVType, OVAny -from openvino.frontend.pytorch.utils import ivalue_to_constant, get_value_from_getattr, pt_to_ov_type_map +from openvino.frontend.pytorch.utils import ivalue_to_constant, get_value_from_getattr, pt_to_ov_type_map, torch_tensor_to_ov_const from openvino.runtime import opset11 as ops import typing @@ -29,11 +29,12 @@ def forward(self, {input_sign}): class TorchScriptPythonDecoder (Decoder): - def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=None): + def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=None, shared_memory=True): Decoder.__init__(self) # We store every decoder created by this decoder so that all them are not deleted until the first decoder is deleted self.m_decoders = [] self._input_signature = None + self._shared_memory = shared_memory if graph_element is None: try: pt_module = self._get_scripted_model(pt_module, example_input) @@ -43,10 +44,9 @@ def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=N help_msg = "" else: msg = "scripting" - help_msg = "Tracing sometimes provide better results, " - "please provide valid 'example_input' argument. " + help_msg = "\nTracing sometimes provide better results, please provide valid 'example_input' argument. " raise RuntimeError( - f"Couldn't get TorchScript module by {msg}. {help_msg}" + f"Couldn't get TorchScript module by {msg}. With exception:\n{e}\n {help_msg}" "You can also provide TorchScript module that you obtained" " yourself, please refer to PyTorch documentation: " "https://pytorch.org/tutorials/beginner/Intro_to_TorchScript_tutorial.html.") @@ -160,8 +160,11 @@ def prepare_example_inputs_and_model(inputs, input_params, model): except Exception: try: scripted = torch.jit.script(pt_module) - except Exception: - scripted = torch.jit.trace(pt_module, **input_parameters, strict=False) + except Exception as se: + try: + scripted = torch.jit.trace(pt_module, **input_parameters, strict=False) + except Exception as te: + raise f"Tracing failed with exception {te}\nScripting failed with exception: {se}" skip_freeze = False for n in scripted.inlined_graph.nodes(): # TODO: switch off freezing for all traced models @@ -283,7 +286,7 @@ def get_subgraph_size(self) -> int: def visit_subgraph(self, node_visitor) -> None: # make sure topological order is satisfied for node in self.graph_element.nodes(): - decoder = TorchScriptPythonDecoder(self.pt_module, node, alias_db=self.alias_db) + decoder = TorchScriptPythonDecoder(self.pt_module, node, alias_db=self.alias_db, shared_memory=self._shared_memory) self.m_decoders.append(decoder) node_visitor(decoder) @@ -299,7 +302,7 @@ def get_subgraphs(self) -> list: return list(self.graph_element.blocks()) def get_subgraph_decoder(self, index: int): - decoder = TorchScriptPythonDecoder(self.pt_module, self.get_subgraphs()[index], alias_db=self.alias_db) + decoder = TorchScriptPythonDecoder(self.pt_module, self.get_subgraphs()[index], alias_db=self.alias_db, shared_memory=self._shared_memory) self.m_decoders.append(decoder) return decoder @@ -336,7 +339,7 @@ def mark_node(self, node): return node @staticmethod - def convert_quantized_tensor(qtensor: torch.Tensor): + def convert_quantized_tensor(qtensor: torch.Tensor, shared_memory: bool): # need to represent as Constant(u8) -> Convert(f32) -> Subtract(zero_point) -> Multiply (scale) qscheme = qtensor.qscheme() # torch.per_channel_affine (per_tensor) if qscheme == torch.per_channel_affine: @@ -349,8 +352,8 @@ def convert_quantized_tensor(qtensor: torch.Tensor): new_shape[axis] = -1 zero_point_bc = np.reshape(zero_point, new_shape) scale_bc = np.reshape(scale, new_shape) - - int8_const = op.Constant(int8_tensor.numpy()) + + int8_const = torch_tensor_to_ov_const(int8_tensor, shared_memory=shared_memory) convert = ops.convert(int8_const, np.float32) sub = ops.subtract(convert, zero_point_bc) return ops.multiply(sub, scale_bc).outputs() @@ -359,7 +362,7 @@ def convert_quantized_tensor(qtensor: torch.Tensor): scale = np.float32(qtensor.q_scale()) zero_point = np.float32(qtensor.q_zero_point()) - int8_const = op.Constant(int8_tensor.numpy()) + int8_const = torch_tensor_to_ov_const(int8_tensor, shared_memory=shared_memory) convert = ops.convert(int8_const, np.float32) sub = ops.subtract(convert, zero_point) return ops.multiply(sub, scale).outputs() @@ -372,7 +375,7 @@ def try_decode_get_attr(self): # We assume this is __torch__.torch.classes.quantized.Conv2dPackedParamsBase or __torch__.torch.classes.quantized.LinearPackedParamsBase # TODO: but can be anything. Figure a better way to distinguish weight, bias = pt_value.unpack() - res = self.convert_quantized_tensor(weight) + res = self.convert_quantized_tensor(weight, self._shared_memory) if isinstance(bias, torch.Tensor): res += ivalue_to_constant(bias) else: @@ -383,12 +386,15 @@ def try_decode_get_attr(self): padding = pt_value.padding() dilation = pt_value.dilation() groups = pt_value.groups() - res += ivalue_to_constant(stride) + ivalue_to_constant(padding) + ivalue_to_constant(dilation) + ivalue_to_constant(groups) + res += ivalue_to_constant(stride, shared_memory=self._shared_memory) + res += ivalue_to_constant(padding, shared_memory=self._shared_memory) + res += ivalue_to_constant(dilation, shared_memory=self._shared_memory) + res += ivalue_to_constant(groups, shared_memory=self._shared_memory) except: pass return res elif not isinstance(pt_value, (torch.jit.ScriptModule, torch.jit.TracedModule)): - return ivalue_to_constant(pt_value) + return ivalue_to_constant(pt_value, shared_memory=self._shared_memory) else: return [] @@ -400,10 +406,10 @@ def as_constant(self): pt_value = self._raw_output(0) pt_type = pt_value.type() if isinstance(pt_type, torch.TensorType): - return ivalue_to_constant(pt_value.toIValue()) + return ivalue_to_constant(pt_value.toIValue(), shared_memory=self._shared_memory) if isinstance(pt_type, torch.ListType): return self._as_constant_list(pt_value) - return ivalue_to_constant(pt_value.toIValue()) + return ivalue_to_constant(pt_value.toIValue(), shared_memory=self._shared_memory) def as_string(self): if self.get_op_type() == "prim::Constant": diff --git a/src/bindings/python/src/openvino/frontend/pytorch/utils.py b/src/bindings/python/src/openvino/frontend/pytorch/utils.py index 7c491dc8aa23c9..0e7ffd66780c61 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/utils.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/utils.py @@ -55,7 +55,26 @@ def get_type_from_py_type(value): return OVType.dynamic -def ivalue_to_constant(ivalue): +def torch_tensor_to_ov_const(torch_t: torch.Tensor, shared_memory=True): + torch_t = torch_t.to(memory_format=torch.contiguous_format) + if torch_t.dtype == torch.bfloat16: + # reinterpret bfloat16 data as float16 to allow conversion to numpy + torch_t = torch_t.view(torch.float16) + narr = torch_t.numpy(force=True) + if not narr.flags['C_CONTIGUOUS']: + narr = np.ascontiguousarray(narr) + # TODO: this tensor doesn't share memory with initial tensor + tensor = Tensor(narr, torch_t.shape, OVType.bf16) + ov_const = op.Constant(tensor, shared_memory=shared_memory) + else: + narr = torch_t.numpy(force=True) + if not narr.flags['C_CONTIGUOUS']: + narr = np.ascontiguousarray(narr) + ov_const = op.Constant(narr, shared_memory=shared_memory) + return ov_const + + +def ivalue_to_constant(ivalue, shared_memory=True): ov_type = get_type_from_py_type(ivalue) if ov_type.is_static(): return op.Constant(ov_type, Shape([]), [ivalue]).outputs() @@ -67,22 +86,7 @@ def ivalue_to_constant(ivalue): return op.Constant(ov_type, Shape([len(ivalue)]), ivalue).outputs() if isinstance(ivalue, torch.Tensor): - ivalue = ivalue.to(memory_format=torch.contiguous_format) - if ivalue.dtype == torch.bfloat16: - # reinterpret bfloat16 data as float16 to allow conversion to numpy - ivalue = ivalue.view(torch.float16) - narr = ivalue.numpy(force=True) - if not narr.flags['C_CONTIGUOUS']: - narr = np.ascontiguousarray(narr) - # TODO: this tensor doesn't share memory with initial tensor - tensor = Tensor(narr, ivalue.shape, OVType.bf16) - ov_const = op.Constant(tensor, shared_memory=True) - else: - narr = ivalue.numpy(force=True) - if not narr.flags['C_CONTIGUOUS']: - narr = np.ascontiguousarray(narr) - ov_const = op.Constant(narr, shared_memory=True) - return ov_const.outputs() + return torch_tensor_to_ov_const(ivalue, shared_memory=shared_memory).outputs() return None def get_value_from_getattr(getattr_node, self_module): diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py index ae48f1ce1ae7f2..307a1dcde3f271 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py @@ -1011,6 +1011,64 @@ def test_mo_import_from_memory(self, create_model, ie_device, precision, ir_vers self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) + @ pytest.mark.precommit + def test_sharing_memory_switched_off(self, ie_device, precision, ir_version, temp_dir): + from openvino.tools.ovc import convert_model + from openvino.runtime import Core + + class DataModel(torch.nn.Module): + def __init__(self): + super(DataModel, self).__init__() + self.data = torch.tensor([1, 2, 3, 4]) + + def forward(self, x): + return self.data, x + + data_model = DataModel() + test_input = np.array([0, 0, 0, 0]) + + # Convert model to OV + ov_model = convert_model(data_model, input=([4], Type.i32), share_weights=False) + + # Change value of variables in original model + data_model.data[0] *= 2 + + # Check model inference + core = Core() + cmp_model = core.compile_model(ov_model, ie_device) + ov_infer1 = cmp_model(test_input) + + assert np.array_equal(ov_infer1[0], [1, 2, 3, 4]) + + @ pytest.mark.precommit + def test_sharing_memory_switched_on(self, ie_device, precision, ir_version, temp_dir): + from openvino.tools.ovc import convert_model + from openvino.runtime import Core + + class DataModel(torch.nn.Module): + def __init__(self): + super(DataModel, self).__init__() + self.data = torch.tensor([1, 2, 3, 4]) + + def forward(self, x): + return self.data, x + + data_model = DataModel() + test_input = np.array([0, 0, 0, 0]) + + # Convert model to OV + ov_model = convert_model(data_model, input=([4], Type.i32), share_weights=True) + + # Change value of variables in original model + data_model.data[0] *= 2 + + # Check model inference + core = Core() + cmp_model = core.compile_model(ov_model, ie_device) + ov_infer1 = cmp_model(test_input) + + assert np.array_equal(ov_infer1[0], [2, 2, 3, 4]) + def create_pt_model_with_custom_op(): # diff --git a/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py b/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py index 7cb46d92300640..8c489dc412770c 100644 --- a/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py +++ b/tools/mo/openvino/tools/mo/moc_frontend/pytorch_frontend_utils.py @@ -31,7 +31,7 @@ def get_pytorch_decoder(model, input_shape, example_inputs, args): except: pass inputs = prepare_torch_inputs(example_inputs) - decoder = TorchScriptPythonDecoder(model, example_input=inputs) + decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True)) args['input_model'] = decoder args["framework"] = "pytorch" args["example_input"] = inputs diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py index 89c5ce11ae520b..da2abdb21f3b55 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py @@ -31,7 +31,7 @@ def get_pytorch_decoder(model, example_inputs, args): except: pass inputs = prepare_torch_inputs(example_inputs) - decoder = TorchScriptPythonDecoder(model, example_input=inputs) + decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True)) args['input_model'] = decoder args["example_input"] = inputs From 59872ee072a297120edf240dc50a0c904f51a9d0 Mon Sep 17 00:00:00 2001 From: Anastasiia Pnevskaia Date: Thu, 10 Aug 2023 21:47:27 +0200 Subject: [PATCH 32/51] Removed InputCutInfo, disabled input cut in OVC. (#18927) * Fixed output_model logic. * Removed InputCutInfo, disabled input cut in ovc. * Disabled output cut, added tests for setting shapes or types for not all inputs. * Returned support of numpy type. * Separated MO and OVC python API tests. * Small corrections. * Added output dir test, exceptions test. * Tests fixed. * Corrected extension param description. * Corrected input description, minor code corrections. --- .ci/azure/linux.yml | 9 + src/bindings/python/src/openvino/__init__.py | 2 +- .../common/mo_convert_test_class.py | 2 +- .../test_mo_convert_complex_params.py | 63 +- .../test_mo_convert_extensions.py | 5 +- .../test_mo_convert_onnx.py | 6 +- .../test_mo_convert_paddle.py | 1 + .../test_mo_convert_pytorch.py | 121 +- .../mo_python_api_tests/test_mo_convert_tf.py | 70 +- .../mo_python_api_tests/test_mo_help.py | 11 +- .../ovc_python_api_tests/conftest.py | 13 + .../test_complex_params.py | 167 +++ .../ovc_python_api_tests/test_extensions.py | 121 ++ .../ovc_python_api_tests/test_onnx.py | 83 ++ .../test_ovc_cli_tool.py | 15 + .../test_ovc_tool_help.py | 30 + .../ovc_python_api_tests/test_paddle.py | 103 ++ .../ovc_python_api_tests/test_pytorch.py | 1073 +++++++++++++++++ .../ovc_python_api_tests/test_tf.py | 859 +++++++++++++ tools/benchmark_tool/openvino/__init__.py | 2 +- tools/mo/openvino/__init__.py | 2 +- tools/openvino_dev/src/openvino/__init__.py | 2 +- tools/ovc/openvino/__init__.py | 2 +- tools/ovc/openvino/tools/ovc/__init__.py | 2 +- tools/ovc/openvino/tools/ovc/cli_parser.py | 220 ++-- tools/ovc/openvino/tools/ovc/convert.py | 48 +- tools/ovc/openvino/tools/ovc/convert_impl.py | 36 +- tools/ovc/openvino/tools/ovc/help.py | 73 +- tools/ovc/openvino/tools/ovc/main.py | 6 +- .../tools/ovc/moc_frontend/check_config.py | 5 - .../tools/ovc/moc_frontend/extractor.py | 26 +- .../tools/ovc/moc_frontend/pipeline.py | 34 +- .../moc_tf_fe/check_info_messages_test.py | 1 - .../moc_tf_fe/conversion_basic_models_test.py | 194 +-- .../ovc/convert/import_from_mo_test.py | 4 +- .../unit_tests/ovc/convert/meta_data_test.py | 2 +- .../ovc/convert/meta_data_test_actual.py | 2 +- .../unit_tests/ovc/utils/cli_parser_test.py | 302 ++--- tools/pot/openvino/__init__.py | 2 +- 39 files changed, 2883 insertions(+), 836 deletions(-) create mode 100644 tests/layer_tests/ovc_python_api_tests/conftest.py create mode 100644 tests/layer_tests/ovc_python_api_tests/test_complex_params.py create mode 100644 tests/layer_tests/ovc_python_api_tests/test_extensions.py create mode 100644 tests/layer_tests/ovc_python_api_tests/test_onnx.py rename tests/layer_tests/{mo_python_api_tests => ovc_python_api_tests}/test_ovc_cli_tool.py (85%) create mode 100644 tests/layer_tests/ovc_python_api_tests/test_ovc_tool_help.py create mode 100644 tests/layer_tests/ovc_python_api_tests/test_paddle.py create mode 100644 tests/layer_tests/ovc_python_api_tests/test_pytorch.py create mode 100644 tests/layer_tests/ovc_python_api_tests/test_tf.py diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 7d7454f8794849..f07f048001f475 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -551,6 +551,15 @@ jobs: TEST_DEVICE: CPU displayName: 'TensorFlow Lite Layer Tests - TFL FE' + - script: | + set -e + python3 -m pip install -r $(LAYER_TESTS_DIR)/requirements.txt + $(RUN_PREFIX) python3 -m pytest $(LAYER_TESTS_DIR)/ovc_python_api_tests/ --junitxml=./TEST-test_ovc_convert.xmlTEST + env: + PYTHONPATH: $(LAYER_TESTS_DIR) + TEST_DEVICE: CPU + displayName: 'OVC Python API Tests' + - script: | set -e python3 -m pip install -r $(LAYER_TESTS_DIR)/requirements.txt diff --git a/src/bindings/python/src/openvino/__init__.py b/src/bindings/python/src/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/src/bindings/python/src/openvino/__init__.py +++ b/src/bindings/python/src/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass diff --git a/tests/layer_tests/common/mo_convert_test_class.py b/tests/layer_tests/common/mo_convert_test_class.py index 8b251c9399e51d..ccd0c389d6739f 100644 --- a/tests/layer_tests/common/mo_convert_test_class.py +++ b/tests/layer_tests/common/mo_convert_test_class.py @@ -53,7 +53,7 @@ def _test(self, temp_dir, test_params, ref_params): ir_ref = core.read_model(Path(temp_dir, 'model_ref.xml')) flag, msg = compare_functions(ir_test, ir_ref) - assert flag, '\n'.join(msg) + assert flag, msg def _test_by_ref_graph(self, temp_dir, test_params, ref_graph, compare_tensor_names=True, compare_layout=True): """ diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_complex_params.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_complex_params.py index 37543013a3c258..a9f04a702249cc 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_complex_params.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_complex_params.py @@ -5,9 +5,8 @@ import os import pytest from openvino.runtime import Model, Layout, PartialShape, Shape, layout_helpers, Type, Dimension -from openvino.tools.ovc import InputCutInfo -from openvino.tools.mo import LayoutMap - +from openvino.tools.mo import LayoutMap, InputCutInfo +import openvino.runtime as ov from common.mo_convert_test_class import CommonMOConvertTest from common.tf_layer_test_class import save_to_pb @@ -134,11 +133,11 @@ def create_tf_param_res_model(self, tmp_dir): {'params_test': {'input_shape': [PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)]], - 'input':['Input1', 'Input2', 'Relu3'], 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + 'input':['Input1', 'Input2', 'Relu3'], 'compress_to_fp16': True}, 'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Relu3'}}, {'params_test': {'input_shape': [PartialShape([Dimension(), Dimension(1, 3), Dimension(4, -1), Dimension(-1, 5)]), [Dimension(), Dimension(1, 3), 4, Dimension(-1, 5)], - [Dimension(), 3, Dimension(4, -1), Dimension(-1, 5)]], 'use_convert_model_from_mo': True, + [Dimension(), 3, Dimension(4, -1), Dimension(-1, 5)]], 'compress_to_fp16': True, 'input':['Input1', 'Input2', 'Relu3']}, 'params_ref': {'input_shape': "[?,1..3,4..,..5],[?,1..3,4,..5],[?,3,4..,..5]", 'input': 'Input1,Input2,Relu3'}}, @@ -153,32 +152,27 @@ def create_tf_param_res_model(self, tmp_dir): {'params_test': {'output': ["Sigmoid_0", "Sigmoid_2"]}, 'params_ref': {'output': "Sigmoid_0,Sigmoid_2"}}, {'params_test': {'mean_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]}, - 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + 'compress_to_fp16': True}, 'params_ref': {'mean_values': "Input1[0.5,1.3,0.67],Input2[4.2,6.7,3.15],Input3[0.757,4.6,7.3]"}}, {'params_test': { - 'mean_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + 'mean_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'compress_to_fp16': True}, 'params_ref': {'mean_values': "[0.5,1.3,0.67],[4.2,6.7,3.15],[0.757,4.6,7.3]"}}, {'params_test': {'scale_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]}, - 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + 'compress_to_fp16': True}, 'params_ref': {'scale_values': "Input1[0.5,1.3,0.67],Input2[4.2,6.7,3.15],Input3[0.757,4.6,7.3]"}}, {'params_test': { - 'scale_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + 'scale_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'compress_to_fp16': True}, 'params_ref': {'scale_values': "[0.5,1.3,0.67],[4.2,6.7,3.15],[0.757,4.6,7.3]"}}, {'params_test': { - 'source_layout': {'Input1': Layout("nchw"), 'Input2': "nchw", 'Input3': "nc??"}, 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + 'source_layout': {'Input1': Layout("nchw"), 'Input2': "nchw", 'Input3': "nc??"}, 'compress_to_fp16': True}, 'params_ref': {'source_layout': "Input1(nchw),Input2(nchw),Input3(nc??)"}}, {'params_test': { - 'target_layout': {'Input1': Layout("nhwc"), 'Input2': "nhwc", 'Input3': "n??c"}, 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + 'target_layout': {'Input1': Layout("nhwc"), 'Input2': "nhwc", 'Input3': "n??c"}, 'compress_to_fp16': True}, 'params_ref': {'target_layout': "Input1(nhwc),Input2(nhwc),Input3(n??c)"}}, {'params_test': { 'layout': {'Input1': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"), 'Input2': LayoutMap(source_layout="nc??", target_layout=Layout("n??c")), - 'Input3': LayoutMap(source_layout="abcd", target_layout="acdb")}, 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + 'Input3': LayoutMap(source_layout="abcd", target_layout="acdb")}, 'compress_to_fp16': True}, 'params_ref': {'layout': "Input1(nchw->nhwc),Input2(nc??->n??c),Input3(abcd->acdb)"}}, {'params_test': {'input': [PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)]]}, 'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}}, @@ -198,6 +192,7 @@ def test_mo_convert_tf_model(self, params, ie_device, precision, ir_version, test_params = params['params_test'] ref_params = params['params_ref'] + test_params.update({'use_convert_model_from_mo': True}) test_params.update({'input_model': tf_net_path}) ref_params.update({'input_model': tf_net_path}) self._test(temp_dir, test_params, ref_params) @@ -241,16 +236,13 @@ def test_mo_convert_tf_model_no_concat(self, params, ie_device, precision, ir_ve # By default compress_to_fp16 in Python API is False but for mo cli tool (used for params_ref) it's True. # compress_to_fp16 should be specified explicitly either in 'param_test' or 'params_ref' (or in both) # Check all args combinations. - {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'compress_to_fp16': True}, 'params_ref': {'input_shape': "[2,3,4]"}}, - {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'use_convert_model_from_mo': True}, + {'params_test': {'input_shape': PartialShape([2, 3, 4])}, 'params_ref': {'input_shape': "[2,3,4]", 'compress_to_fp16': False}}, - {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'compress_to_fp16': True}, 'params_ref': {'input_shape': "[2,3,4]", 'compress_to_fp16': True}}, - {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'use_convert_model_from_mo': True, - 'compress_to_fp16': False}, + {'params_test': {'input_shape': PartialShape([2, 3, 4]), 'compress_to_fp16': False}, 'params_ref': {'input_shape': "[2,3,4]", 'compress_to_fp16': False}}, # ovc.convert_model with save_model are used, by default save_model compresses to fp16 same as cli tool. @@ -266,8 +258,7 @@ def test_mo_convert_tf_model_no_concat(self, params, ie_device, precision, ir_ve {'params_test': {'input': InputCutInfo("Relu", [3, 2], Type(np.int32), [1, 2, 3, 4, 5, 6]), 'compress_to_fp16': False}, 'params_ref': {'input': "Relu[3 2]{i32}->[1 2 3 4 5 6]", 'compress_to_fp16': False}}, - {'params_test': {'input_shape': [Dimension(), Dimension(1, 3), 4, Dimension(-1, 5)], 'use_convert_model_from_mo': True, - 'compress_to_fp16': True}, + {'params_test': {'input_shape': [Dimension(), Dimension(1, 3), 4, Dimension(-1, 5)], 'compress_to_fp16': True}, 'params_ref': {'input_shape': "[?,1..3,4,..5]"}}, {'params_test': {'input': InputCutInfo("Relu", [3, 2], Type(np.int32), [1, 2, 3, 4, 5, 6])}, 'params_ref': {'input': "Relu[3 2]{i32}->[1 2 3 4 5 6]"}}, @@ -279,18 +270,17 @@ def test_mo_convert_tf_model_no_concat(self, params, ie_device, precision, ir_ve 'params_ref': {'input': "Relu[3 2]"}}, {'params_test': {'input': ("Relu")}, 'params_ref': {'input': "Relu"}}, - {'params_test': {'mean_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'mean_values': [0.5, 1.3, 0.67], 'compress_to_fp16': True}, 'params_ref': {'mean_values': "[0.5,1.3,0.67]"}}, - {'params_test': {'scale_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'scale_values': [0.5, 1.3, 0.67], 'compress_to_fp16': True}, 'params_ref': {'scale_values': "[0.5,1.3,0.67]"}}, - {'params_test': {'source_layout': Layout("nchw"), 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'source_layout': Layout("nchw"), 'compress_to_fp16': True}, 'params_ref': {'source_layout': "nchw"}}, - {'params_test': {'target_layout': Layout("nchw"), 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'target_layout': Layout("nchw"), 'compress_to_fp16': True}, 'params_ref': {'target_layout': "nchw"}}, - {'params_test': {'layout': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"), - 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'layout': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"), 'compress_to_fp16': True}, 'params_ref': {'layout': "nchw->nhwc"}}, - {'params_test': {'layout': Layout("nchw"), 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'layout': Layout("nchw"), 'compress_to_fp16': True}, 'params_ref': {'layout': "nchw"}}, {'params_test': {'input': [3, 2]}, 'params_ref': {'input': "Input[3 2]"}}, @@ -306,13 +296,13 @@ def test_mo_convert_tf_model_no_concat(self, params, ie_device, precision, ir_ve 'params_ref': {'input': "Input[1]{i32}->[10]"}}, {'params_test': {'input': (np.int32, [1, 2, 3])}, 'params_ref': {'input': "Input[1,2,3]{i32}"}}, - {'params_test': {'input_shape': [Dimension(3, 10), 10, -1], 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'input_shape': [Dimension(3, 10), 10, -1], 'compress_to_fp16': True}, 'params_ref': {'input_shape': '[3..10,10,?]'}}, {'params_test': {'input': [Dimension(3, 10), 10, -1]}, 'params_ref': {'input': 'Input[3..10,10,?]'}}, - {'params_test': {'input': PartialShape([1, 100, 100, 3]), 'mean_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'input': PartialShape([1, 100, 100, 3]), 'mean_values': [0.5, 1.3, 0.67], 'compress_to_fp16': True}, 'params_ref': {'input': "Input[1,100,100,3]", 'mean_values': "[0.5,1.3,0.67]"}}, - {'params_test': {'input': [1, 100, 100, 3], 'scale_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True, 'compress_to_fp16': True}, + {'params_test': {'input': [1, 100, 100, 3], 'scale_values': [0.5, 1.3, 0.67], 'compress_to_fp16': True}, 'params_ref': {'input': "Input[1,100,100,3]", 'scale_values': "[0.5,1.3,0.67]"}}, ] @@ -325,6 +315,7 @@ def test_mo_convert_tf_model_single_input_output(self, params, ie_device, precis test_params = params['params_test'] ref_params = params['params_ref'] + test_params.update({'use_convert_model_from_mo': True}) test_params.update({'input_model': tf_net_path}) ref_params.update({'input_model': tf_net_path}) self._test(temp_dir, test_params, ref_params) diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_extensions.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_extensions.py index 5cc02f76f54416..b510104e9e2235 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_extensions.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_extensions.py @@ -102,9 +102,9 @@ def create_ref_graph2(): return Model([sigmoid], [param], "test") test_data = [ - {'params_test': {'extension': create_custom_extension_leaky_relu_to_relu()}, + {'params_test': {'extensions': create_custom_extension_leaky_relu_to_relu()}, 'ref_graph': create_ref_graph1()}, - {'params_test': {'extension': [create_custom_extension_leaky_relu_to_relu(), + {'params_test': {'extensions': [create_custom_extension_leaky_relu_to_relu(), create_custom_extension_elu_to_sigmoid()]}, 'ref_graph': create_ref_graph2()} ] @@ -118,4 +118,5 @@ def test_mo_convert_extensions(self, params, ie_device, precision, ir_version, test_params = params['params_test'] test_params.update({'input_model': onnx_net_path}) + test_params.update({'use_convert_model_from_mo': True}) self._test_by_ref_graph(temp_dir, test_params, params['ref_graph']) diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_onnx.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_onnx.py index 58fd799a507dc9..f671ef07b3c0da 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_onnx.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_onnx.py @@ -49,9 +49,8 @@ def make_graph_proto_model(): def create_ref_model(shape): param1 = ov.opset8.parameter(shape, dtype=np.float32) - slope_const = ov.opset8.constant([0.1], dtype=np.float16) - decompress_slope = ov.opset8.convert(slope_const, np.float32) - prelu = ov.opset8.prelu(param1, slope=decompress_slope) + slope_const = ov.opset8.constant([0.1], dtype=np.float32) + prelu = ov.opset8.prelu(param1, slope=slope_const) relu = ov.opset8.elu(prelu, alpha=np.float32(0.1)) parameter_list = [param1] return Model([relu], parameter_list, "test") @@ -79,5 +78,6 @@ def test_mo_convert_onnx(self, create_model, ie_device, precision, ir_version, test_params = {'input_model': fw_model} if mo_params is not None: test_params.update(mo_params) + test_params.update({'use_convert_model_from_mo': True}) self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_paddle.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_paddle.py index de4fe954eff204..dd403facdce277 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_paddle.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_paddle.py @@ -100,4 +100,5 @@ def test_mo_import_from_memory_paddle_fe(self, create_model, ie_device, precisio test_params = {'input_model': fw_model, 'use_new_frontend': True} if mo_params is not None: test_params.update(mo_params) + test_params.update({'use_convert_model_from_mo': True}) self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py index 307a1dcde3f271..ea29e9c94cc1cb 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py @@ -11,7 +11,7 @@ import torch import unittest from openvino.runtime import PartialShape, Dimension, Model, Type -from openvino.tools.ovc import InputCutInfo +from openvino.tools.mo import InputCutInfo from common.mo_convert_test_class import CommonMOConvertTest @@ -176,7 +176,7 @@ def create_pytorch_nn_module_with_scalar_input(tmp_dir): sample_input2 = torch.zeros(1, 3, 10, 10) sample_input = sample_input1, sample_input2 - return pt_model, ref_model, {'input': ["[]", PartialShape([-1, 3, -1, -1])], + return pt_model, ref_model, {'input_shape': [PartialShape("[]"), PartialShape([-1, 3, -1, -1])], 'example_input': sample_input} @@ -188,7 +188,7 @@ def create_pytorch_nn_module_case3(tmp_dir): sample_input2 = torch.zeros(1, 3, 10, 10) sample_input = tuple([sample_input1, sample_input2]) - return pt_model, ref_model, {'input': "[?,3,?,?],[?,3,?,?]", + return pt_model, ref_model, {'input_shape': "[?,3,?,?],[?,3,?,?]", 'example_input': sample_input} @@ -297,7 +297,8 @@ def create_pytorch_nn_module_layout_list(tmp_dir): ref_model.inputs[1].node.layout = Layout('nhwc') return pt_model, ref_model, { - 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ['nchw', Layout('nhwc')], 'use_convert_model_from_mo': True + 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ['nchw', Layout('nhwc')], + 'use_convert_model_from_mo': True } @@ -312,7 +313,8 @@ def create_pytorch_nn_module_layout_list_case2(tmp_dir): ref_model.inputs[1].node.layout = Layout('nhwc') return pt_model, ref_model, { - 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ('nchw', Layout('nhwc')), 'use_convert_model_from_mo': True} + 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ('nchw', Layout('nhwc')), + 'use_convert_model_from_mo': True} def create_pytorch_nn_module_mean_list_compression_disabled(tmp_dir): @@ -333,7 +335,8 @@ def create_pytorch_nn_module_mean_list_compression_disabled(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], 'mean_values': [[0, 0, 0], [0, 0, 0]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': False, 'use_convert_model_from_mo': True} @@ -357,7 +360,8 @@ def create_pytorch_nn_module_mean_list_compression_default(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], 'mean_values': [[0, 0, 0], [0, 0, 0]], + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'mean_values': [[0, 0, 0], [0, 0, 0]], 'use_convert_model_from_mo': True} @@ -607,7 +611,8 @@ def create_pytorch_nn_module_convert_pytorch_frontend4(tmp_dir): parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") return pt_model, ref_model, { - "example_input": {"x": torch.zeros((1, 3, 10, 10), dtype=torch.float32), "y": torch.ones((1, 3, 10, 10), dtype=torch.float32)}, + "example_input": {"x": torch.zeros((1, 3, 10, 10), dtype=torch.float32), + "y": torch.ones((1, 3, 10, 10), dtype=torch.float32)}, 'input': [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")] } @@ -626,7 +631,7 @@ def create_pytorch_jit_script_module_convert_pytorch_frontend(tmp_dir): sigm = ov.opset10.sigmoid(relu) parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return scripted_model, ref_model, { + return scripted_model, ref_model, { "example_input": [torch.zeros((1, 3, 10, 10)), torch.ones((1, 3, 10, 10))]} @@ -645,7 +650,7 @@ def create_pytorch_jit_trace_module_convert_pytorch_frontend(tmp_dir): sigm = ov.opset10.sigmoid(relu) parameter_list = [param1, param2] ref_model = Model([sigm], parameter_list, "test") - return scripted_model, ref_model, {"example_input": example_input} + return scripted_model, ref_model, {"example_input": example_input} def create_pytorch_module_convert_pytorch_frontend_oob(tmp_dir): @@ -663,9 +668,8 @@ def forward(self, x): net = ConvModel() shape = PartialShape([-1, 3, -1, -1]) param1 = ov.opset10.parameter(shape, dtype=np.float32) - weights = ov.opset10.constant(net.weights.numpy(force=True), dtype=np.float16) - decompress_weights = ov.opset10.convert(weights, np.float32) - conv = ov.opset10.convolution(param1, decompress_weights, strides=[1, 1], + weights = ov.opset10.constant(net.weights.numpy(force=True), dtype=np.float32) + conv = ov.opset10.convolution(param1, weights, strides=[1, 1], pads_begin=[0, 0], pads_end=[0, 0], dilations=[1, 1]) parameter_list = [param1] @@ -723,17 +727,15 @@ def forward(self, x): param1 = ov.opset10.parameter(shape, dtype=np.float32) weights = ov.opset10.constant(net.weights.numpy(force=True)) cast1 = ov.opset10.convert(weights, np.float32) - sub1_const = np.float16(0.5).reshape(1, 1, 1, 1) - mul1_const = np.float16(0.02).reshape(1, 1, 1, 1) - sub1_const_decompress = ov.opset10.convert(sub1_const, np.float32) - mul1_const_decompress = ov.opset10.convert(mul1_const, np.float32) - sub1 = ov.opset10.subtract(cast1, sub1_const_decompress) - mul1 = ov.opset10.multiply(sub1, mul1_const_decompress) + sub1_const = np.float32(0.5).reshape(1, 1, 1, 1) + mul1_const = np.float32(0.02).reshape(1, 1, 1, 1) + sub1 = ov.opset10.subtract(cast1, sub1_const) + mul1 = ov.opset10.multiply(sub1, mul1_const) conv = ov.opset10.convolution(param1, mul1, strides=[1, 1], pads_begin=[0, 0], pads_end=[0, 0], dilations=[1, 1]) ref_model = Model([conv], [param1], "test") - return traced_model, ref_model, {"example_input": example_input} + return traced_model, ref_model, {"example_input": example_input} def create_pytorch_module_with_compressed_int8_constant(tmp_dir): @@ -766,17 +768,17 @@ def forward(self, x): pads_begin=[0, 0], pads_end=[0, 0], dilations=[1, 1]) ref_model = Model([conv], [param1], "test") - return traced_model, ref_model, {"example_input": example_input, "compress_to_fp16": False} + return traced_model, ref_model, {"example_input": example_input, "compress_to_fp16": False} def create_pytorch_module_with_nested_inputs(tmp_dir): class PTModel(torch.nn.Module): - - def forward(self, z:Tuple[torch.Tensor, torch.Tensor]): + + def forward(self, z: Tuple[torch.Tensor, torch.Tensor]): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) - return torch.cat([z1, zeros1], 1), torch.cat([z2, zeros2], 2) + return torch.cat([z1, zeros1], 1), torch.cat([z2, zeros2], 2) net = PTModel() constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) @@ -795,7 +797,7 @@ def forward(self, z:Tuple[torch.Tensor, torch.Tensor]): def create_pytorch_module_with_nested_inputs_compress_to_fp16_default(tmp_dir): class PTModel(torch.nn.Module): - def forward(self, z:Tuple[torch.Tensor, torch.Tensor]): + def forward(self, z: Tuple[torch.Tensor, torch.Tensor]): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) @@ -818,12 +820,12 @@ def forward(self, z:Tuple[torch.Tensor, torch.Tensor]): def create_pytorch_module_with_nested_inputs2(tmp_dir): class PTModel(torch.nn.Module): - - def forward(self, x:torch.Tensor, z:Tuple[torch.Tensor, torch.Tensor]): + + def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor]): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) - return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) net = PTModel() constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) @@ -837,18 +839,19 @@ def forward(self, x:torch.Tensor, z:Tuple[torch.Tensor, torch.Tensor]): concat2 = ov.opset10.concat([param2, constant_zeros2], 2) add = ov.opset10.add(concat1, param0) ref_model = Model([concat2, add], [param0, param1, param2], "test") - return net, ref_model, {"example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 5)))}, - "compress_to_fp16": False} + return net, ref_model, { + "example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 5)))}, + "compress_to_fp16": False} def create_pytorch_module_with_nested_inputs3(tmp_dir): class PTModel(torch.nn.Module): - - def forward(self, z:Tuple[torch.Tensor, torch.Tensor], x:torch.Tensor): + + def forward(self, z: Tuple[torch.Tensor, torch.Tensor], x: torch.Tensor): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) - return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) net = PTModel() shape1 = PartialShape([1, -1]) @@ -862,18 +865,19 @@ def forward(self, z:Tuple[torch.Tensor, torch.Tensor], x:torch.Tensor): concat2 = ov.opset10.concat([param2, constant_zeros2], 2) add = ov.opset10.add(concat1, param3) ref_model = Model([concat2, add], [param1, param2, param3], "test") - return net, ref_model, {"example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 3)))}, - "compress_to_fp16": False} + return net, ref_model, { + "example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 3)))}, + "compress_to_fp16": False} def create_pytorch_module_with_nested_inputs4(tmp_dir): class PTModel(torch.nn.Module): - - def forward(self, x:torch.Tensor, z:Tuple[torch.Tensor, torch.Tensor], y:torch.Tensor): + + def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor], y: torch.Tensor): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) - return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) * y + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) * y net = PTModel() constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) @@ -889,18 +893,20 @@ def forward(self, x:torch.Tensor, z:Tuple[torch.Tensor, torch.Tensor], y:torch.T add = ov.opset10.add(concat1, param3) mul = ov.opset10.multiply(concat2, param4) ref_model = Model([mul, add], [param3, param1, param2, param4], "test") - return net, ref_model, {"example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 10))), "y": torch.ones((1,))}, - "compress_to_fp16": False} + return net, ref_model, { + "example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 10))), + "y": torch.ones((1,))}, + "compress_to_fp16": False} def create_pytorch_module_with_nested_inputs5(tmp_dir): class PTModel(torch.nn.Module): - - def forward(self, x:torch.Tensor, z:Tuple[torch.Tensor, torch.Tensor], y:torch.Tensor): + + def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor], y: torch.Tensor): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) - return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) * y + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) * y net = PTModel() constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) @@ -916,19 +922,20 @@ def forward(self, x:torch.Tensor, z:Tuple[torch.Tensor, torch.Tensor], y:torch.T add = ov.opset10.add(concat1, param0) mul = ov.opset10.multiply(concat2, param4) ref_model = Model([mul, add], [param0, param1, param2, param4], "test") - return net, ref_model, {"example_input": [torch.ones((1, 10)), (torch.zeros((1, 10)), torch.ones((1, 5, 10))), torch.ones((1,))], - "compress_to_fp16": False} + return net, ref_model, { + "example_input": [torch.ones((1, 10)), (torch.zeros((1, 10)), torch.ones((1, 5, 10))), torch.ones((1,))], + "compress_to_fp16": False} def create_pytorch_module_with_nested_inputs6(tmp_dir): class PTModel(torch.nn.Module): - - def forward(self, x:torch.Tensor, y:torch.Tensor=None, z:Tuple[torch.Tensor, torch.Tensor]=None): + + def forward(self, x: torch.Tensor, y: torch.Tensor = None, z: Tuple[torch.Tensor, torch.Tensor] = None): z1, z2 = z zeros1 = torch.zeros((1, 1)) zeros2 = torch.zeros((1, 5, 1)) if y is not None: - return torch.cat([z1, zeros1], 1) * y, torch.cat([z2, zeros2], 2) * y + return torch.cat([z1, zeros1], 1) * y, torch.cat([z2, zeros2], 2) * y return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) net = PTModel() @@ -943,8 +950,9 @@ def forward(self, x:torch.Tensor, y:torch.Tensor=None, z:Tuple[torch.Tensor, tor concat2 = ov.opset10.concat([param2, constant_zeros2], 2) add1 = ov.opset10.add(concat1, param0) ref_model = Model([concat2, add1], [param0, param1, param2], "test") - return net, ref_model, {"example_input": {"x": torch.ones((1, 11)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 10)))}, - "compress_to_fp16": False} + return net, ref_model, { + "example_input": {"x": torch.ones((1, 11)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 10)))}, + "compress_to_fp16": False} class TestMoConvertPyTorch(CommonMOConvertTest): @@ -998,14 +1006,15 @@ class TestMoConvertPyTorch(CommonMOConvertTest): create_pytorch_module_with_nested_inputs6 ] - @ pytest.mark.parametrize("create_model", test_data) - @ pytest.mark.nightly - @ pytest.mark.precommit + @pytest.mark.parametrize("create_model", test_data) + @pytest.mark.nightly + @pytest.mark.precommit def test_mo_import_from_memory(self, create_model, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): fw_model, graph_ref, mo_params = create_model(temp_dir) test_params = {'input_model': fw_model} + test_params.update({'use_convert_model_from_mo': True}) if mo_params is not None: test_params.update(mo_params) self._test_by_ref_graph(temp_dir, test_params, @@ -1089,11 +1098,11 @@ def forward(self, x): class ConvertRaises(unittest.TestCase): def test_example_inputs(self): - from openvino.tools.ovc import convert_model + from openvino.tools.mo import convert_model pytorch_model = create_pt_model_with_custom_op() # Check that mo raises error message of wrong argument. - with self.assertRaisesRegex(TypeError, ".*got an unexpected keyword argument 'example_inputs'.*"): + with self.assertRaisesRegex(AssertionError, ".*'example_inputs' argument is not recognized.*"): convert_model(pytorch_model, example_inputs=(torch.tensor(1),)) def test_failed_extension(self): @@ -1109,7 +1118,7 @@ def relu_bad(n): # Check that mo raises error message of wrong argument. with self.assertRaisesRegex(Exception, ".*Conversion is failed for: aten::relu.*"): convert_model(pt_model, input=(inp_shapes, np.float32), extensions=[ - ConversionExtension("aten::relu", relu_bad)]) + ConversionExtension("aten::relu", relu_bad)]) def test_failed_extension(self): import tempfile diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py index e86a075baea62f..b7b2c85032b58c 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py @@ -377,8 +377,8 @@ def first_func(input, filter): param1 = ov.opset8.parameter(data_shape, dtype=np.float32) param2 = ov.opset8.parameter(filters_shape, dtype=np.float32) - reshape = ov.opset8.reshape(param2, np.array([1, 1, 3, 3], dtype=np.int64), True) - conv = ov.opset11.convolution(param1, reshape, strides, pads_begin, pads_end, dilations, auto_pad="same_upper") + transpose2 = ov.opset8.transpose(param2, np.array([3, 2, 0, 1], dtype=np.int64)) + conv = ov.opset11.convolution(param1, transpose2, strides, pads_begin, pads_end, dilations, auto_pad="same_upper") parameter_list = [param1, param2] model_ref = Model([conv], parameter_list, "test") @@ -577,7 +577,7 @@ def __call__(self, input1, input2): sigm = tf.nn.sigmoid(input1) + input2 return sigm * self.var1 model = LayerModel() - model_ref = two_params_function_reference_fp16_compressed([[1, 2], [1, 2]], [[5.0]]) + model_ref = two_params_function_reference([[1, 2], [1, 2]], [[5.0]]) return model, model_ref, {} @@ -656,9 +656,10 @@ def shape_of_const_fold_test(temp_dir): # Ref model param1 = ov.opset8.parameter(PartialShape([1, 4, 10, 10])) - mul_const = ov.opset8.constant([[[[4]]]], dtype=np.float16) - cast = ov.opset8.convert(mul_const, np.float32) - mul = ov.opset8.multiply(cast, param1) + shape_const = ov.opset8.constant([1, 4, 10, 10], dtype=np.int32) + reshape = ov.opset8.reshape(param1, shape_const, False) + mul_const = ov.opset8.constant([[[[4]]]], dtype=np.float32) + mul = ov.opset8.multiply(mul_const, reshape) parameter_list = [param1] model_ref = Model([mul], parameter_list, "test") @@ -781,6 +782,7 @@ def test_mo_import_from_memory_tf_fe(self, create_model, ie_device, precision, i fw_model, graph_ref, mo_params = create_model(temp_dir) test_params = {'input_model': fw_model} + test_params.update({'use_convert_model_from_mo': True}) if mo_params is not None: test_params.update(mo_params) self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) @@ -791,6 +793,7 @@ def test_unnamed_saved_model_dir(self, ie_device, precision, ir_version, temp_di saved_model_dir, graph_ref = create_tf_saved_model_dir(temp_dir) test_params = {'input_model': saved_model_dir} + test_params.update({'use_convert_model_from_mo': True}) self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) test_params = {'input_model': saved_model_dir} @@ -798,7 +801,7 @@ def test_unnamed_saved_model_dir(self, ie_device, precision, ir_version, temp_di def test_zero_copy(self, ie_device, precision, ir_version, temp_dir): import tensorflow as tf - from openvino.tools.ovc import convert_model + from openvino.tools.mo import convert_model from openvino.runtime import compile_model class LayerModel(tf.Module): def __init__(self): @@ -845,62 +848,13 @@ def __call__(self, input): assert np.array_equal(ov_infer2['Identity:0'], fw_infer2) assert np.array_equal(ov_infer2['Identity:0'], [ 0., 8., 16.]) - def test_turn_off_sharing(self, ie_device, precision, ir_version, temp_dir): - import tensorflow as tf - from openvino.tools.ovc import convert_model - from openvino.runtime import compile_model - class LayerModel(tf.Module): - def __init__(self): - super(LayerModel, self).__init__() - self.var1 = tf.Variable([7., 5., 6.], name='var1') - self.var2 = tf.Variable([5., 7., 3.], name='var2') - - - @tf.function - def sub_function(self, input): - return input * self.var1 + self.var2 - - @tf.function() - def __call__(self, input): - return self.sub_function(input) - - # Create TF model with variables - keras_model = LayerModel() - test_input = np.array(7.).astype(np.float32) - - # Convert model to OV - ov_model = convert_model(keras_model, input=[1], share_weights=False) - cmp_model = compile_model(ov_model) - - # Check model inference - ov_infer1 = cmp_model(test_input, ie_device) - fw_infer1 = keras_model(test_input).numpy() - - assert np.array_equal(ov_infer1['Identity:0'], fw_infer1) - assert np.array_equal(ov_infer1['Identity:0'], [54., 42., 45.]) - - # Change value of variables in original model - for val in keras_model.variables: - arr = val.value().__array__() - arr[0] = 0 - arr[1] = 1 - arr[2] = 2 - - # Check model inference - ov_infer2 = cmp_model(test_input) - fw_infer2 = keras_model(test_input).numpy() - - # Check model inference calculated with old constant values - assert not np.array_equal(ov_infer2['Identity:0'], fw_infer2) - assert np.array_equal(ov_infer2['Identity:0'], [54., 42., 45.]) - def test_memory_loss(self, ie_device, precision, ir_version, temp_dir): # This test checks that the memory allocated for constants # is not lost after returning the model from convert_model() method. import tensorflow as tf tf.compat.v1.reset_default_graph() - from openvino.tools.ovc import convert_model + from openvino.tools.mo import convert_model from openvino.runtime import compile_model import gc @@ -955,7 +909,7 @@ class TFConvertTest(unittest.TestCase): @pytest.mark.precommit def test_tf_function_no_signature(self): import tensorflow as tf - from openvino.tools.ovc import convert_model + from openvino.tools.mo import convert_model @tf.function() def function(x1, x2): diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_help.py b/tests/layer_tests/mo_python_api_tests/test_mo_help.py index 33219093c3831e..7a836a26e1b8b9 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_help.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_help.py @@ -5,9 +5,8 @@ import os import sys import unittest -from openvino.tools.ovc import ovc -from openvino.tools.ovc.cli_parser import get_mo_convert_params -from openvino.tools.mo.utils.cli_parser import get_mo_convert_params as legacy_mo_params +from openvino.tools.mo import mo +from openvino.tools.mo.utils.cli_parser import get_mo_convert_params from pathlib import Path from common.utils.common_utils import shell @@ -17,8 +16,8 @@ class TestSubprocessMoConvert(unittest.TestCase): def test_mo_convert(self): mo_convert_params = get_mo_convert_params() - # Test ovc tool help - mo_path = Path(ovc.__file__).parent + # Test mo tool help + mo_path = Path(mo.__file__).parent mo_runner = mo_path.joinpath('main.py').as_posix() params = [sys.executable, mo_runner, "--help"] _, mo_output, _ = shell(params) @@ -35,7 +34,7 @@ def test_mo_convert(self): params = [sys.executable, mo_help_file] _, mo_output, _ = shell(params) - legacy_params = legacy_mo_params() + legacy_params = get_mo_convert_params() for group in legacy_params: for param_name in group: assert param_name in mo_output diff --git a/tests/layer_tests/ovc_python_api_tests/conftest.py b/tests/layer_tests/ovc_python_api_tests/conftest.py new file mode 100644 index 00000000000000..7a32373605e452 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/conftest.py @@ -0,0 +1,13 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import inspect + +from common.layer_test_class import get_params + + +def pytest_generate_tests(metafunc): + test_gen_attrs_names = list(inspect.signature(get_params).parameters) + params = get_params() + + metafunc.parametrize(test_gen_attrs_names, params, scope="function") diff --git a/tests/layer_tests/ovc_python_api_tests/test_complex_params.py b/tests/layer_tests/ovc_python_api_tests/test_complex_params.py new file mode 100644 index 00000000000000..228db2f2cb0356 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_complex_params.py @@ -0,0 +1,167 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import openvino.runtime as ov +import os +import pytest +import tempfile +import unittest +from openvino.runtime import Model, Layout, PartialShape, Shape, layout_helpers, Type, Dimension + +from common.mo_convert_test_class import CommonMOConvertTest +from common.tf_layer_test_class import save_to_pb + + +class TestComplexParams(CommonMOConvertTest): + @staticmethod + def create_tf_model(tmp_dir): + # + # Create Tensorflow model with multiple inputs/outputs + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + inp1 = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input1') + inp2 = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input2') + inp3 = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input3') + + relu1 = tf.nn.relu(inp1, name='Relu1') + relu2 = tf.nn.relu(inp2, name='Relu2') + relu3 = tf.nn.relu(inp3, name='Relu3') + + concat = tf.concat([relu1, relu2, relu3], axis=0, name='Concat') + + outputs = tf.split(concat, 3) + outputs_list = [] + for i, output in enumerate(outputs): + outputs_list.append(tf.nn.sigmoid(output, name='Sigmoid_{}'.format(i))) + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # save model to .pb and return path to the model + return save_to_pb(tf_net, tmp_dir) + + @staticmethod + def create_tf_model_single_input_output(tmp_dir): + # + # Create Tensorflow model with single input/output + # + + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + inp = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input') + + relu = tf.nn.relu(inp, name='Relu') + + output = tf.nn.sigmoid(relu, name='Sigmoid') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # save model to .pb and return path to the model + return save_to_pb(tf_net, tmp_dir) + + test_data = [ + {'params_test': {'output': ["Sigmoid_0", "Sigmoid_2"]}, + 'params_ref': {'output': "Sigmoid_0,Sigmoid_2"}}, + {'params_test': {'output': ["Sigmoid_0"]}, + 'params_ref': {'output': "Sigmoid_0"}}, + {'params_test': {'input': [PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)]]}, + 'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}}, + {'params_test': {'input': [PartialShape([1, 3, -1, -1]), [1, 3, -1, -1]]}, + 'params_ref': {'input_shape': "[1,3,?,?],[1,3,?,?]", 'input': 'Input1,Input2'}}, + {'params_test': {'input': [(2, 3, 4), [2, 3, 4], (Dimension(2), Dimension(3), Dimension(4))]}, + 'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}}, + {'params_test': {'input': {"Input1": PartialShape([2, 3, 4]), "Input2": [2, 3, 4], + "Input3": [Dimension(2), Dimension(3), Dimension(4)]}}, + 'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}}, + {'params_test': {'input': {"Input2": [1, -1, -1, -1], + "Input3": [Dimension(1), Dimension(-1), Dimension(-1), Dimension(-1)]}}, + 'params_ref': {'input_shape': "[1,?,?,?],[1,?,?,?]", 'input': 'Input2,Input3'}}, + {'params_test': {'input': [np.int32, Type(np.int32), np.int32]}, + 'params_ref': {'input': 'Input1{i32},Input2{i32},Input3{i32}'}}, + {'params_test': {'input': [ov.Type.f32, ov.Type.f32]}, + 'params_ref': {'input': 'Input1{f32},Input2{f32}'}}, + {'params_test': {'input': [([1, 3, -1, -1], ov.Type.i32), ov.Type.i32, ov.Type.i32]}, + 'params_ref': {'input': 'Input1[1,3,?,?]{i32},Input2{i32},Input3{i32}'}} + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_mo_convert_tf_model(self, params, ie_device, precision, ir_version, + temp_dir, use_new_frontend, use_old_api): + tf_net_path = self.create_tf_model(temp_dir) + + test_params = params['params_test'] + ref_params = params['params_ref'] + test_params.update({'input_model': tf_net_path}) + ref_params.update({'input_model': tf_net_path}) + self._test(temp_dir, test_params, ref_params) + + test_data = [ + {'params_test': {'input': {"Input": ([3, 2], ov.Type.i32)}}, + 'params_ref': {'input': "Input[3,2]{i32}"}}, + {'params_test': {'input': {"Input": ov.Type.i32}}, + 'params_ref': {'input': "Input{i32}"}}, + {'params_test': {'input': {"Input": [3, 2]}}, + 'params_ref': {'input': "Input[3,2]"}}, + {'params_test': {'input': (3, 2)}, + 'params_ref': {'input': "Input[3,2]"}}, + {'params_test': {'input': (3, Dimension(2))}, + 'params_ref': {'input': "Input[3,2]"}}, + {'params_test': {'input': [3, 2]}, + 'params_ref': {'input': "Input[3 2]"}}, + {'params_test': {'input': [Dimension(3, 10), 2]}, + 'params_ref': {'input': "Input[3..10 2]"}}, + {'params_test': {'input': (-1, 10)}, + 'params_ref': {'input': "Input[?,10]"}}, + {'params_test': {'input': PartialShape([-1, 10])}, + 'params_ref': {'input': "Input[?,10]"}}, + {'params_test': {'input': np.int32}, + 'params_ref': {'input': "Input{i32}"}}, + {'params_test': {'input': (np.int32, [1, 2, 3])}, + 'params_ref': {'input': "Input[1,2,3]{i32}"}}, + {'params_test': {'input': [Dimension(3, 10), 10, -1]}, + 'params_ref': {'input': 'Input[3..10,10,?]'}}, + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + @pytest.mark.precommit + def test_mo_convert_tf_model_single_input_output(self, params, ie_device, precision, ir_version, + temp_dir, use_new_frontend, use_old_api): + tf_net_path = self.create_tf_model_single_input_output(temp_dir) + + test_params = params['params_test'] + ref_params = params['params_ref'] + test_params.update({'input_model': tf_net_path}) + ref_params.update({'input_model': tf_net_path}) + self._test(temp_dir, test_params, ref_params) + +class NegativeCases(unittest.TestCase): + test_directory = os.path.dirname(os.path.realpath(__file__)) + + def test_input_output_cut_exceptions(self): + from openvino.tools.ovc import convert_model + with tempfile.TemporaryDirectory(dir=self.test_directory) as temp_dir: + tf_net_path = TestComplexParams.create_tf_model_single_input_output(temp_dir) + + with self.assertRaisesRegex(Exception, ".*Name Relu is not found among model inputs.*"): + convert_model(tf_net_path, input='Relu') + with self.assertRaisesRegex(Exception, ".*Name Relu is not found among model outputs.*"): + convert_model(tf_net_path, output='Relu') + + tf_net_path = TestComplexParams.create_tf_model(temp_dir) + + with self.assertRaisesRegex(Exception, ".*Name Relu2 is not found among model inputs.*"): + convert_model(tf_net_path, input='Relu2') + with self.assertRaisesRegex(Exception, ".*Name Relu2 is not found among model outputs.*"): + convert_model(tf_net_path, output='Relu2') \ No newline at end of file diff --git a/tests/layer_tests/ovc_python_api_tests/test_extensions.py b/tests/layer_tests/ovc_python_api_tests/test_extensions.py new file mode 100644 index 00000000000000..5cc02f76f54416 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_extensions.py @@ -0,0 +1,121 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +import numpy as np + +from common.mo_convert_test_class import CommonMOConvertTest +from common.onnx_layer_test_class import save_to_onnx + +import openvino.runtime as ov +from openvino.runtime import PartialShape, Model + + +class TestExtensions(CommonMOConvertTest): + def create_onnx_model(self, tmp_dir): + # + # Create ONNX model + # + + import onnx + from onnx import helper + from onnx import TensorProto + + shape = [2, 3, 4] + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'LeakyRelu', + inputs=['input'], + outputs=['LeakyRelu_data'], + alpha=0.1 + ) + node_def2 = onnx.helper.make_node( + 'Elu', + inputs=['LeakyRelu_data'], + outputs=['output'], + alpha=0.1 + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def, node_def2], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + # save model to .onnx and return path to the model + return save_to_onnx(onnx_net, tmp_dir) + + def create_custom_extension_leaky_relu_to_relu(): + # replaces LeakyRelu with Relu + from openvino.frontend import ConversionExtension + from openvino.frontend import NodeContext + import openvino.runtime.opset8 as ops + + def custom_converter(node: NodeContext): + input = node.get_input(0) + relu = ops.relu(input) + return [relu.output(0)] + + return ConversionExtension("LeakyRelu", custom_converter) + + def create_custom_extension_elu_to_sigmoid(): + # replaces Elu with Sigmoid + from openvino.frontend import ConversionExtension + from openvino.frontend import NodeContext + import openvino.runtime.opset8 as ops + + def custom_converter(node: NodeContext): + input = node.get_input(0) + sigm = ops.sigmoid(input) + return [sigm.output(0)] + + return ConversionExtension("Elu", custom_converter) + + def create_ref_graph1(): + shape = PartialShape([2, 3, 4]) + param = ov.opset8.parameter(shape, dtype=np.float32) + param.get_output_tensor(0).set_names({"input"}) + relu = ov.opset8.relu(param) + relu.get_output_tensor(0).set_names({"LeakyRelu_data"}) + elu = ov.opset8.elu(relu, alpha=0.1) + elu.get_output_tensor(0).set_names({"output"}) + + return Model([elu], [param], "test") + + def create_ref_graph2(): + shape = PartialShape([2, 3, 4]) + param = ov.opset8.parameter(shape, dtype=np.float32) + param.get_output_tensor(0).set_names({"input"}) + relu = ov.opset8.relu(param) + relu.get_output_tensor(0).set_names({"LeakyRelu_data"}) + sigmoid = ov.opset8.sigmoid(relu) + sigmoid.get_output_tensor(0).set_names({"output"}) + + return Model([sigmoid], [param], "test") + + test_data = [ + {'params_test': {'extension': create_custom_extension_leaky_relu_to_relu()}, + 'ref_graph': create_ref_graph1()}, + {'params_test': {'extension': [create_custom_extension_leaky_relu_to_relu(), + create_custom_extension_elu_to_sigmoid()]}, + 'ref_graph': create_ref_graph2()} + ] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + @pytest.mark.precommit + def test_mo_convert_extensions(self, params, ie_device, precision, ir_version, + temp_dir, use_new_frontend, use_old_api): + onnx_net_path = self.create_onnx_model(temp_dir) + + test_params = params['params_test'] + test_params.update({'input_model': onnx_net_path}) + self._test_by_ref_graph(temp_dir, test_params, params['ref_graph']) diff --git a/tests/layer_tests/ovc_python_api_tests/test_onnx.py b/tests/layer_tests/ovc_python_api_tests/test_onnx.py new file mode 100644 index 00000000000000..58fd799a507dc9 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_onnx.py @@ -0,0 +1,83 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import io + +import numpy as np +import openvino.runtime as ov +import pytest +from openvino.runtime import Model + +from common.mo_convert_test_class import CommonMOConvertTest + + +def make_graph_proto_model(): + import onnx + from onnx import helper + from onnx import TensorProto + + shape = [2, 3, 4] + + input = helper.make_tensor_value_info('input', TensorProto.FLOAT, shape) + output = helper.make_tensor_value_info('output', TensorProto.FLOAT, shape) + + node_def = onnx.helper.make_node( + 'LeakyRelu', + inputs=['input'], + outputs=['LeakyRelu_data'], + alpha=0.1 + ) + node_def2 = onnx.helper.make_node( + 'Elu', + inputs=['LeakyRelu_data'], + outputs=['output'], + alpha=0.1 + ) + + # Create the graph (GraphProto) + graph_def = helper.make_graph( + [node_def, node_def2], + 'test_model', + [input], + [output], + ) + + # Create the model (ModelProto) + onnx_net = helper.make_model(graph_def, producer_name='test_model') + + return onnx_net + +def create_ref_model(shape): + param1 = ov.opset8.parameter(shape, dtype=np.float32) + slope_const = ov.opset8.constant([0.1], dtype=np.float16) + decompress_slope = ov.opset8.convert(slope_const, np.float32) + prelu = ov.opset8.prelu(param1, slope=decompress_slope) + relu = ov.opset8.elu(prelu, alpha=np.float32(0.1)) + parameter_list = [param1] + return Model([relu], parameter_list, "test") + +def create_bytes_io(): + import onnx + onnx_model = make_graph_proto_model() + + file_like_object = io.BytesIO() + onnx.save(onnx_model, file_like_object) + + ref_model = create_ref_model([2,3,4]) + return file_like_object, ref_model, {} + + +class TestMoConvertONNX(CommonMOConvertTest): + test_data = [create_bytes_io] + @pytest.mark.parametrize("create_model", test_data) + @pytest.mark.nightly + @pytest.mark.precommit + def test_mo_convert_onnx(self, create_model, ie_device, precision, ir_version, + temp_dir): + fw_model, graph_ref, mo_params = create_model() + + test_params = {'input_model': fw_model} + if mo_params is not None: + test_params.update(mo_params) + self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) + diff --git a/tests/layer_tests/mo_python_api_tests/test_ovc_cli_tool.py b/tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.py similarity index 85% rename from tests/layer_tests/mo_python_api_tests/test_ovc_cli_tool.py rename to tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.py index 0ef3b08a4ba6b8..a1ccdf96ee6353 100644 --- a/tests/layer_tests/mo_python_api_tests/test_ovc_cli_tool.py +++ b/tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.py @@ -89,3 +89,18 @@ def test_ovc_tool(self, ie_device, precision, ir_version, temp_dir, use_new_fron ov_model = core.read_model(os.path.join(temp_dir, "model.xml")) flag, msg = compare_functions(ov_model, create_ref_graph(), False) assert flag, msg + + def test_ovc_tool_output_dir(self, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): + from openvino.runtime import Core + + model_path = self.create_tf_model(temp_dir) + + core = Core() + + # tests for MO cli tool + exit_code, stderr = generate_ir_ovc(coverage=False, **{"input_model": model_path, "output_model": temp_dir}) + assert not exit_code + + ov_model = core.read_model(os.path.join(temp_dir, "model.xml")) + flag, msg = compare_functions(ov_model, create_ref_graph(), False) + assert flag, msg \ No newline at end of file diff --git a/tests/layer_tests/ovc_python_api_tests/test_ovc_tool_help.py b/tests/layer_tests/ovc_python_api_tests/test_ovc_tool_help.py new file mode 100644 index 00000000000000..74ce9ead5717b9 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_ovc_tool_help.py @@ -0,0 +1,30 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + + +import os +import sys +import unittest +from openvino.tools.ovc import ovc +from openvino.tools.ovc.cli_parser import get_mo_convert_params +from pathlib import Path + +from common.utils.common_utils import shell + + +class TestSubprocessMoConvert(unittest.TestCase): + def test_mo_convert(self): + mo_convert_params = get_mo_convert_params() + + # Test ovc tool help + mo_path = Path(ovc.__file__).parent + mo_runner = mo_path.joinpath('main.py').as_posix() + params = [sys.executable, mo_runner, "--help"] + _, mo_output, _ = shell(params) + + # We don't expect PyTorch specific parameters to be in help message of the MO tool. + for group in mo_convert_params: + if group == 'Pytorch-specific parameters:' or group == 'PaddlePaddle-specific parameters:': + continue + for param_name in group: + assert param_name in mo_output diff --git a/tests/layer_tests/ovc_python_api_tests/test_paddle.py b/tests/layer_tests/ovc_python_api_tests/test_paddle.py new file mode 100644 index 00000000000000..de4fe954eff204 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_paddle.py @@ -0,0 +1,103 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +from common.mo_convert_test_class import CommonMOConvertTest + +import openvino.runtime as ov +from openvino.runtime import PartialShape, Model + +def make_pd_dynamic_graph_model(): + import paddle + paddle.disable_static() + class NeuralNetwork(paddle.nn.Layer): + def __init__(self): + super(NeuralNetwork, self).__init__() + self.relu_sigmoid_stack = paddle.nn.Sequential( + paddle.nn.ReLU(), + paddle.nn.Sigmoid()) + def forward(self, input): + return self.relu_sigmoid_stack(input) + return NeuralNetwork() + +def make_pd_static_graph_model(shape): + import paddle + import paddle.nn + + paddle.enable_static() + + x = paddle.static.data(name="x", shape=shape) + y = paddle.static.data(name="y", shape=shape) + relu = paddle.nn.ReLU() + sigmoid = paddle.nn.Sigmoid() + y = sigmoid(relu(x)) + + exe = paddle.static.Executor(paddle.CPUPlace()) + exe.run(paddle.static.default_startup_program()) + return exe, x, y + +def make_pd_hapi_graph_model(shape): + import paddle + paddle.disable_static() + from paddle.static import InputSpec + net = paddle.nn.Sequential( + paddle.nn.ReLU(), + paddle.nn.Sigmoid()) + input = InputSpec(shape, 'float32', 'x') + label = InputSpec(shape, 'float32', 'label') + + model = paddle.Model(net, input, label) + optim = paddle.optimizer.SGD(learning_rate=1e-3, + parameters=model.parameters()) + model.prepare(optim, paddle.nn.CrossEntropyLoss(), paddle.metric.Accuracy()) + return model + +def make_ref_graph_model(shape, dtype=np.float32): + shape = PartialShape(shape) + param = ov.opset8.parameter(shape, name="x", dtype=dtype) + + relu = ov.opset8.relu(param) + sigm = ov.opset8.sigmoid(relu) + + model = Model([sigm], [param], "test") + return model + +def create_paddle_dynamic_module(tmp_dir): + import paddle + shape = [2,3,4] + pd_model = make_pd_dynamic_graph_model() + ref_model = make_ref_graph_model(shape) + + x = paddle.static.InputSpec(shape=shape, dtype='float32', name='x') + return pd_model, ref_model, {"example_input": [x]} + +def create_paddle_static_module(tmp_dir): + shape = [2,3,4] + pd_model, x, y = make_pd_static_graph_model(shape) + ref_model = make_ref_graph_model(shape) + + return pd_model, ref_model, {"example_input": [x], "example_output": [y]} + +def create_paddle_hapi_module(tmp_dir): + shape = [2,3,4] + pd_model = make_pd_hapi_graph_model(shape) + ref_model = make_ref_graph_model(shape) + + return pd_model, ref_model, {} + +class TestMoConvertPaddle(CommonMOConvertTest): + test_data = [ + create_paddle_dynamic_module, + create_paddle_static_module, + create_paddle_hapi_module + ] + @pytest.mark.skip(reason="Paddlepaddle has incompatible protobuf. Ticket: 95904") + @pytest.mark.parametrize("create_model", test_data) + def test_mo_import_from_memory_paddle_fe(self, create_model, ie_device, precision, ir_version, + temp_dir): + fw_model, graph_ref, mo_params = create_model(temp_dir) + test_params = {'input_model': fw_model, 'use_new_frontend': True} + if mo_params is not None: + test_params.update(mo_params) + self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) diff --git a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py new file mode 100644 index 00000000000000..19c7f215e48440 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py @@ -0,0 +1,1073 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +from typing import Tuple +import numpy +import numpy as np +import openvino.runtime as ov +import pytest +import torch +import unittest +from openvino.runtime import PartialShape, Dimension, Model, Type +from openvino.tools.mo import InputCutInfo +from common.mo_convert_test_class import CommonMOConvertTest + + +class MyTorchOp(torch.autograd.Function): + @staticmethod + def symbolic(g, in_positions): + return g.op("MyTorchOp", in_positions) + + @staticmethod + def forward(self, in_positions): + out_pos = in_positions.reshape(-1) + return out_pos + 0.5 + + +def make_pt_model_one_input(): + from torch import nn + + class NeuralNetwork(nn.Module): + def __init__(self): + super(NeuralNetwork, self).__init__() + self.linear_relu_stack = nn.Sequential( + nn.ReLU(), + nn.Sigmoid(), + ) + + def forward(self, x): + logits = self.linear_relu_stack(x) + return logits + + return NeuralNetwork() + + +def make_pt_model_two_inputs(): + from torch import nn + + class NeuralNetwork(nn.Module): + def __init__(self): + super(NeuralNetwork, self).__init__() + self.linear_relu_stack = nn.Sequential( + nn.ReLU(), + nn.Sigmoid(), + ) + + def forward(self, x, y): + logits = self.linear_relu_stack(x * y) + return logits + + return NeuralNetwork() + + +def make_pt_model_with_optional_input(): + from torch import nn + + class NeuralNetwork(nn.Module): + def __init__(self): + super(NeuralNetwork, self).__init__() + self.linear_relu_stack = nn.Sequential( + nn.ReLU(), + nn.Sigmoid(), + ) + + def forward(self, x, y=None, z=None): + logits = None + if y is None: + logits = self.linear_relu_stack(x + z) + if z is None: + logits = self.linear_relu_stack(x * y) + return logits + + return NeuralNetwork() + + +def make_ref_pt_model_one_input(shape, dtype=np.float32): + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape, name="input_0", dtype=dtype) + relu = ov.opset8.relu(param1) + if dtype not in [np.float32, Type.dynamic]: + relu = ov.opset8.convert(relu, np.float32) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1] + model = Model([sigm], parameter_list, "test") + return model + + +def make_ref_pt_model_two_inputs(shape, dtype=np.float32): + if len(shape) == 2: + param1 = ov.opset8.parameter(PartialShape( + shape[0]), name="input_0", dtype=dtype) + param2 = ov.opset8.parameter(PartialShape( + shape[1]), name="input_1", dtype=dtype) + else: + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape, name="input_0", dtype=dtype) + param2 = ov.opset8.parameter(shape, name="input_1", dtype=dtype) + if dtype == Type.dynamic: + cl = ov.opset8.convert_like(param2, param1) + mul = ov.opset8.multiply(param1, cl) + else: + mul = ov.opset8.multiply(param1, param2) + relu = ov.opset8.relu(mul) + if dtype not in [np.float32, Type.dynamic]: + relu = ov.opset8.convert(relu, np.float32) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model = Model([sigm], parameter_list, "test") + return model + + +def make_ref_pt_model_with_optional_inputs(shape, dtype=np.float32, z_exist=False): + if len(shape) == 2: + param1 = ov.opset8.parameter(PartialShape( + shape[0]), name="input_0", dtype=dtype) + param2 = ov.opset8.parameter(PartialShape( + shape[1]), name="input_1", dtype=dtype) + else: + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape, name="input_0", dtype=dtype) + param2 = ov.opset8.parameter(shape, name="input_1", dtype=dtype) + + op = ov.opset8.multiply( + param1, param2) if not z_exist else ov.opset8.add(param1, param2) + relu = ov.opset8.relu(op) + if dtype != np.float32: + relu = ov.opset8.convert(relu, np.float32) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model = Model([sigm], parameter_list, "test") + return model + + +def create_pytorch_nn_module_case1(tmp_dir): + pt_model = make_pt_model_two_inputs() + ref_model = make_ref_pt_model_two_inputs([-1, -1, -1, -1]) + + sample_input1 = torch.zeros(1, 3, 10, 10) + sample_input2 = torch.zeros(1, 3, 10, 10) + sample_input = sample_input1, sample_input2 + + return pt_model, ref_model, {'example_input': sample_input} + + +def create_pytorch_nn_module_case2(tmp_dir): + pt_model = make_pt_model_two_inputs() + ref_model = make_ref_pt_model_two_inputs([-1, 3, -1, -1]) + + sample_input1 = torch.zeros(1, 3, 10, 10) + sample_input2 = torch.zeros(1, 3, 10, 10) + sample_input = sample_input1, sample_input2 + + return pt_model, ref_model, {'input': [PartialShape("[?,3,?,?]"), PartialShape([-1, 3, -1, -1])], + 'example_input': sample_input} + + +def create_pytorch_nn_module_with_scalar_input(tmp_dir): + pt_model = make_pt_model_two_inputs() + ref_model = make_ref_pt_model_two_inputs([[], [-1, 3, -1, -1]]) + + sample_input1 = torch.tensor(0.66) + sample_input2 = torch.zeros(1, 3, 10, 10) + sample_input = sample_input1, sample_input2 + + return pt_model, ref_model, {'input': ["[]", PartialShape([-1, 3, -1, -1])], + 'example_input': sample_input} + + +def create_pytorch_nn_module_case3(tmp_dir): + pt_model = make_pt_model_two_inputs() + ref_model = make_ref_pt_model_two_inputs([-1, 3, -1, -1]) + + sample_input1 = torch.zeros(1, 3, 10, 10) + sample_input2 = torch.zeros(1, 3, 10, 10) + sample_input = tuple([sample_input1, sample_input2]) + + return pt_model, ref_model, {'input': "[?,3,?,?],[?,3,?,?]", + 'example_input': sample_input} + + +def create_pytorch_nn_module_case4(tmp_dir): + pt_model = make_pt_model_one_input() + + sample_input = torch.zeros(1, 3, 10, 10) + + ref_model = make_ref_pt_model_one_input(PartialShape([1, 3, 20, 20])) + + return pt_model, ref_model, {'example_input': sample_input, "input": [1, 3, 20, 20]} + + +def create_pytorch_nn_module_case5(tmp_dir): + pt_model = make_pt_model_one_input() + inp_shape = PartialShape([-1, 3, Dimension(2, -1), Dimension(-1, 10)]) + ref_model = make_ref_pt_model_one_input(inp_shape) + + sample_input = torch.zeros(3, 3, 10, 10) + return pt_model, ref_model, {'example_input': sample_input, + 'input': (inp_shape, np.float32)} + + +def create_pytorch_nn_module_case6(tmp_dir): + pt_model = make_pt_model_one_input() + shape = PartialShape([1, 3, Dimension(2, -1), Dimension(-1, 10)]) + ref_model = make_ref_pt_model_one_input(shape) + + return pt_model, ref_model, {'input': (shape, np.float32)} + + +def create_pytorch_nn_module_case7(tmp_dir): + pt_model = make_pt_model_one_input() + + sample_input = torch.zeros(1, 3, 10, 10, dtype=torch.int32) + + ref_model = make_ref_pt_model_one_input( + PartialShape([1, 3, 20, 20]), dtype=np.int32) + + return pt_model, ref_model, {'example_input': sample_input, "input": ([1, 3, 20, 20], np.int32)} + + +def create_pytorch_nn_module_torch_size(tmp_dir): + pt_model = make_pt_model_one_input() + ref_model = make_ref_pt_model_one_input([1, 3, 2, 10]) + + return pt_model, ref_model, {'input': (torch.Size([1, 3, 2, 10]), np.float32)} + + +def create_pytorch_nn_module_sample_input_int32(tmp_dir): + pt_model = make_pt_model_one_input() + shape = PartialShape([-1, 3, Dimension(2, -1), Dimension(-1, 10)]) + + sample_input = torch.zeros(1, 3, 10, 10, dtype=torch.int32) + + ref_model = make_ref_pt_model_one_input(shape, dtype=np.int32) + + return pt_model, ref_model, {'example_input': sample_input, + 'input': (shape, np.int32)} + + +def create_pytorch_nn_module_sample_input_int32_two_inputs(tmp_dir): + pt_model = make_pt_model_two_inputs() + inp_shapes = [PartialShape("[?,3,?,?]"), PartialShape([-1, 3, -1, -1])] + + sample_input1 = torch.zeros(1, 3, 10, 10, dtype=torch.int32) + sample_input2 = torch.zeros(1, 3, 10, 10, dtype=torch.int32) + sample_input = sample_input1, sample_input2 + ref_model = make_ref_pt_model_two_inputs( + [PartialShape([-1, 3, -1, -1]), inp_shapes[1]], dtype=np.int32) + + return pt_model, ref_model, {'input': [(np.int32, inp_shapes[0]), (np.int32, inp_shapes[1])], + 'example_input': sample_input} + + +def create_pytorch_jit_script_module(tmp_dir): + import torch + + net = make_pt_model_two_inputs() + scripted_model = torch.jit.script(net) + + model_ref = make_ref_pt_model_two_inputs([1, 3, 5, 5]) + return scripted_model, model_ref, {'input': [([1, 3, 5, 5], np.float32), ([1, 3, 5, 5], np.float32)]} + + +def create_pytorch_jit_script_function(tmp_dir): + import torch + + @torch.jit.script + def scripted_fn(x: torch.Tensor, y: torch.Tensor): + return torch.sigmoid(torch.relu(x * y)) + + inp_shape = PartialShape([Dimension(1, -1), Dimension(-1, 5), 10]) + ref_model = make_ref_pt_model_two_inputs(inp_shape, dtype=Type.dynamic) + return scripted_fn, ref_model, {'input': [(inp_shape), (inp_shape)]} + + +def create_pytorch_nn_module_layout_list(tmp_dir): + from openvino.runtime import Layout + pt_model = make_pt_model_two_inputs() + shape = [1, 3, 10, 10] + + shape = PartialShape(shape) + ref_model = make_ref_pt_model_two_inputs(shape) + ref_model.inputs[0].node.layout = Layout('nchw') + ref_model.inputs[1].node.layout = Layout('nhwc') + + return pt_model, ref_model, { + 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ['nchw', Layout('nhwc')], + 'use_convert_model_from_mo': True + } + + +def create_pytorch_nn_module_layout_list_case2(tmp_dir): + from openvino.runtime import Layout + pt_model = make_pt_model_two_inputs() + shape = [1, 3, 10, 10] + + shape = PartialShape(shape) + ref_model = make_ref_pt_model_two_inputs(shape) + ref_model.inputs[0].node.layout = Layout('nchw') + ref_model.inputs[1].node.layout = Layout('nhwc') + + return pt_model, ref_model, { + 'input': [(shape, np.float32), (shape, np.float32)], 'layout': ('nchw', Layout('nhwc')), + 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_mean_list_compression_disabled(tmp_dir): + pt_model = make_pt_model_two_inputs() + shape = [1, 10, 10, 3] + + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape) + param2 = ov.opset8.parameter(shape) + const1 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32) + const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32) + add1 = ov.opset8.add(param1, const1) + add2 = ov.opset8.add(param2, const2) + mul = ov.opset8.multiply(add1, add2) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'mean_values': [[0, 0, 0], [0, 0, 0]], + 'compress_to_fp16': False, 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_mean_list_compression_default(tmp_dir): + # when 'use_convert_model_from_mo': True by default compression in convert_model is disabled + # therefore decompression Converts will not be present + pt_model = make_pt_model_two_inputs() + shape = [1, 10, 10, 3] + + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape) + param2 = ov.opset8.parameter(shape) + const1 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32) + const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32) + add1 = ov.opset8.add(param1, const1) + add2 = ov.opset8.add(param2, const2) + mul = ov.opset8.multiply(add1, add2) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'mean_values': [[0, 0, 0], [0, 0, 0]], + 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_mean_list_compression_enabled(tmp_dir): + pt_model = make_pt_model_two_inputs() + shape = [1, 10, 10, 3] + + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape) + param2 = ov.opset8.parameter(shape) + const1 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float16) + const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float16) + const1_decompressed = ov.opset8.convert( + const1, destination_type=np.float32) + const2_decompressed = ov.opset8.convert( + const2, destination_type=np.float32) + + add1 = ov.opset8.add(param1, const1_decompressed) + add2 = ov.opset8.add(param2, const2_decompressed) + mul = ov.opset8.multiply(add1, add2) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + + return pt_model, ref_model, { + 'input': [(shape, np.float32), (shape, np.float32)], 'mean_values': [[0, 0, 0], [0, 0, 0]], + 'compress_to_fp16': True, 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_scale_list_compression_disabled(tmp_dir): + pt_model = make_pt_model_two_inputs() + shape = [1, 10, 10, 3] + + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape) + param2 = ov.opset8.parameter(shape) + const1 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32) + const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32) + sub1 = ov.opset8.multiply(param1, const1) + sub2 = ov.opset8.multiply(param2, const2) + mul = ov.opset8.multiply(sub1, sub2) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'scale_values': [[1, 1, 1], [1, 1, 1]], + 'compress_to_fp16': False, 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_scale_list_compression_default(tmp_dir): + # when 'use_convert_model_from_mo': True by default compression in convert_model is disabled + # therefore decompression Converts will not be present + pt_model = make_pt_model_two_inputs() + shape = [1, 10, 10, 3] + + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape) + param2 = ov.opset8.parameter(shape) + const1 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32) + const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32) + sub1 = ov.opset8.multiply(param1, const1) + sub2 = ov.opset8.multiply(param2, const2) + mul = ov.opset8.multiply(sub1, sub2) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'scale_values': [[1, 1, 1], [1, 1, 1]], + 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_scale_list_compression_enabled(tmp_dir): + pt_model = make_pt_model_two_inputs() + shape = [1, 10, 10, 3] + + shape = PartialShape(shape) + param1 = ov.opset8.parameter(shape) + param2 = ov.opset8.parameter(shape) + const1 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float16) + const1_decompressed = ov.opset8.convert( + const1, destination_type=np.float32) + const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float16) + const2_decompressed = ov.opset8.convert( + const2, destination_type=np.float32) + mul1 = ov.opset8.multiply(param1, const1_decompressed) + mul2 = ov.opset8.multiply(param2, const2_decompressed) + mul3 = ov.opset8.multiply(mul1, mul2) + relu = ov.opset8.relu(mul3) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + + return pt_model, ref_model, {'input': [(shape, np.float32), (shape, np.float32)], + 'scale_values': [[1, 1, 1], [1, 1, 1]], + 'compress_to_fp16': True, 'use_convert_model_from_mo': True} + + +def create_pytorch_nn_module_shapes_list_static(tmp_dir): + pt_model = make_pt_model_two_inputs() + ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20], dtype=Type.dynamic) + + return pt_model, ref_model, {'input': [[1, 3, 20, 20], [1, 3, 20, 20]]} + + +def create_pytorch_nn_module_shapes_list_static_via_input(tmp_dir): + pt_model = make_pt_model_two_inputs() + ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20]) + + return pt_model, ref_model, {'input': [([1, 3, 20, 20], np.float32), ([1, 3, 20, 20], np.float32)]} + + +def create_pytorch_nn_module_shapes_list_dynamic(tmp_dir): + pt_model = make_pt_model_two_inputs() + inp_shapes = [[Dimension(-1), 3, 20, Dimension(20, -1)], + [-1, 3, 20, Dimension(-1, 20)]] + + param1 = ov.opset8.parameter(PartialShape( + inp_shapes[0]), name="x", dtype=Type.dynamic) + param2 = ov.opset8.parameter(PartialShape( + inp_shapes[1]), name="y", dtype=Type.dynamic) + cl = ov.opset8.convert_like(param2, param1) + mul = ov.opset8.multiply(param1, cl) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + return pt_model, ref_model, {'input': inp_shapes} + + +def create_pytorch_nn_module_shapes_list_dynamic_via_input(tmp_dir): + pt_model = make_pt_model_two_inputs() + inp_shapes = [[Dimension(-1), 3, 20, Dimension(20, -1)], + [-1, 3, 20, Dimension(-1, 20)]] + + param1 = ov.opset8.parameter(PartialShape( + inp_shapes[0]), name="x", dtype=np.float32) + param2 = ov.opset8.parameter(PartialShape( + inp_shapes[1]), name="y", dtype=np.float32) + mul = ov.opset8.multiply(param1, param2) + relu = ov.opset8.relu(mul) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + return pt_model, ref_model, {'input': [(inp_shapes[0], Type.f32), (inp_shapes[1], Type.f32)]} + + +def create_pytorch_nn_module_shapes_list_dynamic_single_input(tmp_dir): + pt_model = make_pt_model_one_input() + inp_shapes = [[Dimension(-1), 3, 20, Dimension(20, -1)]] + ref_model = make_ref_pt_model_one_input(inp_shapes[0], dtype=Type.dynamic) + return pt_model, ref_model, {'input': inp_shapes} + + +def create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input(tmp_dir): + pt_model = make_pt_model_one_input() + inp_shapes = [Dimension(-1), 3, 20, Dimension(20, -1)] + ref_model = make_ref_pt_model_one_input(inp_shapes) + return pt_model, ref_model, {'input': (inp_shapes, np.float32)} + + +def create_pytorch_nn_module_shapes_list_static_single_input(tmp_dir): + pt_model = make_pt_model_one_input() + inp_shapes = [[1, 3, 20, 20]] + ref_model = make_ref_pt_model_one_input(inp_shapes[0], dtype=Type.dynamic) + return pt_model, ref_model, {'input': inp_shapes} + + +def create_pytorch_nn_module_shapes_list_static_single_input_via_input(tmp_dir): + pt_model = make_pt_model_one_input() + inp_shapes = [1, 3, 20, 20] + ref_model = make_ref_pt_model_one_input(inp_shapes) + return pt_model, ref_model, {'input': (inp_shapes, np.float32)} + + +def create_pytorch_nn_module_convert_pytorch_frontend1(tmp_dir): + pt_model = make_pt_model_one_input() + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param = ov.opset10.parameter(shape) + relu = ov.opset10.relu(param) + sigm = ov.opset10.sigmoid(relu) + + parameter_list = [param] + ref_model = Model([sigm], parameter_list, "test") + return pt_model, ref_model, { + "example_input": torch.zeros((1, 3, 10, 10)), + 'input': [([-1, -1, -1, -1], np.float32)] + } + + +def create_pytorch_nn_module_convert_pytorch_frontend2(tmp_dir): + pt_model = make_pt_model_one_input() + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param = ov.opset10.parameter(shape, Type.i32) + relu = ov.opset10.relu(param) + convt = ov.opset10.convert(relu, "f32") + sigm = ov.opset10.sigmoid(convt) + + parameter_list = [param] + ref_model = Model([sigm], parameter_list, "test") + return pt_model, ref_model, { + "example_input": torch.zeros((1, 3, 10, 10), dtype=torch.int32), + 'input': [([-1, -1, -1, -1], np.int32)] + } + + +def create_pytorch_nn_module_convert_pytorch_frontend3(tmp_dir): + pt_model = make_pt_model_two_inputs() + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + param2 = ov.opset10.parameter(shape, dtype=np.float32) + mul = ov.opset10.multiply(param1, param2) + relu = ov.opset10.relu(mul) + sigm = ov.opset10.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + return pt_model, ref_model, { + "example_input": [torch.zeros((1, 3, 10, 10)), torch.ones((1, 3, 10, 10))], + 'input': [([-1, -1, -1, -1], np.float32), ([-1, -1, -1, -1], np.float32)] + } + + +def create_pytorch_nn_module_convert_pytorch_frontend4(tmp_dir): + pt_model = make_pt_model_two_inputs() + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + param2 = ov.opset10.parameter(shape, dtype=np.float32) + mul = ov.opset10.multiply(param1, param2) + relu = ov.opset10.relu(mul) + sigm = ov.opset10.sigmoid(relu) + + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + return pt_model, ref_model, { + "example_input": {"x": torch.zeros((1, 3, 10, 10), dtype=torch.float32), + "y": torch.ones((1, 3, 10, 10), dtype=torch.float32)}, + 'input': [([-1, -1, -1, -1], np.float32), ([-1, -1, -1, -1], np.float32)] + } + + +def create_pytorch_jit_script_module_convert_pytorch_frontend(tmp_dir): + import torch + + net = make_pt_model_two_inputs() + scripted_model = torch.jit.script(net) + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + param2 = ov.opset10.parameter(shape, dtype=np.float32) + mul = ov.opset10.multiply(param1, param2) + relu = ov.opset10.relu(mul) + sigm = ov.opset10.sigmoid(relu) + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + return scripted_model, ref_model, { + "example_input": [torch.zeros((1, 3, 10, 10)), torch.ones((1, 3, 10, 10))]} + + +def create_pytorch_jit_trace_module_convert_pytorch_frontend(tmp_dir): + import torch + + net = make_pt_model_two_inputs() + example_input = [torch.zeros((1, 3, 10, 10)), torch.ones((1, 3, 10, 10))] + scripted_model = torch.jit.trace(net, example_input) + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + param2 = ov.opset10.parameter(shape, dtype=np.float32) + mul = ov.opset10.multiply(param1, param2) + relu = ov.opset10.relu(mul) + sigm = ov.opset10.sigmoid(relu) + parameter_list = [param1, param2] + ref_model = Model([sigm], parameter_list, "test") + return scripted_model, ref_model, {"example_input": example_input} + + +def create_pytorch_module_convert_pytorch_frontend_oob(tmp_dir): + import torch + import torch.nn.functional as F + + class ConvModel(torch.nn.Module): + def __init__(self): + super(ConvModel, self).__init__() + self.weights = torch.rand([1, 3, 3, 3]) + + def forward(self, x): + return F.conv2d(x, self.weights) + + net = ConvModel() + shape = PartialShape([-1, 3, -1, -1]) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + weights = ov.opset10.constant(net.weights.numpy(force=True), dtype=np.float16) + decompress_weights = ov.opset10.convert(weights, np.float32) + conv = ov.opset10.convolution(param1, decompress_weights, strides=[1, 1], + pads_begin=[0, 0], pads_end=[0, 0], + dilations=[1, 1]) + parameter_list = [param1] + ref_model = Model([conv], parameter_list, "test") + return net, ref_model, {} + + +def create_pytorch_module_with_optional_inputs_case1(tmp_dir): + net = make_pt_model_with_optional_input() + example_input = {"x": torch.zeros( + (1, 3, 10, 10)), "y": torch.ones((1, 3, 10, 10))} + ref_model = make_ref_pt_model_with_optional_inputs([-1, -1, -1, -1]) + return net, ref_model, {"example_input": example_input} + + +def create_pytorch_module_with_optional_inputs_case2(tmp_dir): + net = make_pt_model_with_optional_input() + example_input = {"x": torch.zeros( + (1, 3, 10, 10)), "z": torch.ones((1, 3, 10, 10))} + ref_model = make_ref_pt_model_with_optional_inputs( + [-1, -1, -1, -1], z_exist=True) + return net, ref_model, {"example_input": example_input} + + +def create_pytorch_module_with_optional_inputs_case3(tmp_dir): + net = make_pt_model_with_optional_input() + example_input = {"x": torch.zeros( + (1, 3, 10, 10)), "z": torch.ones((1, 3, 10, 10))} + ref_model = make_ref_pt_model_with_optional_inputs( + [3, 3, 3, 3], z_exist=True) + return net, ref_model, {"example_input": example_input, "input": [[3, 3, 3, 3], [3, 3, 3, 3]]} + + +def create_pytorch_module_with_compressed_int8_constant_compress_to_fp16_default(tmp_dir): + import torch + import torch.nn.functional as F + + class Int8Model(torch.nn.Module): + def __init__(self): + super(Int8Model, self).__init__() + self.weights = torch.randint(-127, 128, + [1, 3, 3, 3], dtype=torch.int8) + + def forward(self, x): + cast = self.weights.to(torch.float32) + sub = cast - 0.5 + mul = sub * 0.02 + return F.conv2d(x, mul) + + net = Int8Model() + example_input = (torch.rand((1, 3, 10, 10)),) + traced_model = torch.jit.trace(net, example_input) + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + weights = ov.opset10.constant(net.weights.numpy(force=True)) + cast1 = ov.opset10.convert(weights, np.float32) + sub1_const = np.float16(0.5).reshape(1, 1, 1, 1) + mul1_const = np.float16(0.02).reshape(1, 1, 1, 1) + sub1_const_decompress = ov.opset10.convert(sub1_const, np.float32) + mul1_const_decompress = ov.opset10.convert(mul1_const, np.float32) + sub1 = ov.opset10.subtract(cast1, sub1_const_decompress) + mul1 = ov.opset10.multiply(sub1, mul1_const_decompress) + conv = ov.opset10.convolution(param1, mul1, strides=[1, 1], + pads_begin=[0, 0], pads_end=[0, 0], + dilations=[1, 1]) + ref_model = Model([conv], [param1], "test") + return traced_model, ref_model, {"example_input": example_input} + + +def create_pytorch_module_with_compressed_int8_constant(tmp_dir): + import torch + import torch.nn.functional as F + + class Int8Model(torch.nn.Module): + def __init__(self): + super(Int8Model, self).__init__() + self.weights = torch.randint(-127, 128, + [1, 3, 3, 3], dtype=torch.int8) + + def forward(self, x): + cast = self.weights.to(torch.float32) + sub = cast - 0.5 + mul = sub * 0.02 + return F.conv2d(x, mul) + + net = Int8Model() + example_input = (torch.rand((1, 3, 10, 10)),) + traced_model = torch.jit.trace(net, example_input) + shape = [-1, -1, -1, -1] + shape = PartialShape(shape) + param1 = ov.opset10.parameter(shape, dtype=np.float32) + weights = ov.opset10.constant(net.weights.numpy(force=True)) + cast1 = ov.opset10.convert(weights, np.float32) + sub1 = ov.opset10.subtract(cast1, np.float32(0.5).reshape(1, 1, 1, 1)) + mul1 = ov.opset10.multiply(sub1, np.float32(0.02).reshape(1, 1, 1, 1)) + conv = ov.opset10.convolution(param1, mul1, strides=[1, 1], + pads_begin=[0, 0], pads_end=[0, 0], + dilations=[1, 1]) + ref_model = Model([conv], [param1], "test") + return traced_model, ref_model, {"example_input": example_input, "compress_to_fp16": False} + + +def create_pytorch_module_with_nested_inputs(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, z: Tuple[torch.Tensor, torch.Tensor]): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + return torch.cat([z1, zeros1], 1), torch.cat([z2, zeros2], 2) + + net = PTModel() + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float32) + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + concat1 = ov.opset10.concat([param1, constant_zeros1], 1) + concat2 = ov.opset10.concat([param2, constant_zeros2], 2) + ref_model = Model([concat2, concat1], [param1, param2], "test") + return net, ref_model, {"example_input": {"z": (torch.zeros((1, 10)), torch.ones((1, 5, 2)))}, + "compress_to_fp16": False} + + +def create_pytorch_module_with_nested_inputs_compress_to_fp16_default(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, z: Tuple[torch.Tensor, torch.Tensor]): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + return torch.cat([z1, zeros1], 1), torch.cat([z2, zeros2], 2) + + net = PTModel() + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float16) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float16) + const1_decompress = ov.opset10.convert(constant_zeros1, np.float32) + const2_decompress = ov.opset10.convert(constant_zeros2, np.float32) + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + concat1 = ov.opset10.concat([param1, const1_decompress], 1) + concat2 = ov.opset10.concat([param2, const2_decompress], 2) + ref_model = Model([concat2, concat1], [param1, param2], "test") + return net, ref_model, {"example_input": {"z": (torch.zeros((1, 10)), torch.ones((1, 5, 2)))}} + + +def create_pytorch_module_with_nested_inputs2(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor]): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) + + net = PTModel() + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float32) + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + param0 = ov.opset10.parameter(PartialShape([-1, -1]), dtype=np.float32) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + concat1 = ov.opset10.concat([param1, constant_zeros1], 1) + concat2 = ov.opset10.concat([param2, constant_zeros2], 2) + add = ov.opset10.add(concat1, param0) + ref_model = Model([concat2, add], [param0, param1, param2], "test") + return net, ref_model, { + "example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 5)))}, + "compress_to_fp16": False} + + +def create_pytorch_module_with_nested_inputs3(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, z: Tuple[torch.Tensor, torch.Tensor], x: torch.Tensor): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) + + net = PTModel() + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float32) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + param3 = ov.opset10.parameter(PartialShape([-1, -1]), dtype=np.float32) + concat1 = ov.opset10.concat([param1, constant_zeros1], 1) + concat2 = ov.opset10.concat([param2, constant_zeros2], 2) + add = ov.opset10.add(concat1, param3) + ref_model = Model([concat2, add], [param1, param2, param3], "test") + return net, ref_model, { + "example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 3)))}, + "compress_to_fp16": False} + + +def create_pytorch_module_with_nested_inputs4(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor], y: torch.Tensor): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) * y + + net = PTModel() + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float32) + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + param3 = ov.opset10.parameter(PartialShape([-1, -1]), dtype=np.float32) + param4 = ov.opset10.parameter(PartialShape([-1]), dtype=np.float32) + concat1 = ov.opset10.concat([param1, constant_zeros1], 1) + concat2 = ov.opset10.concat([param2, constant_zeros2], 2) + add = ov.opset10.add(concat1, param3) + mul = ov.opset10.multiply(concat2, param4) + ref_model = Model([mul, add], [param3, param1, param2, param4], "test") + return net, ref_model, { + "example_input": {"x": torch.ones((1, 10)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 10))), + "y": torch.ones((1,))}, + "compress_to_fp16": False} + + +def create_pytorch_module_with_nested_inputs5(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor], y: torch.Tensor): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) * y + + net = PTModel() + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float32) + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + param0 = ov.opset10.parameter(PartialShape([-1, -1]), dtype=np.float32) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + param4 = ov.opset10.parameter(PartialShape([-1]), dtype=np.float32) + concat1 = ov.opset10.concat([param1, constant_zeros1], 1) + concat2 = ov.opset10.concat([param2, constant_zeros2], 2) + add = ov.opset10.add(concat1, param0) + mul = ov.opset10.multiply(concat2, param4) + ref_model = Model([mul, add], [param0, param1, param2, param4], "test") + return net, ref_model, { + "example_input": [torch.ones((1, 10)), (torch.zeros((1, 10)), torch.ones((1, 5, 10))), torch.ones((1,))], + "compress_to_fp16": False} + + +def create_pytorch_module_with_nested_inputs6(tmp_dir): + class PTModel(torch.nn.Module): + + def forward(self, x: torch.Tensor, y: torch.Tensor = None, z: Tuple[torch.Tensor, torch.Tensor] = None): + z1, z2 = z + zeros1 = torch.zeros((1, 1)) + zeros2 = torch.zeros((1, 5, 1)) + if y is not None: + return torch.cat([z1, zeros1], 1) * y, torch.cat([z2, zeros2], 2) * y + return torch.cat([z1, zeros1], 1) + x, torch.cat([z2, zeros2], 2) + + net = PTModel() + constant_zeros1 = ov.opset10.constant(np.zeros((1, 1), dtype=np.float32), dtype=np.float32) + constant_zeros2 = ov.opset10.constant(np.zeros((1, 5, 1), dtype=np.float32), dtype=np.float32) + shape1 = PartialShape([1, -1]) + shape2 = PartialShape([1, 5, -1]) + param0 = ov.opset10.parameter(PartialShape([-1, -1]), dtype=np.float32) + param1 = ov.opset10.parameter(shape1, dtype=np.float32) + param2 = ov.opset10.parameter(shape2, dtype=np.float32) + concat1 = ov.opset10.concat([param1, constant_zeros1], 1) + concat2 = ov.opset10.concat([param2, constant_zeros2], 2) + add1 = ov.opset10.add(concat1, param0) + ref_model = Model([concat2, add1], [param0, param1, param2], "test") + return net, ref_model, { + "example_input": {"x": torch.ones((1, 11)), "z": (torch.zeros((1, 10)), torch.ones((1, 5, 10)))}, + "compress_to_fp16": False} + + +class TestMoConvertPyTorch(CommonMOConvertTest): + test_data = [ + create_pytorch_nn_module_case1, + create_pytorch_nn_module_case2, + create_pytorch_nn_module_case3, + create_pytorch_nn_module_case4, + create_pytorch_nn_module_case5, + create_pytorch_nn_module_case6, + create_pytorch_nn_module_case7, + create_pytorch_nn_module_torch_size, + create_pytorch_nn_module_sample_input_int32, + create_pytorch_nn_module_sample_input_int32_two_inputs, + create_pytorch_jit_script_module, + create_pytorch_jit_script_function, + create_pytorch_nn_module_layout_list, + create_pytorch_nn_module_layout_list_case2, + create_pytorch_nn_module_mean_list_compression_default, + create_pytorch_nn_module_mean_list_compression_disabled, + create_pytorch_nn_module_mean_list_compression_enabled, + create_pytorch_nn_module_scale_list_compression_default, + create_pytorch_nn_module_scale_list_compression_disabled, + create_pytorch_nn_module_scale_list_compression_enabled, + create_pytorch_nn_module_shapes_list_static, + create_pytorch_nn_module_shapes_list_static_via_input, + create_pytorch_nn_module_shapes_list_dynamic, + create_pytorch_nn_module_shapes_list_dynamic_via_input, + create_pytorch_nn_module_shapes_list_dynamic_single_input, + create_pytorch_nn_module_shapes_list_static_single_input, + create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input, + create_pytorch_nn_module_shapes_list_static_single_input_via_input, + create_pytorch_nn_module_convert_pytorch_frontend1, + create_pytorch_nn_module_convert_pytorch_frontend2, + create_pytorch_nn_module_convert_pytorch_frontend3, + create_pytorch_nn_module_convert_pytorch_frontend4, + create_pytorch_jit_script_module_convert_pytorch_frontend, + create_pytorch_jit_trace_module_convert_pytorch_frontend, + create_pytorch_module_convert_pytorch_frontend_oob, + create_pytorch_module_with_optional_inputs_case1, + create_pytorch_module_with_optional_inputs_case2, + create_pytorch_module_with_optional_inputs_case3, + create_pytorch_nn_module_with_scalar_input, + create_pytorch_module_with_compressed_int8_constant, + create_pytorch_module_with_compressed_int8_constant_compress_to_fp16_default, + create_pytorch_module_with_nested_inputs, + create_pytorch_module_with_nested_inputs2, + create_pytorch_module_with_nested_inputs3, + create_pytorch_module_with_nested_inputs4, + create_pytorch_module_with_nested_inputs5, + create_pytorch_module_with_nested_inputs6 + ] + + @pytest.mark.parametrize("create_model", test_data) + @pytest.mark.nightly + @pytest.mark.precommit + def test_mo_import_from_memory(self, create_model, ie_device, precision, ir_version, + temp_dir, use_new_frontend, use_old_api): + fw_model, graph_ref, mo_params = create_model(temp_dir) + + test_params = {'input_model': fw_model} + if mo_params is not None: + test_params.update(mo_params) + self._test_by_ref_graph(temp_dir, test_params, + graph_ref, compare_tensor_names=False) + + +def create_pt_model_with_custom_op(): + # + # Create PyTorch model with custom operation + # + import torch.nn as nn + + class MyModel(nn.Module): + def __init__(self): + super(MyModel, self).__init__() + self.my_op = MyTorchOp() + + def forward(self, x): + return self.my_op.apply(x) + + return MyModel() + + +class ConvertRaises(unittest.TestCase): + def test_example_inputs(self): + from openvino.tools.ovc import convert_model + pytorch_model = create_pt_model_with_custom_op() + + # Check that mo raises error message of wrong argument. + with self.assertRaisesRegex(TypeError, ".*got an unexpected keyword argument 'example_inputs'.*"): + convert_model(pytorch_model, example_inputs=(torch.tensor(1),)) + + def test_failed_extension(self): + from openvino.tools.ovc import convert_model + from openvino.frontend.pytorch import ConversionExtension + + inp_shapes = [1, 3, 20, 20] + pt_model = make_pt_model_one_input() + + def relu_bad(n): + assert False, "Something happened" + + # Check that mo raises error message of wrong argument. + with self.assertRaisesRegex(Exception, ".*Conversion is failed for: aten::relu.*"): + convert_model(pt_model, input=(inp_shapes, np.float32), extensions=[ + ConversionExtension("aten::relu", relu_bad)]) + + def test_failed_extension(self): + import tempfile + from openvino.tools.ovc import convert_model + + with self.assertRaisesRegex(Exception, ".*Cannot recognize input model.*"): + with tempfile.NamedTemporaryFile() as tmpfile: + convert_model(tmpfile.name) diff --git a/tests/layer_tests/ovc_python_api_tests/test_tf.py b/tests/layer_tests/ovc_python_api_tests/test_tf.py new file mode 100644 index 00000000000000..d2cd65602e67c6 --- /dev/null +++ b/tests/layer_tests/ovc_python_api_tests/test_tf.py @@ -0,0 +1,859 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import unittest + +import numpy as np +import openvino.runtime as ov +import pytest +from openvino.runtime import PartialShape, Model, Dimension + +from common.mo_convert_test_class import CommonMOConvertTest +from common.layer_test_class import CommonLayerTest + + +def create_tf_graph_def(tmp_dir): + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + inp1 = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], 'Input') + inp2 = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], 'Input') + relu = tf.nn.relu(inp1 + inp2, name='Relu') + + output = tf.nn.sigmoid(relu, name='Sigmoid') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return tf_net, model_ref, None + + +def create_keras_model(temp_dir): + import tensorflow as tf + + tf.keras.backend.clear_session() + tf.compat.v1.reset_default_graph() + + input_names = ["Input1", "Input2"] + input_shape = [1, 2, 3] + + x1 = tf.keras.Input(shape=input_shape, name=input_names[0]) + x2 = tf.keras.Input(shape=input_shape, name=input_names[1]) + y = tf.nn.sigmoid(tf.nn.relu(x1 + x2)) + keras_net = tf.keras.Model(inputs=[x1, x2], outputs=[y]) + + shape = PartialShape([-1, 1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + tf.keras.backend.clear_session() + + return keras_net, model_ref, None + + +def create_tf1_wrap_function(tmp_dir): + import tensorflow as tf + + def f(x, y): + return tf.nn.sigmoid(tf.nn.relu(x + y)) + + func = tf.compat.v1.wrap_function(f, [tf.TensorSpec((1, 2, 3), tf.float32), + tf.TensorSpec((1, 2, 3), tf.float32)]) + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return func, model_ref, None + + +def create_tf_session(tmp_dir): + import tensorflow as tf + from tensorflow.python.eager.context import graph_mode + + with graph_mode(): + tf.compat.v1.reset_default_graph() + sess = tf.compat.v1.Session() + inp1 = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], 'Input1') + inp2 = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], 'Input2') + relu = tf.nn.relu(inp1 + inp2, name='Relu') + + output = tf.nn.sigmoid(relu, name='Sigmoid') + + tf.compat.v1.global_variables_initializer() + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return sess, model_ref, None + + +def create_tf_module(tmp_dir): + import tensorflow as tf + + class Net(tf.Module): + def __init__(self, name=None): + super(Net, self).__init__(name=name) + + def __call__(self, x, y): + return tf.nn.sigmoid(tf.nn.relu(x + y)) + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + net = Net() + return net, model_ref, {'input': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])]} + + +def create_tf_module_dynamic(tmp_dir): + import tensorflow as tf + + class Net(tf.Module): + def __init__(self, name=None): + super(Net, self).__init__(name=name) + + def __call__(self, x, y): + return tf.nn.sigmoid(tf.nn.relu(x + y)) + + input_shapes = [PartialShape([-1, Dimension(3, -1), Dimension(4)]), + PartialShape([-1, Dimension(3), Dimension(4, -1)])] + + param1 = ov.opset8.parameter(input_shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(input_shapes[1], dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + net = Net() + return net, model_ref, {'input': input_shapes} + + +def create_keras_layer(tmp_dir): + import tensorflow as tf + class LayerModel(tf.keras.layers.Layer): + + def __init__(self): + super(LayerModel, self).__init__() + + def call(self, x, y): + return tf.sigmoid(tf.nn.relu(x + y)) + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + net = LayerModel() + return net, model_ref, {'input': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])]} + + +def create_keras_layer_dynamic(tmp_dir): + import tensorflow as tf + class LayerModel(tf.keras.layers.Layer): + + def __init__(self): + super(LayerModel, self).__init__() + + def call(self, x, y): + return tf.sigmoid(tf.nn.relu(x + y)) + + input_shapes = [PartialShape([-1, Dimension(3, -1), Dimension(4)]), + PartialShape([-1, Dimension(3), Dimension(4, -1)])] + + param1 = ov.opset8.parameter(input_shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(input_shapes[1], dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + net = LayerModel() + return net, model_ref, {'input': input_shapes} + + +def create_tf_checkpoint(tmp_dir): + import tensorflow as tf + + input_names = ["Input1", "Input2"] + input_shape = [1, 2, 3] + + x1 = tf.keras.Input(shape=input_shape, name=input_names[0]) + x2 = tf.keras.Input(shape=input_shape, name=input_names[1]) + y = tf.nn.sigmoid(tf.nn.relu(x1 + x2)) + + model = tf.keras.Model(inputs=[x1, x2], outputs=[y]) + checkpoint = tf.train.Checkpoint(model) + + shape = PartialShape([-1, 1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return checkpoint, model_ref, None + + +def create_tf_function(temp_dir): + import tensorflow as tf + + @tf.function( + input_signature=[tf.TensorSpec(shape=[1, 2, 3], dtype=tf.float32), + tf.TensorSpec(shape=[1, 2, 3], dtype=tf.float32)]) + def f(x1, x2): + y = tf.nn.sigmoid(tf.nn.relu(x1 + x2)) + return y + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return f, model_ref, None + + +def create_tf_graph(temp_dir): + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + inp1 = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], 'Input') + inp2 = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], 'Input') + relu = tf.nn.relu(inp1 + inp2, name='Relu') + + output = tf.nn.sigmoid(relu, name='Sigmoid') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph + + shape = PartialShape([1, 2, 3]) + param1 = ov.opset8.parameter(shape, dtype=np.float32) + param2 = ov.opset8.parameter(shape, dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return tf_net, model_ref, None + + +def create_tf_saved_model_dir(temp_dir): + import tensorflow as tf + + input_names = ["Input1", "Input2"] + input_shape = [1, 2, 3] + + x1 = tf.keras.Input(shape=input_shape, name=input_names[0]) + x2 = tf.keras.Input(shape=input_shape, name=input_names[1]) + y = tf.nn.sigmoid(tf.nn.relu(x1 + x2)) + keras_net = tf.keras.Model(inputs=[x1, x2], outputs=[y]) + + tf.saved_model.save(keras_net, temp_dir + "/model") + + shape = PartialShape([-1, 1, 2, 3]) + param1 = ov.opset8.parameter(shape, name="Input1:0", dtype=np.float32) + param2 = ov.opset8.parameter(shape, name="Input2:0", dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu = ov.opset8.relu(add) + sigm = ov.opset8.sigmoid(relu) + + parameter_list = [param1, param2] + model_ref = Model([sigm], parameter_list, "test") + + return temp_dir + "/model", model_ref + + +def create_tf_stateful_partioned_call_net(temp_dir): + import tensorflow as tf + tf.compat.v1.reset_default_graph() + + data_shape = [1, 1, 10, 10] + filters_shape = [3, 3, 1, 1] + + strides = [1, 1] + pads_begin = [0, 0] + pads_end = [0, 0] + dilations = [1, 1] + + @tf.function + def second_func(input, filter): + conv = tf.raw_ops.Conv2D(input=input, filter=filter, strides=[1, 1, 1, 1], padding='SAME', data_format='NCHW') + return conv + + @tf.function( + input_signature=[tf.TensorSpec(shape=data_shape, dtype=tf.float32), + tf.TensorSpec(shape=filters_shape, dtype=tf.float32)]) + def first_func(input, filter): + conv = second_func(input, filter) + return conv + + tf_model = first_func + + param1 = ov.opset8.parameter(data_shape, dtype=np.float32) + param2 = ov.opset8.parameter(filters_shape, dtype=np.float32) + reshape = ov.opset8.reshape(param2, np.array([1, 1, 3, 3], dtype=np.int64), True) + conv = ov.opset11.convolution(param1, reshape, strides, pads_begin, pads_end, dilations, auto_pad="same_upper") + + parameter_list = [param1, param2] + model_ref = Model([conv], parameter_list, "test") + + return tf_model, model_ref, {} + + +def create_keras_layer_input_list(): + import tensorflow as tf + class LayerModel(tf.keras.layers.Layer): + + def __init__(self): + super(LayerModel, self).__init__() + + def call(self, x, y): + res_list = [tf.sigmoid(tf.nn.relu(x + y)), tf.nn.relu(x), tf.sigmoid(y)] + return res_list + + input_shapes = [PartialShape([1, 2, 3]), + PartialShape([1, 2, 3])] + + param1 = ov.opset8.parameter(input_shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(input_shapes[1], dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu1 = ov.opset8.relu(add) + sigm1 = ov.opset8.sigmoid(relu1) + relu2 = ov.opset8.relu(param1) + sigm2 = ov.opset8.sigmoid(param2) + + parameter_list = [param1, param2] + model_ref = Model([sigm1, relu2, sigm2], parameter_list, "test") + return LayerModel(), model_ref + + +def create_keras_layer_input_list_one_inp(): + import tensorflow as tf + class LayerModel(tf.keras.layers.Layer): + + def __init__(self): + super(LayerModel, self).__init__() + + def call(self, x): + res_list = [tf.sigmoid(tf.nn.relu(x)), tf.nn.relu(x)] + return res_list + + input_shapes = [PartialShape([1,2,3])] + + param1 = ov.opset8.parameter(input_shapes[0], dtype=np.float32) + relu1 = ov.opset8.relu(param1) + sigm1 = ov.opset8.sigmoid(relu1) + parameter_list = [param1] + model_ref = Model([sigm1, relu1], parameter_list, "test") + + return LayerModel(), model_ref + + +def create_keras_layer_input_dict(): + import tensorflow as tf + class LayerModel(tf.keras.layers.Layer): + + def __init__(self): + super(LayerModel, self).__init__() + + def call(self, args): + res = {} + res['result'] = tf.sigmoid(tf.nn.relu(args['a'] + args['b'])) + return res + + input_shapes = [PartialShape([1, 2, 3]), + PartialShape([1, 2, 3])] + + param1 = ov.opset8.parameter(input_shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(input_shapes[1], dtype=np.float32) + add = ov.opset8.add(param1, param2) + relu1 = ov.opset8.relu(add) + sigm1 = ov.opset8.sigmoid(relu1) + + parameter_list = [param1, param2] + model_ref = Model([sigm1], parameter_list, "test") + return LayerModel(), model_ref + + +def create_keras_layer_input_dict_one_inp(): + import tensorflow as tf + class LayerModel(tf.keras.layers.Layer): + + def __init__(self): + super(LayerModel, self).__init__() + + def call(self, args): + res = {} + res['result'] = tf.sigmoid(tf.nn.relu(args['args'])) + return res + + input_shapes = [PartialShape([1, 2, 3]), + PartialShape([1, 2, 3])] + + param1 = ov.opset8.parameter(input_shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(input_shapes[1], dtype=np.float32) + relu1 = ov.opset8.relu(param1) + sigm1 = ov.opset8.sigmoid(relu1) + parameter_list = [param1, param2] + model_ref = Model([sigm1], parameter_list, "test") + return LayerModel(), model_ref + + +def single_param_function_reference(shape, const_value): + param1 = ov.opset8.parameter(shape, dtype=np.float32) + const = ov.opset8.constant(const_value, dtype=np.float32) + sigm = ov.opset8.sigmoid(param1) + mul = ov.opset8.multiply(sigm, const) + parameter_list = [param1] + return Model([mul], parameter_list, "test") + + +def two_params_function_reference(shapes, const_value): + param1 = ov.opset8.parameter(shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(shapes[1], dtype=np.float32) + const = ov.opset8.constant(const_value, dtype=np.float32) + sigm = ov.opset8.sigmoid(param1) + add = ov.opset8.add(sigm, param2) + mul = ov.opset8.multiply(add, const) + parameter_list = [param1, param2] + return Model([mul], parameter_list, "test") + + +def two_params_function_reference_fp16_compressed(shapes, const_value): + param1 = ov.opset8.parameter(shapes[0], dtype=np.float32) + param2 = ov.opset8.parameter(shapes[1], dtype=np.float32) + const_value = ov.opset8.constant(const_value, dtype=np.float16) + const_decompress = ov.opset8.convert(const_value, np.float32) + sigm = ov.opset8.sigmoid(param1) + add = ov.opset8.add(sigm, param2) + mul = ov.opset8.multiply(add, const_decompress) + parameter_list = [param1, param2] + return Model([mul], parameter_list, "test") + + +def create_keras_layer_with_example_input_1(tmp_dir): + model, model_ref = create_keras_layer_input_list() + example_input = (np.random.rand(1,2,3).astype(np.float32), np.random.rand(1,2,3).astype(np.float32)) + return model, model_ref, {'example_input': example_input} + + +def create_keras_layer_with_example_input_2(tmp_dir): + model, model_ref = create_keras_layer_input_dict() + example_input = {'a': np.random.rand(1,2,3).astype(np.float32), 'b': np.random.rand(1,2,3).astype(np.float32)} + return model, model_ref, {'example_input': example_input} + + +def create_keras_layer_with_input_shapes_case1(tmp_dir): + model, model_ref = create_keras_layer_input_list() + return model, model_ref, {'input': [[1, 2, 3], [1, 2, 3]]} + + +def create_keras_layer_with_input_shapes_case2(tmp_dir): + model, model_ref = create_keras_layer_input_list() + return model, model_ref, {'input': [([1, 2, 3], np.float32), ([1, 2, 3], np.float32)]} + + +def create_keras_layer_with_input_shapes_case3(tmp_dir): + model, model_ref = create_keras_layer_input_dict_one_inp() + return model, model_ref, {'input': [('args', [1, 2, 3])]} + + +def create_keras_layer_with_input_shapes_case4(tmp_dir): + model, model_ref = create_keras_layer_input_list_one_inp() + return model, model_ref, {'input': [1, 2, 3]} + + +def create_keras_layer_with_tf_function_call(tmp_dir): + import tensorflow as tf + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable(5.0) + + @tf.function(input_signature=[tf.TensorSpec([1, 2], tf.float32), tf.TensorSpec([1, 2], tf.float32)]) + def __call__(self, input1, input2): + sigm = tf.nn.sigmoid(input1) + input2 + return sigm * self.var1 + model = LayerModel() + model_ref = two_params_function_reference([[1, 2], [1, 2]], [[5.0]]) + return model, model_ref, {'compress_to_fp16': False} + + +def create_keras_layer_with_tf_function_call_default_compressed_to_fp16(tmp_dir): + import tensorflow as tf + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable(5.0) + + @tf.function(input_signature=[tf.TensorSpec([1, 2], tf.float32), tf.TensorSpec([1, 2], tf.float32)]) + def __call__(self, input1, input2): + sigm = tf.nn.sigmoid(input1) + input2 + return sigm * self.var1 + model = LayerModel() + model_ref = two_params_function_reference_fp16_compressed([[1, 2], [1, 2]], [[5.0]]) + return model, model_ref, {} + + +def create_keras_layer_with_tf_function_call_no_signature(tmp_dir): + import tensorflow as tf + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable(5.0) + + @tf.function() + def __call__(self, input1, input2): + sigm = tf.nn.sigmoid(input1) + input2 + return sigm * self.var1 + model = LayerModel() + example_input = [np.random.rand(2, 3).astype(np.float32), np.random.rand(2, 3).astype(np.float32)] + + model_ref = two_params_function_reference([[2, 3], [2, 3]], [[5.0]]) + return model, model_ref, {'example_input': example_input, 'compress_to_fp16': False} + + +def create_keras_layer_with_tf_function_call_no_signature_single_input(tmp_dir): + import tensorflow as tf + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable(5.0) + + @tf.function() + def __call__(self, input1): + sigm = tf.nn.sigmoid(input1) + return sigm * self.var1 + model = LayerModel() + example_input = np.random.rand(2, 3).astype(np.float32) + + model_ref = single_param_function_reference([2, 3], [[5.0]]) + return model, model_ref, {'example_input': example_input, 'compress_to_fp16': False} + + +def create_keras_layer_with_string_tensor(tmp_dir): + import tensorflow as tf + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var = tf.Variable("Text_1", dtype=tf.string) + self.const = tf.constant("Text_2", dtype=tf.string) + + @tf.function(input_signature=[tf.TensorSpec([1], tf.float32), tf.TensorSpec([1], tf.float32)]) + def __call__(self, input1, input2): + return input1 + input2, self.var, self.const + + model = LayerModel() + + param1 = ov.opset8.parameter([1], dtype=np.float32) + param2 = ov.opset8.parameter([1], dtype=np.float32) + add = ov.opset8.add(param1, param2) + parameter_list = [param1, param2] + model_ref = Model([add], parameter_list, "test") + + return model, model_ref, {} + + +class TestMoConvertTF(CommonMOConvertTest): + test_data = [ + # TF2 + create_keras_model, + create_keras_layer, + create_tf_function, + create_tf_module, + create_tf_checkpoint, + create_keras_layer_dynamic, + create_tf_module_dynamic, + create_tf_stateful_partioned_call_net, + create_keras_layer_with_example_input_1, + create_keras_layer_with_example_input_2, + create_keras_layer_with_input_shapes_case1, + create_keras_layer_with_input_shapes_case2, + create_keras_layer_with_input_shapes_case3, + create_keras_layer_with_input_shapes_case4, + create_keras_layer_with_tf_function_call, + create_keras_layer_with_tf_function_call_default_compressed_to_fp16, + create_keras_layer_with_tf_function_call_no_signature, + create_keras_layer_with_tf_function_call_no_signature_single_input, + create_keras_layer_with_string_tensor, + + # TF1 + create_tf_graph, + create_tf_graph_def, + create_tf1_wrap_function, + create_tf_session, + ] + + @pytest.mark.parametrize("create_model", test_data) + @pytest.mark.nightly + @pytest.mark.precommit_tf_fe + @pytest.mark.precommit + def test_mo_import_from_memory_tf_fe(self, create_model, ie_device, precision, ir_version, + temp_dir): + fw_model, graph_ref, mo_params = create_model(temp_dir) + + test_params = {'input_model': fw_model} + if mo_params is not None: + test_params.update(mo_params) + self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) + + @pytest.mark.nightly + @pytest.mark.precommit + def test_unnamed_saved_model_dir(self, ie_device, precision, ir_version, temp_dir): + saved_model_dir, graph_ref = create_tf_saved_model_dir(temp_dir) + + test_params = {'input_model': saved_model_dir} + self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) + + test_params = {'input_model': saved_model_dir} + self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False) + + def test_zero_copy(self, ie_device, precision, ir_version, temp_dir): + import tensorflow as tf + from openvino.tools.ovc import convert_model + from openvino.runtime import compile_model + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable([7., 5., 6.], name='var1') + self.var2 = tf.Variable([5., 7., 3.], name='var2') + + + @tf.function + def sub_function(self, input): + return input * self.var1 + self.var2 + + @tf.function() + def __call__(self, input): + return self.sub_function(input) + + # Create TF model with variables + keras_model = LayerModel() + test_input = np.array(7.).astype(np.float32) + + # Convert model to OV + ov_model = convert_model(keras_model, input=[1], share_weights=True) + cmp_model = compile_model(ov_model) + + # Check model inference + ov_infer1 = cmp_model(test_input, ie_device) + fw_infer1 = keras_model(test_input).numpy() + + assert np.array_equal(ov_infer1['Identity:0'], fw_infer1) + assert np.array_equal(ov_infer1['Identity:0'], [54., 42., 45.]) + + # Change value of variables in original model + for val in keras_model.variables: + arr = val.value().__array__() + arr[0] = 0 + arr[1] = 1 + arr[2] = 2 + + # Check model inference + cmp_model = compile_model(ov_model) + ov_infer2 = cmp_model(test_input) + fw_infer2 = keras_model(test_input).numpy() + + assert np.array_equal(ov_infer2['Identity:0'], fw_infer2) + assert np.array_equal(ov_infer2['Identity:0'], [ 0., 8., 16.]) + + def test_turn_off_sharing(self, ie_device, precision, ir_version, temp_dir): + import tensorflow as tf + from openvino.tools.ovc import convert_model + from openvino.runtime import compile_model + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable([7., 5., 6.], name='var1') + self.var2 = tf.Variable([5., 7., 3.], name='var2') + + + @tf.function + def sub_function(self, input): + return input * self.var1 + self.var2 + + @tf.function() + def __call__(self, input): + return self.sub_function(input) + + # Create TF model with variables + keras_model = LayerModel() + test_input = np.array(7.).astype(np.float32) + + # Convert model to OV + ov_model = convert_model(keras_model, input=[1], share_weights=False) + cmp_model = compile_model(ov_model) + + # Check model inference + ov_infer1 = cmp_model(test_input, ie_device) + fw_infer1 = keras_model(test_input).numpy() + + assert np.array_equal(ov_infer1['Identity:0'], fw_infer1) + assert np.array_equal(ov_infer1['Identity:0'], [54., 42., 45.]) + + # Change value of variables in original model + for val in keras_model.variables: + arr = val.value().__array__() + arr[0] = 0 + arr[1] = 1 + arr[2] = 2 + + # Check model inference + ov_infer2 = cmp_model(test_input) + fw_infer2 = keras_model(test_input).numpy() + + # Check model inference calculated with old constant values + assert not np.array_equal(ov_infer2['Identity:0'], fw_infer2) + assert np.array_equal(ov_infer2['Identity:0'], [54., 42., 45.]) + + def test_memory_loss(self, ie_device, precision, ir_version, temp_dir): + # This test checks that the memory allocated for constants + # is not lost after returning the model from convert_model() method. + import tensorflow as tf + tf.compat.v1.reset_default_graph() + + from openvino.tools.ovc import convert_model + from openvino.runtime import compile_model + import gc + + with tf.compat.v1.Session() as sess: + inp1 = tf.compat.v1.placeholder(tf.float32, [3], 'Input') + const = tf.constant([0.5, 2.3, 7.8], dtype=tf.float32) + res = inp1 + const + + tf.compat.v1.global_variables_initializer() + tf_graph = sess.graph # tf.Graph + + if precision == 'FP32': + eps = 1e-4 + else: + eps = 5e-2 + + + test_input = np.array([2.1, 7.3, 4.6]).astype(np.float32) + + # Convert model to OV + ov_model = convert_model(tf_graph) + cmp_model = compile_model(ov_model) + + # Check model inference + ov_infer1 = cmp_model(test_input, ie_device) + + feed_dict = {"Input:0": test_input} + with tf.compat.v1.Session(graph=tf_graph) as sess: + fw_infer1 = sess.run('add:0', feed_dict=feed_dict) + + assert CommonLayerTest().compare_ie_results_with_framework(ov_infer1, {"add:0": fw_infer1}, eps) + assert CommonLayerTest().compare_ie_results_with_framework(ov_infer1, {"add:0": [2.6, 9.6, 12.4]}, eps) + + # run Garbage collector to ensure, that values from tf.constant are copied to ov.Const and + # we do not lose allocated memory. + gc.collect() + + # Check model inference + cmp_model = compile_model(ov_model) + ov_infer2 = cmp_model(test_input, ie_device) + + feed_dict = {"Input:0": test_input} + with tf.compat.v1.Session(graph=tf_graph) as sess: + fw_infer2 = sess.run('add:0', feed_dict=feed_dict) + + assert CommonLayerTest().compare_ie_results_with_framework(ov_infer2, {"add:0": fw_infer2}, eps) + assert CommonLayerTest().compare_ie_results_with_framework(ov_infer1, {"add:0": [2.6, 9.6, 12.4]}, eps) + + +class TFConvertTest(unittest.TestCase): + @pytest.mark.nightly + @pytest.mark.precommit + def test_tf_function_no_signature(self): + import tensorflow as tf + from openvino.tools.ovc import convert_model + + @tf.function() + def function(x1, x2): + y = tf.nn.sigmoid(tf.nn.relu(x1 + x2)) + return y + + with self.assertRaisesRegex(Exception, ".*Please provide 'example_input'.*"): + convert_model(function) + + +class TestTFLoadByModel(unittest.TestCase): + def test_load_by_model_tf_graph_iterator(self): + def simple_tf_model(): + import tensorflow as tf + + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + inp = tf.compat.v1.placeholder(tf.float32, [1, 2, 3], "Input") + _ = tf.nn.sigmoid(inp, name="Sigmoid") + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph + return tf_net + from openvino.frontend.tensorflow.graph_iterator import GraphIteratorTFGraph + from openvino.frontend import FrontEndManager + model = GraphIteratorTFGraph(simple_tf_model(), True) + fem = FrontEndManager() + fe = fem.load_by_model(model) + assert fe is not None + assert fe.get_name() == "tf" diff --git a/tools/benchmark_tool/openvino/__init__.py b/tools/benchmark_tool/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/tools/benchmark_tool/openvino/__init__.py +++ b/tools/benchmark_tool/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass diff --git a/tools/mo/openvino/__init__.py b/tools/mo/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/tools/mo/openvino/__init__.py +++ b/tools/mo/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass diff --git a/tools/openvino_dev/src/openvino/__init__.py b/tools/openvino_dev/src/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/tools/openvino_dev/src/openvino/__init__.py +++ b/tools/openvino_dev/src/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass diff --git a/tools/ovc/openvino/__init__.py b/tools/ovc/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/tools/ovc/openvino/__init__.py +++ b/tools/ovc/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass diff --git a/tools/ovc/openvino/tools/ovc/__init__.py b/tools/ovc/openvino/tools/ovc/__init__.py index c55c861e448318..7d462d71b205b9 100644 --- a/tools/ovc/openvino/tools/ovc/__init__.py +++ b/tools/ovc/openvino/tools/ovc/__init__.py @@ -1,4 +1,4 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.tools.ovc.convert import convert_model, InputCutInfo \ No newline at end of file +from openvino.tools.ovc.convert import convert_model \ No newline at end of file diff --git a/tools/ovc/openvino/tools/ovc/cli_parser.py b/tools/ovc/openvino/tools/ovc/cli_parser.py index e8dcb63fa0e184..e4f2b99cccb021 100644 --- a/tools/ovc/openvino/tools/ovc/cli_parser.py +++ b/tools/ovc/openvino/tools/ovc/cli_parser.py @@ -3,27 +3,27 @@ import argparse import ast +import inspect import logging as log import os import pathlib import re from collections import OrderedDict, namedtuple from distutils.util import strtobool -from itertools import zip_longest -from pathlib import Path from operator import xor from typing import List, Union -import numbers -import inspect import numpy as np -from openvino.runtime import Layout, PartialShape, Dimension, Shape, Type # pylint: disable=no-name-in-module,import-error +from openvino.runtime import PartialShape, Dimension, Shape, Type # pylint: disable=no-name-in-module,import-error import openvino from openvino.tools.ovc.convert_data_type import destination_type_to_np_data_type from openvino.tools.ovc.error import Error -from openvino.tools.ovc.utils import get_mo_root_dir from openvino.tools.ovc.help import get_convert_model_help_specifics +from openvino.tools.ovc.utils import get_mo_root_dir + +# Helper class for storing input cut information +_InputCutInfo = namedtuple("InputCutInfo", ["name", "shape", "type", "value"], defaults=[None, None, None, None]) def is_shape_type(value): if isinstance(value, PartialShape): @@ -45,20 +45,12 @@ def single_input_to_input_cut_info(input: [str, tuple, list, PartialShape, Type, """ if isinstance(input, str): # Parse params from string - node_name, shape, value, data_type = parse_input_value(input) - # pylint: disable=no-member - return openvino.tools.ovc.InputCutInfo(node_name, - PartialShape(shape) if shape is not None else None, - data_type, - value) - if isinstance(input, openvino.tools.ovc.InputCutInfo): # pylint: disable=no-member - # Wrap input.shape to PartialShape if possible and wrap to InputCutInfo + node_name, shape, data_type = parse_input_value(input) # pylint: disable=no-member - return openvino.tools.ovc.InputCutInfo(input.name, - PartialShape(input.shape) if input.shape is not None else None, - input.type, - input.value) - if isinstance(input, (tuple, list, PartialShape)): + return _InputCutInfo(node_name, + PartialShape(shape) if shape is not None else None, + data_type) + if isinstance(input, (tuple, list)) or is_shape_type(input): # If input represents list with shape, wrap it to list. Single PartialShape also goes to this condition. # Check of all dimensions will be in is_shape_type(val) method below if len(input) > 0 and isinstance(input[0], (int, Dimension)): @@ -85,19 +77,18 @@ def single_input_to_input_cut_info(input: [str, tuple, list, PartialShape, Type, raise Exception("Incorrect input parameters provided. Expected tuple with input name, " "input type or input shape. Got unknown object: {}".format(val)) # pylint: disable=no-member - return openvino.tools.ovc.InputCutInfo(name, - PartialShape(shape) if shape is not None else None, - inp_type, - None) + return _InputCutInfo(name, + PartialShape(shape) if shape is not None else None, + inp_type, + None) # Case when only type is set if isinstance(input, (type, Type)): - return openvino.tools.ovc.InputCutInfo(None, None, input, None) # pylint: disable=no-member + return _InputCutInfo(None, None, input, None) # pylint: disable=no-member # We don't expect here single unnamed value. If list of int is set it is considered as shape. # Setting of value is expected only using InputCutInfo or string analog. - raise Exception("Unexpected object provided for input. Expected openvino.tools.ovc.InputCutInfo " - "or tuple or str. Got {}".format(type(input))) + raise Exception("Unexpected object provided for input. Expected tuple, Shape, PartialShape, Type or str. Got {}".format(type(input))) def input_to_input_cut_info(input: [str, tuple, list]): @@ -114,17 +105,12 @@ def input_to_input_cut_info(input: [str, tuple, list]): for input_value in split_inputs(input): # Parse string with parameters for single input - node_name, shape, value, data_type = parse_input_value(input_value) + node_name, shape, data_type = parse_input_value(input_value) # pylint: disable=no-member - inputs.append(openvino.tools.ovc.InputCutInfo(node_name, - PartialShape(shape) if shape is not None else None, - data_type, - value)) + inputs.append(_InputCutInfo(node_name, + PartialShape(shape) if shape is not None else None, + data_type)) return inputs - # pylint: disable=no-member - if isinstance(input, openvino.tools.ovc.InputCutInfo): - # Wrap to list and return - return [input] if isinstance(input, tuple): # Case when input is single shape set in tuple if len(input) > 0 and isinstance(input[0], (int, Dimension)): @@ -140,6 +126,17 @@ def input_to_input_cut_info(input: [str, tuple, list]): for inp in input: inputs.append(single_input_to_input_cut_info(inp)) return inputs + if isinstance(input, dict): + res_list = [] + for name, value in input.items(): + if not isinstance(name, str): + raise Exception("Incorrect operation name type. Expected string, got {}".format(type(name))) + info = single_input_to_input_cut_info(value) + if info.name is not None and info.name != name: + raise Exception("Incorrect \"input\" dictionary, got different names in key and value. " + "Got operation name {} for key {}".format(info.name, name)) + res_list.append(_InputCutInfo(name, info.shape, info.type)) + return res_list # Case when single type or value is set, or unknown object return [single_input_to_input_cut_info(input)] @@ -443,7 +440,7 @@ def _format_usage(self, usage, actions, groups, prefix): usage = argparse.HelpFormatter._format_usage(self, usage, actions, groups, prefix) usage = usage[0:usage.find('INPUT_MODEL')].rstrip() + '\n' insert_idx = usage.find(self._prog) + len(self._prog) - usage = usage[0: insert_idx] + ' INPUT_MODEL ' + usage[insert_idx + 1:] + usage = usage[0: insert_idx] + ' INPUT_MODEL... ' + usage[insert_idx + 1:] return usage def _get_default_metavar_for_optional(self, action): @@ -473,12 +470,20 @@ def get_common_cli_parser(parser: argparse.ArgumentParser = None): add_args_by_description(parser, mo_convert_params_common) return parser +def input_model_details(model): + if isinstance(model, (list, tuple)) and len(model) == 1: + model = model[0] + if isinstance(model, (str, pathlib.Path)): + return model + return type(model) + -def get_common_cli_options(model_name): +def get_common_cli_options(argv, is_python_api_used): d = OrderedDict() - d['input_model'] = '- Path to the Input Model' - d['output_dir'] = ['- Path for generated IR', lambda x: x if x != '.' else os.getcwd()] # TODO: Consider removing - d['output_model'] = ['- IR output name', lambda x: x if x else model_name] + d['input_model'] = ['- Path to the Input Model', input_model_details] + if not is_python_api_used: + model_name = get_model_name_from_args(argv) + d['output_model'] = ['- IR output name', lambda _: model_name] d['log_level'] = '- Log level' d['input'] = ['- Input layers', lambda x: x if x else 'Not specified, inherited from the model'] d['output'] = ['- Output layers', lambda x: x if x else 'Not specified, inherited from the model'] @@ -530,7 +535,8 @@ def remove_shape_from_input_value(input_value: str): :param input_value: string passed as input to the "input" command line parameter :return: string without shape specification """ - assert '->' not in input_value, 'The function should not be called for input_value with constant value specified' + if '->' in input_value: + raise Error('Incorrect format of input. Got {}'.format(input_value)) return re.sub(r'[(\[]([0-9\.?, -]*)[)\]]', '', input_value) @@ -540,8 +546,6 @@ def get_shape_from_input_value(input_value: str): :param input_value: string passed as input to the "input" command line parameter :return: the corresponding shape and None if the shape is not specified in the input value """ - # remove the tensor value from the input_value first - input_value = input_value.split('->')[0] # parse shape shape = re.findall(r'[(\[]([0-9\.\?, -]*)[)\]]', input_value) @@ -556,7 +560,7 @@ def get_shape_from_input_value(input_value: str): shape = PartialShape([Dimension(dim) for dim in dims]) else: raise Error("Wrong syntax to specify shape. Use \"input\" " - "\"node_name[shape]->value\"") + "\"node_name[shape]\"") return shape @@ -566,33 +570,7 @@ def get_node_name_with_port_from_input_value(input_value: str): :param input_value: string passed as input to the "input" command line parameter :return: the corresponding node name with input/output port """ - return remove_shape_from_input_value(remove_data_type_from_input_value(input_value.split('->')[0])) - - -def get_value_from_input_value(input_value: str): - """ - Returns the value from the input value string - :param input_value: string passed as input to the "input" command line parameter - :return: the corresponding value or None if it is not specified - """ - parts = input_value.split('->') - value = None - if len(parts) == 2: - value = parts[1] - if value[0] == '[' and value[-1] != ']' or value[0] != '[' and value[-1] == ']': - raise Error("Wrong syntax to specify value. Use \"input\"=\"node_name[shape]->value\"") - if '[' in value.strip(' '): - value = value.replace('[', '').replace(']', '') - if ',' in value: - value = value.replace(' ', '') - value = value.split(',') - else: - value = value.split(' ') - if not isinstance(value, list): - value = ast.literal_eval(value) - elif len(parts) > 2: - raise Error("Wrong syntax to specify value. Use \"input\"=\"node_name[shape]->value\"") - return value + return remove_shape_from_input_value(remove_data_type_from_input_value(input_value)) def partial_shape_prod(shape: [PartialShape, tuple]): @@ -614,7 +592,7 @@ def parse_input_value(input_value: str): ---------- input_value string with a specified node name, shape, value and data_type. - E.g. 'node_name:0[4]{fp32}->[1.0 2.0 3.0 4.0]' + E.g. 'node_name:0[4]{fp32}' Returns ------- @@ -623,19 +601,9 @@ def parse_input_value(input_value: str): """ data_type = get_data_type_from_input_value(input_value) node_name = get_node_name_with_port_from_input_value(input_value) - value = get_value_from_input_value(input_value) shape = get_shape_from_input_value(input_value) - value_size = np.prod(len(value)) if isinstance(value, list) else 1 - - if value is not None and shape is not None: - for dim in shape: - if isinstance(dim, Dimension) and dim.is_dynamic: - raise Error("Cannot freeze input with dynamic shape: {}".format(shape)) - if shape is not None and value is not None and partial_shape_prod(shape) != value_size: - raise Error("The shape '{}' of the input node '{}' does not correspond to the number of elements '{}' in the " - "value: {}".format(shape, node_name, value_size, value)) - return node_name if node_name else None, shape, value, data_type + return node_name if node_name else None, shape, data_type def split_str_avoiding_square_brackets(s: str) -> list: @@ -818,65 +786,6 @@ def get_layout_values(argv_layout: str = '', argv_source_layout: str = '', argv_ return res_list -#TODO: Should be removed? -def parse_freeze_placeholder_values(argv_freeze_placeholder_with_value: str): - """ - Parses parse_freeze_placeholder_values string. - :param argv_freeze_placeholder_with_value: string information on freezing placeholders - :return: dictionary where key is node name, value is node value. - """ - placeholder_values = {} - if argv_freeze_placeholder_with_value is not None: - for plh_with_value in argv_freeze_placeholder_with_value.split(','): - plh_with_value = plh_with_value.split('->') - if len(plh_with_value) != 2: - raise Error("Wrong replacement syntax. Use \"freeze_placeholder_with_value\" " - "\"node1_name->value1,node2_name->value2\"") - node_name = plh_with_value[0] - value = plh_with_value[1] - if node_name in placeholder_values and placeholder_values[node_name] != value: - raise Error("Overriding replacement value of the placeholder with name '{}': old value = {}, new value = {}" - ".".format(node_name, placeholder_values[node_name], value)) - if '[' in value.strip(' '): - value = value.replace('[', '').replace(']', '').split(' ') - placeholder_values[node_name] = value - return placeholder_values - - -def get_freeze_placeholder_values(argv_input: str): - """ - Parses values for placeholder freezing and input node names - - Parameters - ---------- - argv_input - string with a list of input layers: either an empty string, or strings separated with comma. - 'node_name1[shape1]->value1,node_name2[shape2]->value2,...' - - Returns - ------- - parsed placeholders with values for freezing - input nodes cleaned from shape info - """ - placeholder_values = {} - input_node_names = None - - if argv_input is not None: - input_node_names = '' - # walkthrough all input values and save values for freezing - for input_value in split_inputs(argv_input): - node_name, _, value, _ = parse_input_value(input_value) - input_node_names = input_node_names + ',' + node_name if input_node_names != '' else node_name - if value is None: # no value is specified for freezing - continue - if node_name in placeholder_values and placeholder_values[node_name] != value: - raise Error("Overriding replacement value of the placeholder with name '{}': old value = {}, new value = {}" - ".".format(node_name, placeholder_values[node_name], value)) - placeholder_values[node_name] = value - - return placeholder_values, input_node_names - - def split_inputs(input_str): brakets_count = 0 inputs = [] @@ -942,13 +851,28 @@ def get_model_name(path_input_model: str) -> str: def get_model_name_from_args(argv: argparse.Namespace): + output_dir = os.getcwd() if hasattr(argv, 'output_model') and argv.output_model: model_name = argv.output_model - else: - model_name = argv.input_model - if isinstance(model_name, (tuple, list)) and len(model_name) > 0: - model_name = model_name[0] - return model_name + + if not os.path.isdir(argv.output_model): + if not model_name.endswith('.xml'): + model_name += '.xml' + return model_name + else: + if not os.access(argv.output_model, os.W_OK): + raise Error('The directory "{}" is not writable'.format(argv.output_model)) + output_dir = argv.output_model + + input_model = argv.input_model + if isinstance(input_model, (tuple, list)) and len(input_model) > 0: + input_model = input_model[0] + + if not isinstance(input_model, (str, pathlib.Path)): + return output_dir + + input_model_name = os.path.splitext(os.path.split(input_model)[1])[0] + return os.path.join(output_dir, input_model_name + ".xml") def get_absolute_path(path_to_file: str) -> str: @@ -1033,7 +957,7 @@ def check_bool(value): def depersonalize(value: str, key: str): dir_keys = [ - 'output_dir', 'extension', 'saved_model_dir', 'tensorboard_logdir', 'caffe_parser_path' + 'extension' ] if isinstance(value, list): updated_value = [] diff --git a/tools/ovc/openvino/tools/ovc/convert.py b/tools/ovc/openvino/tools/ovc/convert.py index ebeb37abd04b4b..393ca2977cc260 100644 --- a/tools/ovc/openvino/tools/ovc/convert.py +++ b/tools/ovc/openvino/tools/ovc/convert.py @@ -1,26 +1,21 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -import os import pathlib -from collections import namedtuple from typing import Any -from openvino.runtime import PartialShape, Shape, Model # pylint: disable=no-name-in-module,import-error +from openvino.runtime import Model # pylint: disable=no-name-in-module,import-error +from openvino.tools.ovc.cli_parser import get_all_cli_parser from openvino.tools.ovc.convert_impl import _convert from openvino.tools.ovc.logger import get_logger_state, restore_logger_state -from openvino.tools.ovc.cli_parser import get_all_cli_parser - -#TODO: Why names InputCutInfo and InputInfo are different -InputCutInfo = namedtuple("InputInfo", ["name", "shape", "type", "value"], defaults=[None, None, None, None]) def convert_model( input_model: [str, pathlib.Path, Any, list], # TODO: Instead of list just accept arbitrary number of positional arguments # Framework-agnostic parameters - input: [str, list, tuple, InputCutInfo] = None, + input: [list, dict] = None, output: [str, list] = None, example_input: Any = None, extension: [str, pathlib.Path, list, Any] = None, @@ -63,27 +58,18 @@ def convert_model( paddle.fluid.executor.Executor :param input: - Input can be set by passing a list of InputCutInfo objects or by a list - of tuples. Each tuple can contain optionally input name, input - type or input shape. Example: input=("op_name", PartialShape([-1, - 3, 100, 100]), Type(np.float32)). Alternatively input can be set by - a string or list of strings of the following format. Quoted list of comma-separated - input nodes names with shapes, data types, and values for freezing. - If operation names are specified, the order of inputs in converted - model will be the same as order of specified operation names (applicable for TF2, ONNX, MxNet). - The shape and value are specified as comma-separated lists. The data type of input node is specified - in braces and can have one of the values: f64 (float64), f32 (float32), f16 (float16), i64 - (int64), i32 (int32), u8 (uint8), boolean (bool). Data type is optional. - If it's not specified explicitly then there are two options: if input - node is a parameter, data type is taken from the original node dtype, - if input node is not a parameter, data type is set to f32. Example, to set - `input_1` with shape [1,100], and Parameter node `sequence_len` with - scalar input with value `150`, and boolean input `is_training` with - `False` value use the following format: "input_1[1,100],sequence_len->150,is_training->False". - Another example, use the following format to set input port 0 of the node - `node_name1` with the shape [3,4] as an input node and freeze output - port 1 of the node `node_name2` with the value [20,15] of the int32 type - and shape [2]: "0:node_name1[3,4],node_name2:1[2]{i32}->[20,15]". + Information of model input required for model conversion. + Input can be set by a list of tuples or a dictionary. Each tuple can contain optionally input name (string), + input type (ov.Type, numpy.dtype) or input shape (ov.Shape, ov.PartialShape, list, tuple). + Example: input=("op_name", PartialShape([-1, 3, 100, 100]), ov.Type.f32). + Alternatively input can be set by a dictionary, where key - input name, + value - tuple with input parameters (shape or type). + Example 1: input={"op_name_1": ([1, 2, 3], ov.Type.f32), "op_name_2": ov.Type.i32} + Example 2: input=[("op_name_1", [1, 2, 3], ov.Type.f32), ("op_name_2", ov.Type.i32)] + Example 3: input=[([1, 2, 3], ov.Type.f32), ov.Type.i32] + The order of inputs in converted model will match the order of specified inputs. + If data type is not specified explicitly data type is taken from the original node data type. + :param output: The name of the output operation of the model or list of names. For TensorFlow*, do not add :0 to this name.The order of outputs in converted model is the @@ -96,9 +82,7 @@ def convert_model( :param extension: Paths to libraries (.so or .dll) with extensions, comma-separated list of paths, objects derived from BaseExtension class or lists of - objects. For the legacy MO path (if "use_legacy_frontend" is used), - a directory or a comma-separated list of directories with extensions - are supported. To disable all extensions including those that are placed + objects. To disable all extensions including those that are placed at the default location, pass an empty string. :param verbose: Print detailed information about conversion. diff --git a/tools/ovc/openvino/tools/ovc/convert_impl.py b/tools/ovc/openvino/tools/ovc/convert_impl.py index 7fd0e683f638a8..8c222cf4f4c1c5 100644 --- a/tools/ovc/openvino/tools/ovc/convert_impl.py +++ b/tools/ovc/openvino/tools/ovc/convert_impl.py @@ -21,9 +21,8 @@ from openvino.tools.ovc.moc_frontend.pipeline import moc_pipeline from openvino.tools.ovc.moc_frontend.moc_emit_ir import moc_emit_ir from openvino.tools.ovc.convert_data_type import destination_type_to_np_data_type -from openvino.tools.ovc.cli_parser import get_available_front_ends, \ - get_common_cli_options, get_model_name_from_args, depersonalize, get_mo_convert_params, \ - input_to_input_cut_info, freeze_placeholder_to_input_cut_info +from openvino.tools.ovc.cli_parser import get_available_front_ends, get_common_cli_options, depersonalize, \ + get_mo_convert_params, input_to_input_cut_info from openvino.tools.ovc.help import get_convert_model_help_specifics from openvino.tools.ovc.error import Error, FrameworkError @@ -57,10 +56,10 @@ def replace_ext(name: str, old: str, new: str): return base + new -def print_argv(argv: argparse.Namespace, model_name: str): +def print_argv(argv: argparse.Namespace): print('Model Conversion arguments:') props = OrderedDict() - props['common_args'] = get_common_cli_options(model_name) + props['common_args'] = get_common_cli_options(argv, argv.is_python_api_used) framework_specifics_map = { 'common_args': 'Common parameters:' @@ -80,10 +79,11 @@ def print_argv(argv: argparse.Namespace, model_name: str): def arguments_post_parsing(argv: argparse.Namespace): # TODO: This function looks similar to another one. Check for code duplicates. log.debug("Model Conversion API started") - log.debug('Output model name would be {}{{.xml, .bin}}'.format(argv.output_model)) + if not argv.is_python_api_used: + log.debug('Output model name would be {}{{.xml, .bin}}'.format(argv.output_model)) if argv.verbose: - print_argv(argv, argv.output_model) + print_argv(argv) params_parsing(argv) argv.output = argv.output.split(',') if isinstance(argv.output, (str, pathlib.Path)) else argv.output @@ -287,10 +287,6 @@ def params_parsing(argv: argparse.Namespace): argv.placeholder_data_types - dictionary where key is node name, value is node np.type, or list of np.types if node names were not set. - argv.freeze_placeholder_with_value - dictionary where key is node name, value is np.ndarray - - argv.unnamed_freeze_placeholder_with_value - list with np.ndarray - :param argv: MO arguments """ # Parse input to list of InputCutInfo @@ -308,13 +304,6 @@ def params_parsing(argv: argparse.Namespace): argv.inputs_list = input_names_list argv.input = ','.join(input_names_list) - # Parse freeze_placeholder_with_value. - # values for freezing can be set both by named and unnamed approach if - # 'input' was used without names and 'freeze_placeholder_with_value' was used with names. - # So named and unnamed values are stored separately. - argv.freeze_placeholder_with_value, argv.unnamed_freeze_placeholder_with_value = \ - freeze_placeholder_to_input_cut_info(inputs) - if len(input_names_list) > 0: # Named inputs case shape_dict = {} @@ -401,10 +390,6 @@ def is_verbose(argv: argparse.Namespace): def _convert(cli_parser: argparse.ArgumentParser, args, python_api_used): - # FIXME: It doesn't work when -h is passed - if 'help' in args and args['help']: - show_mo_convert_help() - return None, None simplified_ie_version = VersionChecker().get_ie_simplified_version() telemetry = init_mo_telemetry() telemetry.start_session('ovc') @@ -460,11 +445,6 @@ def _convert(cli_parser: argparse.ArgumentParser, args, python_api_used): non_default_params = get_non_default_params(argv, cli_parser) argv.is_python_api_used = python_api_used - if inp_model_is_object: - argv.output_model = "model" # TODO: Consider removing - if not hasattr(argv, "output_model") or argv.output_model is None: - argv.output_model = get_model_name_from_args(argv) - argv.framework = model_framework ov_model = driver(argv, {"conversion_parameters": non_default_params}) @@ -494,7 +474,7 @@ def _convert(cli_parser: argparse.ArgumentParser, args, python_api_used): if isinstance(e, (FileNotFoundError, NotADirectoryError)): log.error('File {} was not found'.format(str(e).split('No such file or directory:')[1])) log.debug(traceback.format_exc()) - elif isinstance(e, Error): + elif isinstance(e, (Error, OpConversionFailure)): log.error(e) log.debug(traceback.format_exc()) elif isinstance(e, FrameworkError): diff --git a/tools/ovc/openvino/tools/ovc/help.py b/tools/ovc/openvino/tools/ovc/help.py index 1921fddf94b407..53bf2171f6fdf1 100644 --- a/tools/ovc/openvino/tools/ovc/help.py +++ b/tools/ovc/openvino/tools/ovc/help.py @@ -8,77 +8,28 @@ def get_convert_model_help_specifics(): 'input_model': {'description': 'Input model file(s) from TensorFlow, ONNX, PaddlePaddle. ' - 'Use openvino.convert_model in Python to convert models from Pytorch.' + 'Use openvino.convert_model in Python to convert models from PyTorch.' '', 'action': CanonicalizePathCheckExistenceAction, 'type': readable_dirs_or_files_or_empty, 'aliases': {}}, - 'input_shape': - {'description': - 'Input shape(s) that should be fed to an input node(s) ' - 'of the model. Shape is defined as a comma-separated ' - 'list of integer numbers enclosed in parentheses or ' - 'square brackets, for example [1,3,227,227] or ' - '(1,227,227,3), where the order of dimensions depends ' - 'on the framework input layout of the model. For ' - 'example, [N,C,H,W] is used for ONNX* models and ' - '[N,H,W,C] for TensorFlow* models. The shape can ' - 'contain undefined dimensions (? or -1) and should fit ' - 'the dimensions defined in the input operation of the ' - 'graph. Boundaries of undefined dimension can be ' - 'specified with ellipsis, for example ' - '[1,1..10,128,128]. One boundary can be undefined, for ' - 'example [1,..100] or [1,3,1..,1..]. If there are ' - 'multiple inputs in the model, --input_shape should ' - 'contain definition of shape for each input separated ' - 'by a comma, for example: [1,3,227,227],[2,4] for a ' - 'model with two inputs with 4D and 2D shapes. ' - 'Alternatively, specify shapes with the --input option.'}, 'input': {'description': - 'Information for model input required for model conversion. ' + 'Information of model input required for model conversion. ' 'This is a comma separated list with optional ' - 'input names, shapes, data types, and values for freezing. ' - 'The order of inputs in converted model will match the order of ' - 'specified inputs. The shape and value are ' - 'specified as comma-separated lists. The data type of ' - 'input node is specified in braces and can have one of ' - 'the values: f64 (float64), f32 (float32), f16 ' - '(float16), i64 (int64), i32 (int32), u8 (uint8), ' - 'boolean (bool). Data type is optional. If it\'s not ' - 'specified explicitly then there are two options: if ' - 'input node is a parameter, data type is taken from the ' - 'original node dtype, if input node is not a parameter, ' - 'data type is set to f32. Example, to set `input_1` ' - 'with shape [1,100], and Parameter node `sequence_len` ' - 'with scalar input with value `150`, and boolean input ' - '`is_training` with `False` value use the following ' - 'format: \n ' - '\"input_1[1,100],sequence_len->150,is_training->False\". ' - 'Another example, use the following format to set input ' - 'port 0 of the node `node_name1` with the shape [3,4] ' - 'as an input node and freeze output port 1 of the node ' - '\"node_name2\" with the value [20,15] of the int32 type ' - 'and shape [2]: \n ' - '\"0:node_name1[3,4],node_name2:1[2]{i32}->[20,15]\".'}, - 'transform': - {'description': - 'Apply additional transformations. Usage: \"--transform ' - 'transformation_name1[args],transformation_name2...\" ' - 'where [args] is key=value pairs separated by ' - 'semicolon. Examples: \"--transform LowLatency2\" or \"--' - 'transform Pruning" or "--transform ' - 'LowLatency2[use_const_initializer=False]" or "--' - 'transform "MakeStateful[param_res_names= {\'input_name_1\':' - '\'output_name_1\',\'input_name_2\':\'output_name_2\'}]\" \n' - 'Available transformations: "LowLatency2", "MakeStateful", "Pruning"'}, + 'input names, shapes and data types. The order of inputs ' + 'in converted model will match the order of ' + 'specified inputs. The shape is specified as comma-separated list. ' + 'The data type of input node is specified in braces and can have one of ' + 'the values: f64, f32, f16, i64, i32, u8, boolean. If data type is not ' + 'specified explicitly then data type is taken from the ' + 'original node data type. Example, to set `input_1` input ' + 'with shape [1,100] and float32 type, and `sequence_len` input ' + 'with int32 type \"input_1[1,100]{f32},sequence_len{i32}\".'}, 'extension': {'description': 'Paths or a comma-separated list of paths to libraries ' - '(.so or .dll) with extensions. For the legacy MO path ' - '(if `--use_legacy_frontend` is used), a directory or a ' - 'comma-separated list of directories with extensions ' - 'are supported. To disable all extensions including ' + '(.so or .dll) with extensions. To disable all extensions including ' 'those that are placed at the default location, pass an empty string.', 'action': CanonicalizePathCheckExistenceAction, 'type': readable_files_or_empty}, diff --git a/tools/ovc/openvino/tools/ovc/main.py b/tools/ovc/openvino/tools/ovc/main.py index e5afa079b0ff48..45f26c210c0609 100644 --- a/tools/ovc/openvino/tools/ovc/main.py +++ b/tools/ovc/openvino/tools/ovc/main.py @@ -10,7 +10,7 @@ except ImportError: import openvino.tools.ovc.telemetry_stub as tm from openvino.tools.ovc.convert_impl import _convert -from openvino.tools.ovc.utils import get_ir_version +from openvino.tools.ovc.cli_parser import get_model_name_from_args # pylint: disable=no-name-in-module,import-error from openvino.runtime import serialize @@ -22,9 +22,7 @@ def main(): if ngraph_function is None: return 1 - output_dir = os.getcwd() - model_path_no_ext = os.path.normpath(os.path.join(output_dir, argv.output_model)) - model_path = model_path_no_ext + '.xml' + model_path = get_model_name_from_args(argv) # TODO: replace compress_model + serialize with save_model if argv.compress_to_fp16: diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/check_config.py b/tools/ovc/openvino/tools/ovc/moc_frontend/check_config.py index 77a27870e31f7b..c891e43e50b202 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/check_config.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/check_config.py @@ -97,8 +97,3 @@ def legacy_transformations_config_used(argv: argparse.Namespace): def tensorflow_custom_operations_config_update_used(argv: argparse.Namespace): return hasattr(argv, 'tensorflow_custom_operations_config_update') and \ argv.tensorflow_custom_operations_config_update is not None - - -def input_freezig_used(argv): - return hasattr(argv, 'freeze_placeholder_with_value') and argv.freeze_placeholder_with_value is not None \ - and len(argv.freeze_placeholder_with_value) > 0 diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py b/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py index 81056b5d534f4d..638acc0505a67d 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py @@ -336,16 +336,15 @@ def fe_output_user_data_repack(input_model: InputModel, outputs: list, framework node = decode_name_with_port(input_model, output, framework, IOType.Output) if node is None: raise Error("Cannot find location {} in the graph".format(output)) - _outputs.append({"node": node}) + _outputs.append({"node": node, "output_name": output}) return _outputs -def find_first_unused_input(model_inputs: list, freeze_placeholder: dict, param_dict: dict, param_name: str): +def find_first_unused_input(model_inputs: list, param_dict: dict, param_name: str): """ Finds first input in model_inputs, which is not present in freeze_placeholder dictionary or param_dict. :param model_inputs: list of model inputs - :param freeze_placeholder: dictionary where key is input name, value is input value for freezing. :param param_dict: dictionary where key is input name, value is parameter value (shape or type). :param param_name: name of parameter used in exception message. @@ -355,7 +354,7 @@ def find_first_unused_input(model_inputs: list, freeze_placeholder: dict, param_ input_names = inp.get_names() name_found = False for input_name in input_names: - if input_name in freeze_placeholder or input_name in param_dict: + if input_name in param_dict: name_found = True break if name_found: @@ -366,17 +365,13 @@ def find_first_unused_input(model_inputs: list, freeze_placeholder: dict, param_ def convert_params_lists_to_dicts(input_model, input_user_shapes: [list, dict], - input_user_data_types: [list, dict], - freeze_placeholder: dict, - unnamed_freeze_placeholders: list): + input_user_data_types: [list, dict]): """ Convert lists of unnamed params to dicts using input names from input_model. :param input_model: openvino.runtime.InputModel :param input_user_shapes: list of input shapes or dictionary where key is input name, value is input shape from user. :param input_user_data_types: list of input types or dictionary where key is input name, value is input type from user. - :param freeze_placeholder: dictionary where key is input name, value is input value from user. - :param unnamed_freeze_placeholders: list of unnamed input values from user. :return: (input_user_shapes_dict, input_user_data_types_dict, freeze_placeholder), where input_user_shapes_dict - dictionary where key is input name, value is shape from user; @@ -395,7 +390,7 @@ def convert_params_lists_to_dicts(input_model, for idx, shape in enumerate(input_user_shapes): assert isinstance(shape, PartialShape), "Got incorrect format of input shapes {}.".format(type(shape)) - inp_name = find_first_unused_input(model_inputs, freeze_placeholder, input_user_shapes_dict, "shape") + inp_name = find_first_unused_input(model_inputs, input_user_shapes_dict, "shape") input_user_shapes_dict[inp_name] = shape else: input_user_shapes_dict = input_user_shapes @@ -413,7 +408,7 @@ def convert_params_lists_to_dicts(input_model, "Expected numpy type or openvino.runtime.Type, " \ "got {}.".format(type(node_type)) - inp_name = find_first_unused_input(model_inputs, freeze_placeholder, input_user_data_types_dict, "type") + inp_name = find_first_unused_input(model_inputs, input_user_data_types_dict, "type") input_user_data_types_dict[inp_name] = node_type # FE postprocessing expects input_user_shapes_dict to always have shapes for corresponding types. # If shape is not set it is expected to have None shape in input_user_shapes_dict dictionary. @@ -422,15 +417,8 @@ def convert_params_lists_to_dicts(input_model, else: input_user_data_types_dict = input_user_data_types - # unnamed_freeze_placeholders is always list, it is not empty only if unnamed inputs were used. - for value in unnamed_freeze_placeholders: - assert isinstance(value, list), "Got incorrect format of input values. " \ - "Expected list, " \ - "got {}.".format(type(value)) - inp_name = find_first_unused_input(model_inputs, freeze_placeholder, {}, "input value") - freeze_placeholder[inp_name] = value - return input_user_shapes_dict, input_user_data_types_dict, freeze_placeholder + return input_user_shapes_dict, input_user_data_types_dict def fe_user_data_repack( diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py index a364239b182c39..58cc5a56b779ee 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py @@ -38,6 +38,17 @@ def get_enabled_and_disabled_transforms(): return enabled_transforms, disabled_transforms +def raise_exception_for_input_output_cut(model_inputs_or_outputs: List[Place], new_nodes: List[dict], is_input: bool): + for new_node in new_nodes: + node = new_node['node'] + + if not any([item.is_equal(node) for item in model_inputs_or_outputs]): + if is_input: + raise Exception("Name {} is not found among model inputs.".format(new_node['input_name'])) + else: + raise Exception("Name {} is not found among model outputs.".format(new_node['output_name'])) + + def moc_pipeline(argv: argparse.Namespace, moc_front_end: FrontEnd): """ Load input model and convert it to nGraph function @@ -62,13 +73,12 @@ def moc_pipeline(argv: argparse.Namespace, moc_front_end: FrontEnd): outputs = fe_output_user_data_repack(input_model, argv.output, moc_front_end.get_name()) input_model.override_all_outputs([x['node'] for x in outputs]) ''' - argv.placeholder_shapes, argv.placeholder_data_types, argv.freeze_placeholder_with_value = convert_params_lists_to_dicts( - input_model, argv.placeholder_shapes, argv.placeholder_data_types, - argv.freeze_placeholder_with_value, argv.unnamed_freeze_placeholder_with_value) + argv.placeholder_shapes, argv.placeholder_data_types = convert_params_lists_to_dicts( + input_model, argv.placeholder_shapes, argv.placeholder_data_types) user_shapes, outputs, freeze_placeholder = fe_user_data_repack( input_model, argv.placeholder_shapes, argv.placeholder_data_types, - argv.output, argv.freeze_placeholder_with_value, moc_front_end.get_name()) + argv.output, {}, moc_front_end.get_name()) def check_places_are_same(places_original: List[Place], places_new: List[Place]): """ @@ -109,10 +119,17 @@ def add_names_to_tensors(model: InputModel, places: List[Place]): model_inputs = input_model.get_inputs() inputs_equal = True if user_shapes: + + # TODO: Remove this line when new 'cut' helper is introduced + raise_exception_for_input_output_cut(model_inputs, user_shapes, True) + inputs_equal = check_places_are_same(model_inputs, user_shapes) outputs_equal = True if outputs: + # TODO: Remove this line when new 'cut' helper is introduced + raise_exception_for_input_output_cut(input_model.get_outputs(), outputs, False) + outputs_equal = check_places_are_same(input_model.get_outputs(), outputs) log.debug('Inputs are same: {}, outputs are same: {}'.format( inputs_equal, outputs_equal)) @@ -138,7 +155,7 @@ def create_target_input_shapes(new_input_places): user_shapes, outputs, _ = fe_user_data_repack( input_model, placeholder_shapes, argv.placeholder_data_types, - new_output_places_name, argv.freeze_placeholder_with_value, moc_front_end.get_name()) + new_output_places_name, {}, moc_front_end.get_name()) elif not inputs_equal: log.debug('Using override_all_inputs') add_names_to_tensors(input_model, user_shapes) @@ -150,7 +167,7 @@ def create_target_input_shapes(new_input_places): user_shapes, outputs, _ = fe_user_data_repack( input_model, placeholder_shapes, argv.placeholder_data_types, - argv.output, argv.freeze_placeholder_with_value, moc_front_end.get_name()) + argv.output, {}, moc_front_end.get_name()) elif not outputs_equal: log.debug('Using override_all_outputs') add_names_to_tensors(input_model, user_shapes) @@ -226,11 +243,6 @@ def create_target_input_shapes(new_input_places): def shape_to_array(shape: PartialShape): return [shape.get_dimension(i) for i in range(shape.rank.get_length())] - # obtain layout for all inputs - layout_values = {} - if 'layout_values' in argv and argv.layout_values: - layout_values = update_layout_to_dict(model_inputs, argv.layout_values, - lambda input_place: input_place.get_names()) ov_model = moc_front_end.convert(input_model) diff --git a/tools/ovc/unit_tests/moc_tf_fe/check_info_messages_test.py b/tools/ovc/unit_tests/moc_tf_fe/check_info_messages_test.py index 87232ed7bd7c18..0e7c0155022fb1 100644 --- a/tools/ovc/unit_tests/moc_tf_fe/check_info_messages_test.py +++ b/tools/ovc/unit_tests/moc_tf_fe/check_info_messages_test.py @@ -29,7 +29,6 @@ def arg_parse_helper(input_model, transform=[], output=None, input=None, - output_dir='.', compress_to_fp16=compress_to_fp16, extension=None ) diff --git a/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py b/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py index f8a2afa8415967..ba2a1a8a652c4f 100644 --- a/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py +++ b/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py @@ -35,132 +35,23 @@ def basic(self, input_model, argv_input, inputs, dtype, expected, only_conversio assert np.allclose(values, expected) @generate( - *[ - ( - "in1[1 4]->[1.0 2.0 3.0 4.0],in2[1 4]{f32}->[1.0 2.0 3.0 4.0]", - {}, - np.array([2.0, 4.0, 6.0, 8.0]), - np.float32, - ), - ( - "in2{f32}->[0.0 0.0 0.0 0.0]", - {"in1": np.array([[1.0, 2.0], [3.0, 4.0]])}, - np.array([[1.0, 2.0], [3.0, 4.0]]), - np.float32, - ), - ( - "in2->[1.0 15.0 15.5 1.0]", - {"in1": np.array([[2.0, 4.0], [12.0, 8.0]])}, - np.array([[3.0, 19.0], [27.5, 9.0]]), - np.float32, - ), - ( - "in1[1 4]{i32}->[1 2 3 4],in2[1 4]{i32}->[1 2 3 4]", - {}, - np.array([2.0, 4.0, 6.0, 8.0]), - np.int32, - ), - ], - ) - def test_fp32(self, input_freezing_value, inputs, expected, - dtype): - self.basic("model_fp32.pbtxt", input_freezing_value, inputs, dtype, expected) - - @generate( - *[ - ( - "in1[1 4]->[1 2 3 4],in2[1 4]{i32}->[1 2 3 4]", - {}, - np.array([1, 4, 9, 16]), - np.int32, - ), - ( - "in2->[2 5 6 7 3 2]", - {"in1": np.array([[2, 4, 1], [1, 2, 8]])}, - np.array([[4, 20, 6], [7, 6, 16]]), - np.int32, - ), - ], - ) - def test_int32(self, input_freezing_value, inputs, expected, - dtype=None): - self.basic("model_int32.pbtxt", input_freezing_value, inputs, dtype, expected) - - @generate( - *[ - ( - "in1[2]->[True False],in2[2]->[True True]", - {}, - np.array([True, False], dtype=bool), - bool, - ), - ( - "in2[2,3]->[True,True,False,True,True,False]", - {"in1": np.array([[False, True, True], [False, True, True]], dtype=bool)}, - np.array([[False, True, False], [False, True, False]], dtype=bool), - bool, - ), - ( - "in2[]->True", - {"in1": np.array([[False, True, True], [False, True, True]], dtype=bool)}, - np.array([[False, True, True], [False, True, True]], dtype=bool), - bool, - ), - ], - ) - def test_bool(self, input_freezing_value, inputs, expected, - dtype=None): - self.basic("model_bool.pbtxt", input_freezing_value, inputs, dtype, expected) - - @generate( - *[ - ( - "in1[3]->[1 2 3],in2[3]->[4 5 6],cond->False", - {}, - np.array([4, 5, 6], dtype=np.float32), - np.float32, - None - ), - ( - "in1,in2,cond->False", - {"in1": np.array([2.0, 4.0, 6.0], dtype=np.float32), - "in2": np.array([1.0, 3.0, 5.0], dtype=np.float32)}, - np.array([2, 4, 6], dtype=np.float32), - np.float32, - True # fill a bug to investigate why compilation of this model is hang on - ), - # case: input_shape + freeze_placeholder_with_value - ( - "in2,in1->[2.0 4.0 6.0],cond->True", - {"in2": np.array([1.0, 3.0, 5.0], dtype=np.float32)}, - np.array([2, 4, 6], dtype=np.float32), - np.float32, - False - ), - ], - ) - def test_bool2(self, input_freezing_value, inputs, expected, - dtype=None, only_conversion=False): - self.basic("model_bool2.pbtxt", input_freezing_value, inputs, dtype, expected, - only_conversion) - - @generate( - *[ - ( - "add:0[3],z", - {"add:0": np.array([4, 5, 6], dtype=np.float32), "z": np.array([1, 2, 3], dtype=np.float32)}, - np.array([4, 10, 18], dtype=np.float32), - np.float32, - None - ), - ( - "add:0{i32}[3],z{i32}", - {"add:0": np.array([4, 5, 6], dtype=np.int32), "z": np.array([1, 2, 3], dtype=np.int32)}, - np.array([4, 10, 18], dtype=np.int32), - np.int32, - None - ), - ], + # TODO: Return this test when new 'cut' helper is introduced + # *[ + # ( + # "add:0[3],z", + # {"add:0": np.array([4, 5, 6], dtype=np.float32), "z": np.array([1, 2, 3], dtype=np.float32)}, + # np.array([4, 10, 18], dtype=np.float32), + # np.float32, + # None + # ), + # ( + # "add:0{i32}[3],z{i32}", + # {"add:0": np.array([4, 5, 6], dtype=np.int32), "z": np.array([1, 2, 3], dtype=np.int32)}, + # np.array([4, 10, 18], dtype=np.int32), + # np.int32, + # None + # ), + # ], ) def test_cutting_fp32(self, input_freezing_value, inputs, expected, dtype=None, only_conversion=False): @@ -169,20 +60,21 @@ def test_cutting_fp32(self, input_freezing_value, inputs, expected, @generate( *[ - ( - "x[1,4],y[4]", - {"x": np.array([[3, 2, 1, 5]], dtype=np.int32), "y": np.array([0, -1, -7, 8], dtype=np.int32)}, - np.array([[3, 1, -6, 13]], dtype=np.int32), - np.int32, - None - ), - ( - "x,y", - {"x": np.array([[-3, 20, 1]], dtype=np.int32), "y": np.array([[10, -11, -17]], dtype=np.int32)}, - np.array([[7, 9, -16]], dtype=np.int32), - np.int32, - None - ), + # TODO: Return this test when new 'cut' helper is introduced + # ( + # "x[1,4],y[4]", + # {"x": np.array([[3, 2, 1, 5]], dtype=np.int32), "y": np.array([0, -1, -7, 8], dtype=np.int32)}, + # np.array([[3, 1, -6, 13]], dtype=np.int32), + # np.int32, + # None + # ), + # ( + # "x,y", + # {"x": np.array([[-3, 20, 1]], dtype=np.int32), "y": np.array([[10, -11, -17]], dtype=np.int32)}, + # np.array([[7, 9, -16]], dtype=np.int32), + # np.int32, + # None + # ), ( "x", {"x": np.array([[-3, 20, 1]], dtype=np.int32)}, @@ -197,28 +89,6 @@ def test_placeholder_with_default(self, inputs, inputs_data, expected, self.basic("placeholder_with_default.pbtxt", inputs, inputs_data, dtype, expected, only_conversion) - @generate( - *[ - ( - "x[4],y->2.0", - {"x": np.array([3, 2, 1, 5], dtype=np.float32)}, - np.array([6, 4, 2, 10], dtype=np.float32), - np.float32, - None - ), - ( - "x[1],y->[2.0,3.0]", - {"x": np.array([3], dtype=np.float32)}, - np.array([6, 9], dtype=np.float32), - np.float32, - None - ), - ], - ) - def test_freeze_placeholder_with_unknown_rank(self, inputs, inputs_data, expected, - dtype=None, only_conversion=False): - self.basic("mul_with_unknown_rank_y.pbtxt", inputs, inputs_data, dtype, expected, - only_conversion) def test_conversion_model_oneshot_iterator_default(self): self.basic("model_oneshot_iterator.pbtxt", None, None, None, None, True) diff --git a/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py b/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py index 49284fc501aef9..fa9b08d30f01ed 100644 --- a/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py +++ b/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py @@ -7,7 +7,6 @@ from generator import generator, generate from openvino.runtime import serialize -from openvino.tools.ovc import InputCutInfo from unit_tests.ovc.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry from unit_tests.ovc.convert.utils import create_onnx_model, save_to_onnx @@ -56,8 +55,7 @@ def create_onnx_model(): return onnx_net @generate(*[ - ({}), - ({'input': InputCutInfo(name='LeakyRelu_out', shape=None, type=None, value=None)}), + ({}) ]) # Checks convert import from openvino.tools.mo def test_import(self, params): diff --git a/tools/ovc/unit_tests/ovc/convert/meta_data_test.py b/tools/ovc/unit_tests/ovc/convert/meta_data_test.py index 60261fc8c88d4a..3c7dae9d0b1cc1 100644 --- a/tools/ovc/unit_tests/ovc/convert/meta_data_test.py +++ b/tools/ovc/unit_tests/ovc/convert/meta_data_test.py @@ -71,7 +71,7 @@ def check_meta_data(ov_model): if key == 'conversion_parameters': for param_name, param_value in value.items(): val = ov_model.get_rt_info([key, param_name]).astype(str) - if param_name in ['extension', 'caffe_parser_path', 'input_model', 'k', 'output_dir']: + if param_name in ['extension', 'input_model']: val = Path(val) assert val == param_value, \ "Runtime info attribute with name {} does not match. Expected: {}, " \ diff --git a/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py b/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py index 006aa997bc7c12..ebb46f107347bc 100644 --- a/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py +++ b/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py @@ -21,7 +21,7 @@ def check_meta_data(ov_model, ref_meta): if key == 'conversion_parameters': for param_name, param_value in value.items(): val = ov_model.get_rt_info([key, param_name]).astype(str) - if param_name in ['extension', 'caffe_parser_path', 'input_model', 'k', 'output_dir']: + if param_name in ['extension', 'input_model']: val = Path(val) assert val == param_value, \ "Runtime info attribute with name {} does not match. Expected: {}, " \ diff --git a/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py b/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py index 629c759f33fbbb..47bd73fe0528f6 100644 --- a/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py +++ b/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py @@ -12,15 +12,14 @@ import numpy as np -from openvino.tools.ovc.cli_parser import input_to_input_cut_info, \ - check_positive, writable_dir, \ - readable_file_or_object, get_freeze_placeholder_values, get_all_cli_parser, \ - get_mo_convert_params +from openvino.tools.ovc.cli_parser import input_to_input_cut_info, check_positive, writable_dir, \ + readable_file_or_object, get_all_cli_parser, get_mo_convert_params from openvino.tools.ovc.convert_impl import pack_params_to_args_namespace from openvino.tools.ovc.error import Error from unit_tests.ovc.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry from openvino.runtime import PartialShape, Dimension, Layout -from openvino.tools.ovc import InputCutInfo +from openvino.tools.ovc.cli_parser import _InputCutInfo +import openvino.runtime as ov class TestShapesParsing(UnitTestWithMockedTelemetry): @@ -28,152 +27,119 @@ def test_get_shapes_several_inputs_several_shapes2(self): # shapes specified using --input command line parameter and no values argv_input = "inp1[1,22,333,123],inp2[-1,45,7,1]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([1,22,333,123])), - InputCutInfo(name='inp2', shape=PartialShape([-1,45,7,1]))] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([1,22,333,123])), + _InputCutInfo(name='inp2', shape=PartialShape([-1,45,7,1]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_and_freezing_with_scalar_and_without_shapes_in_input(self): # shapes and value for freezing specified using --input command line parameter - argv_input = "inp1,inp2->157" + argv_input = "inp1,inp2" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1'), - InputCutInfo(name='inp2', value=157)] + inputs_ref = [_InputCutInfo(name='inp1'), + _InputCutInfo(name='inp2')] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp2': 157} - - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - self.assertEqual(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_and_freezing_with_scalar(self): # shapes and value for freezing specified using --input command line parameter - argv_input = "inp1,inp2[]->157" + argv_input = "inp1,inp2[]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1'), - InputCutInfo(name='inp2', shape=PartialShape([]), value=157)] + inputs_ref = [_InputCutInfo(name='inp1'), + _InputCutInfo(name='inp2', shape=PartialShape([]))] self.assertEqual(inputs, inputs_ref) def test_get_shapes_several_inputs_several_shapes3(self): # shapes and value for freezing specified using --input command line parameter - argv_input = "inp1[3 1]->[1.0 2.0 3.0],inp2[3,2,3],inp3[5]->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1[3 1],inp2[3,2,3],inp3[5]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), - InputCutInfo(name='inp3', shape=PartialShape([5]), value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), + _InputCutInfo(name='inp3', shape=PartialShape([5]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), - 'inp3': np.array(['1.0', '1.0', '2.0', '3.0', '5.0'])} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_shapes3_comma_sep(self): # shapes and value for freezing specified using --input command line parameter - argv_input = "inp1[3 1]->[1.0 2.0 3.0],inp2[3 2 3],inp3[5]->[1.0, 1.0, 2.0, 3.0,5.0]" + argv_input = "inp1[3 1],inp2[3 2 3],inp3[5]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), - InputCutInfo(name='inp3', shape=PartialShape([5]), value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), + _InputCutInfo(name='inp3', shape=PartialShape([5]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), - 'inp3': np.array(['1.0', '1.0', '2.0', '3.0', '5.0'])} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_shapes6(self): # 0D value for freezing specified using --input command line parameter without shape - argv_input = "inp1[3,1]->[1.0 2.0 3.0],inp2[3,2,3],inp3->False" + argv_input = "inp1[3,1],inp2[3,2,3],inp3" inputs_list, result, _ = input_to_input_cut_info(argv_input) inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), - InputCutInfo(name='inp3', value=False)] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), + _InputCutInfo(name='inp3')] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': False} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_shapes7(self): # 0D shape and value for freezing specified using --input command line parameter - argv_input = "inp1[3,1]->[1.0 2.0 3.0],inp2[3,2,3],inp3[]->True" + argv_input = "inp1[3,1],inp2[3,2,3],inp3[]" inputs_list, result, _ = input_to_input_cut_info(argv_input) inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), - InputCutInfo(name='inp3', shape=PartialShape([]), value=True)] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3])), + _InputCutInfo(name='inp3', shape=PartialShape([]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': True} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_and_data_types1(self): - argv_input = "inp1[3 1]->[1.0 2.0 3.0],inp2[3 2 3]{i32},inp3[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1[3 1],inp2[3 2 3]{i32},inp3[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), - InputCutInfo(name='inp3', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), + _InputCutInfo(name='inp3', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_with_input_ports(self): - argv_input = "1:inp1[3 1]->[1.0 2.0 3.0],inp2[3 2 3]{i32},0:inp3[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "1:inp1[3 1],inp2[3 2 3]{i32},0:inp3[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='1:inp1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), - InputCutInfo(name='0:inp3', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='1:inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), + _InputCutInfo(name='0:inp3', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_with_output_ports(self): - argv_input = "inp1:1[3 1]->[1.0 2.0 3.0],inp2[3 2 3]{i32},inp3:4[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1:1[3 1],inp2[3 2 3]{i32},inp3:4[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1:1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), - InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1:1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), + _InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_with_output_ports_comma_sep(self): - argv_input = "inp1:1[3,1]->[1.0,2.0 ,3.0],inp2[3,2, 3]{i32},inp3:4[5]{f32}->[1.0, 1.0,2.0, 3.0,5.0]" + argv_input = "inp1:1[3,1],inp2[3,2, 3]{i32},inp3:4[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1:1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), - InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1:1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape([3,2,3]), type=np.int32), + _InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_shape_only(self): argv_input = "placeholder1[3 1],placeholder2,placeholder3" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='placeholder1', shape=PartialShape([3,1])), - InputCutInfo(name='placeholder2'), - InputCutInfo(name='placeholder3')] + inputs_ref = [_InputCutInfo(name='placeholder1', shape=PartialShape([3,1])), + _InputCutInfo(name='placeholder2'), + _InputCutInfo(name='placeholder3')] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_shape_with_ports_only(self): argv_input = "placeholder1:4[3 1],placeholder2,2:placeholder3" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='placeholder1:4', shape=PartialShape([3,1])), - InputCutInfo(name='placeholder2'), - InputCutInfo(name='2:placeholder3')] + inputs_ref = [_InputCutInfo(name='placeholder1:4', shape=PartialShape([3,1])), + _InputCutInfo(name='placeholder2'), + _InputCutInfo(name='2:placeholder3')] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_when_no_freeze_value(self): argv_input = "placeholder1{i32}[3 1],placeholder2,placeholder3{i32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='placeholder1', shape=PartialShape([3,1]), type=np.int32), - InputCutInfo(name='placeholder2'), - InputCutInfo(name='placeholder3', type=np.int32)] + inputs_ref = [_InputCutInfo(name='placeholder1', shape=PartialShape([3,1]), type=np.int32), + _InputCutInfo(name='placeholder2'), + _InputCutInfo(name='placeholder3', type=np.int32)] self.assertEqual(inputs, inputs_ref) def test_wrong_data_types(self): @@ -185,13 +151,6 @@ def test_shape_and_value_shape_mismatch(self): argv_input = "inp1[3 1]->[1.0 2.0 3.0],inp2[3 2 3],inp3[5 3]->[2.0 3.0 5.0]" self.assertRaises(Error, input_to_input_cut_info, argv_input) - def test_wrong_data_for_input_cmd_param(self): - # test that wrongly formatted data specified in --input is handled properly - argv_input = "abc->[1.0" - self.assertRaises(Error, get_freeze_placeholder_values, argv_input) - argv_input = "def[2 2]->[1.0 2.0 3.0 4.0],abc->1.0 34]" - self.assertRaises(Error, get_freeze_placeholder_values, argv_input) - def test_get_shapes_no_input_no_shape(self): argv_input = "" inputs = input_to_input_cut_info(argv_input) @@ -202,106 +161,84 @@ def test_get_shapes_no_input_no_shape(self): def test_get_shapes_no_input_one_shape2(self): argv_input = "[12,4,1]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(shape=PartialShape([12,4,1]))] + inputs_ref = [_InputCutInfo(shape=PartialShape([12,4,1]))] self.assertEqual(inputs, inputs_ref) def test_get_shapes_for_scalar_inputs(self): argv_input = "[]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(shape=PartialShape([]))] + inputs_ref = [_InputCutInfo(shape=PartialShape([]))] self.assertEqual(inputs, inputs_ref) def test_get_shapes_two_input_shapes_with_scalar(self): argv_input = "[12,4,1],[]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(shape=PartialShape([12,4,1])), - InputCutInfo(shape=PartialShape([]))] + inputs_ref = [_InputCutInfo(shape=PartialShape([12,4,1])), + _InputCutInfo(shape=PartialShape([]))] self.assertEqual(inputs, inputs_ref) def test_get_shapes_two_input_shapes(self): argv_input = "[12,4,1],[10]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(shape=PartialShape([12,4,1])), - InputCutInfo(shape=PartialShape([10])),] + inputs_ref = [_InputCutInfo(shape=PartialShape([12,4,1])), + _InputCutInfo(shape=PartialShape([10])),] self.assertEqual(inputs, inputs_ref) def test_get_shapes_one_input_no_shape(self): argv_input = "inp1" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1')] + inputs_ref = [_InputCutInfo(name='inp1')] self.assertEqual(inputs, inputs_ref) def test_get_shapes_several_inputs_several_partial_shapes2(self): # shapes specified using --input command line parameter and no values argv_input = "inp1[1,?,50..100,123],inp2[-1,45..,..7,1]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape("[1,?,50..100,123]")), - InputCutInfo(name='inp2', shape=PartialShape("[-1,45..,..7,1]"))] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape("[1,?,50..100,123]")), + _InputCutInfo(name='inp2', shape=PartialShape("[-1,45..,..7,1]"))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) - def test_get_shapes_several_inputs_several_partial_shapes3(self): # shapes and value for freezing specified using --input command line parameter - argv_input = "inp1[3,1]->[1.0 2.0 3.0],inp2[3..,..2,5..10,?,-1],inp3[5]->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1[3,1],inp2[3..,..2,5..10,?,-1],inp3[5]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=["1.0", "2.0", "3.0"]), - InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), - InputCutInfo(name='inp3', shape=PartialShape([5]), value=["1.0", "1.0", "2.0", "3.0", "5.0"])] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), + _InputCutInfo(name='inp3', shape=PartialShape([5]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': np.array(['1.0', '1.0', '2.0', '3.0', '5.0'])} - input_node_names_ref = "inp1,inp2,inp3" - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_partial_shapes6(self): # 0D value for freezing specified using --input command line parameter without shape - argv_input = "inp1[3 1]->[1.0 2.0 3.0],inp2[3.. ..2 5..10 ? -1],inp3->False" + argv_input = "inp1[3 1],inp2[3.. ..2 5..10 ? -1],inp3" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=["1.0", "2.0", "3.0"]), - InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), - InputCutInfo(name='inp3', value=False)] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), + _InputCutInfo(name='inp3')] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': False} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_partial_shapes7(self): # 0D shape and value for freezing specified using --input command line parameter - argv_input = "inp1[3 1]->[1.0 2.0 3.0],inp2[3.. ..2 5..10 ? -1],inp3[]->True" + argv_input = "inp1[3 1],inp2[3.. ..2 5..10 ? -1],inp3[]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=["1.0", "2.0", "3.0"]), - InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), - InputCutInfo(name='inp3', shape=PartialShape([]), value=True)] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), + _InputCutInfo(name='inp3', shape=PartialShape([]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': True} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_and_data_types_partial_shape_with_input_port(self): - argv_input = "inp1:1[3 1]->[1.0 2.0 3.0],0:inp2[3.. ..2 5..10 ? -1]{i32},inp3:4[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1:1[3 1],0:inp2[3.. ..2 5..10 ? -1]{i32},inp3:4[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1:1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='0:inp2', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), - InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1:1', shape=PartialShape([3,1])), + _InputCutInfo(name='0:inp2', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), + _InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_partial_shape_with_output_port(self): - argv_input = "inp1:1[3 1]->[1.0 2.0 3.0],inp2:3[3.. ..2 5..10 ? -1]{i32},inp3:4[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1:1[3 1],inp2:3[3.. ..2 5..10 ? -1]{i32},inp3:4[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1:1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2:3', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), - InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1:1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2:3', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), + _InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_partial_shapes_freeze_dynamic_negative_case1(self): @@ -316,73 +253,51 @@ def test_get_shapes_several_inputs_several_partial_shapes2_comma_separator(self) # shapes specified using --input command line parameter and no values argv_input = "inp1[1,?,50..100,123],inp2[-1,45..,..7,1]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape("[1,?,50..100,123]")), - InputCutInfo(name='inp2', shape=PartialShape("[-1,45..,..7,1]"))] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape("[1,?,50..100,123]")), + _InputCutInfo(name='inp2', shape=PartialShape("[-1,45..,..7,1]"))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) - def test_get_shapes_several_inputs_several_partial_shapes3_comma_separator(self): # shapes and value for freezing specified using --input command line parameter - argv_input = "inp1[3,1]->[1.0 2.0 3.0],inp2[3..,..2,5..10,?,-1],inp3[5]->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1[3,1],inp2[3..,..2,5..10,?,-1],inp3[5]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=["1.0", "2.0", "3.0"]), - InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), - InputCutInfo(name='inp3', shape=PartialShape([5]), value=["1.0", "1.0", "2.0", "3.0", "5.0"])] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), + _InputCutInfo(name='inp3', shape=PartialShape([5]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), - 'inp3': np.array(['1.0', '1.0', '2.0', '3.0', '5.0'])} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_partial_shapes6_comma_separator(self): # 0D value for freezing specified using --input command line parameter without shape - argv_input = "inp1[3, 1]->[1.0 2.0 3.0],inp2[3.., ..2, 5..10, ?,-1],inp3->False" + argv_input = "inp1[3, 1],inp2[3.., ..2, 5..10, ?,-1],inp3" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=["1.0", "2.0", "3.0"]), - InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), - InputCutInfo(name='inp3', value=False)] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), + _InputCutInfo(name='inp3')] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': False} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_several_inputs_several_partial_shapes7_comma_separator(self): # 0D shape and value for freezing specified using --input command line parameter - argv_input = "inp1[3,1]->[1.0 2.0 3.0],inp2[3.., ..2,5..10, ?,-1],inp3[]->True" + argv_input = "inp1[3,1],inp2[3.., ..2,5..10, ?,-1],inp3[]" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1', shape=PartialShape([3,1]), value=["1.0", "2.0", "3.0"]), - InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), - InputCutInfo(name='inp3', shape=PartialShape([]), value=True)] + inputs_ref = [_InputCutInfo(name='inp1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2', shape=PartialShape("[3..,..2,5..10,?,-1]")), + _InputCutInfo(name='inp3', shape=PartialShape([]))] self.assertEqual(inputs, inputs_ref) - placeholder_values_res, input_node_names_res = get_freeze_placeholder_values(argv_input) - placeholder_values_ref = {'inp1': np.array(['1.0', '2.0', '3.0']), 'inp3': True} - self.assertEqual(list(placeholder_values_res.keys()), list(placeholder_values_ref.keys())) - for i in placeholder_values_ref.keys(): - assert np.array_equal(placeholder_values_res[i], placeholder_values_ref[i]) def test_get_shapes_and_data_types_partial_shape_with_input_port_comma_separator(self): - argv_input = "inp1:1[3,1]->[1.0 2.0 3.0],0:inp2[ 3.. ,..2, 5..10, ?,-1]{i32},inp3:4[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1:1[3,1],0:inp2[ 3.. ,..2, 5..10, ?,-1]{i32},inp3:4[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1:1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='0:inp2', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), - InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1:1', shape=PartialShape([3,1])), + _InputCutInfo(name='0:inp2', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), + _InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_get_shapes_and_data_types_partial_shape_with_output_port_comma_separator(self): - argv_input = "inp1:1[3,1]->[1.0 2.0 3.0],inp2:3[3..,..2,5..10,?,-1]{i32},inp3:4[5]{f32}->[1.0 1.0 2.0 3.0 5.0]" + argv_input = "inp1:1[3,1],inp2:3[3..,..2,5..10,?,-1]{i32},inp3:4[5]{f32}" inputs = input_to_input_cut_info(argv_input) - inputs_ref = [InputCutInfo(name='inp1:1', shape=PartialShape([3,1]), value=['1.0', '2.0', '3.0']), - InputCutInfo(name='inp2:3', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), - InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32, value=['1.0', '1.0', '2.0', '3.0', '5.0'])] + inputs_ref = [_InputCutInfo(name='inp1:1', shape=PartialShape([3,1])), + _InputCutInfo(name='inp2:3', shape=PartialShape("[3..,..2,5..10,?,-1]"), type=np.int32), + _InputCutInfo(name='inp3:4', shape=PartialShape([5]), type=np.float32)] self.assertEqual(inputs, inputs_ref) def test_partial_shapes_freeze_dynamic_negative_case1_comma_separator(self): @@ -401,6 +316,11 @@ def test_partial_shapes_freeze_dynamic_negative_case4_comma_separator(self): argv_input = "inp1:1[1, 2, -1]->[1.0 2.0 3.0]" self.assertRaises(Error, input_to_input_cut_info, argv_input) + def test_not_supported_arrow(self): + with self.assertRaisesRegex(Exception, + "Incorrect format of input."): + input_to_input_cut_info("inp1->[1.0]") + class PositiveChecker(unittest.TestCase): def test_positive_checker_batch(self): @@ -485,7 +405,7 @@ def test_mo_convert_params(self): from openvino.frontend import ConversionExtension args = {'input_model': os.path.dirname(__file__), 'extension': ConversionExtension("Ext", lambda x: x), - 'input': ['name', InputCutInfo("a", [1,2,3], numpy.float32, [5, 6, 7])], + 'input': ['name', ("a", [1,2,3], ov.Type.f32)], 'output': ["a", "b", "c"]} cli_parser = get_all_cli_parser() @@ -493,7 +413,7 @@ def test_mo_convert_params(self): assert argv.input_model == args['input_model'] assert argv.extension == args['extension'] - assert argv.input == ['name', InputCutInfo("a", [1,2,3], numpy.float32, [5, 6, 7])] + assert argv.input == ['name', ("a", [1,2,3], ov.Type.f32)] assert argv.output == ["a","b","c"] for arg, value in vars(argv).items(): diff --git a/tools/pot/openvino/__init__.py b/tools/pot/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/tools/pot/openvino/__init__.py +++ b/tools/pot/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass From c62ad1add8d1996f2051d71d330657b862a7716c Mon Sep 17 00:00:00 2001 From: Wanglei Shen Date: Fri, 11 Aug 2023 13:54:13 +0800 Subject: [PATCH 33/51] Support Win7 in cpu information parser (#19109) --- src/inference/src/os/win/win_system_conf.cpp | 13 ++- .../unit/cpu_map_parser/parser_windows.cpp | 107 +++++++++++++++++- 2 files changed, 114 insertions(+), 6 deletions(-) diff --git a/src/inference/src/os/win/win_system_conf.cpp b/src/inference/src/os/win/win_system_conf.cpp index c678525b66edfe..11b172ba5c2abd 100644 --- a/src/inference/src/os/win/win_system_conf.cpp +++ b/src/inference/src/os/win/win_system_conf.cpp @@ -64,8 +64,10 @@ void parse_processor_info_win(const char* base_ptr, int group_id = 0; int group_type = 0; + int num_package = 0; + _processors = 0; - _sockets = -1; + _sockets = 0; _cores = 0; PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX info = NULL; @@ -87,18 +89,19 @@ void parse_processor_info_win(const char* base_ptr, return; }; + _proc_type_table.push_back(proc_init_line); + for (; info_ptr < base_ptr + len; info_ptr += (DWORD)info->Size) { info = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)info_ptr; if (info->Relationship == RelationProcessorPackage) { - _sockets++; MaskToList(info->Processor.GroupMask->Mask); - if (0 == _sockets) { - _proc_type_table.push_back(proc_init_line); - } else { + if (num_package > 0) { + _sockets++; _proc_type_table.push_back(_proc_type_table[0]); _proc_type_table[0] = proc_init_line; } + num_package++; } else if (info->Relationship == RelationProcessorCore) { MaskToList(info->Processor.GroupMask->Mask); diff --git a/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp b/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp index 75e5cb5bb6d675..58d8e0441c0965 100644 --- a/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp +++ b/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp @@ -2088,6 +2088,108 @@ WinCpuMapTestCase _1sockets_4cores_hyperthreading = { "00000000000000000000000000000ff00000000000000"}, }; +WinCpuMapTestCase _1sockets_4cores_hyperthreading_1_FMT7 = { + 8, + 1, + 1, + 4, + {{8, 4, 0, 4, 0, 0}}, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, + {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {3, 0, 0, 1, MAIN_CORE_PROC, 1, -1}, + {4, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, + {5, 0, 0, 2, MAIN_CORE_PROC, 2, -1}, + {6, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, + {7, 0, 0, 3, MAIN_CORE_PROC, 3, -1}, + }, + {"0000000030000000010000000000000000000000000000000000000000000100030000000000000000006d0052006f0002000000380000000" + "10840000080000002000000000000000000000000000000000000000000000003000000000000000000720073005c00020000003800000001" + "08400000800000010000000000000000000000000000000000000000000000030000000000000000003d0043003a000200000038000000020" + "44000000004000000000000000000000000000000000000000000000000000300000000000000000065006d00700000000000300000000100" + "000000000000000000000000000000000000000001000c0000000000000000003500430033000200000038000000010840000080000002000" + "00000000000000000000000000000000000000000000c0000000000000000003d0043003a0002000000380000000108400000800000010000" + "0000000000000000000000000000000000000000000c000000000000000000770073000000020000003800000002044000000004000000000" + "000000000000000000000000000000000000000000c00000000000000000069006e0064000000000030000000010000000000000000000000" + "000000000000000000000100300000000000000000003a005c004200020000003800000001084000008000000200000000000000000000000" + "000000000000000000000003000000000000000000065005c0063000200000038000000010840000080000001000000000000000000000000" + "0000000000000000000000300000000000000000003a3d433a5c5502000000380000000204400000000400000000000000000000000000000" + "000000000000000000000300000000000000000003a5c50726f67030000003000000000000000000000000000000000000000000000000000" + "0100ff0000000000000000006700436f6d6d0000000030000000010000000000000000000000000000000000000000000100c000000000000" + "0000000657300436f6d02000000380000000108400000800000020000000000000000000000000000000000000000000000c0000000000000" + "0000002046696c657302000000380000000108400000800000010000000000000000000000000000000000000000000000c00000000000000" + "00000434f4d50555402000000380000000204400000000400000000000000000000000000000000000000000000000000c000000000000000" + "00006d642e65786502000000380000000310400000008000000000000000000000000000000000000000000000000000ff000000000000000" + "0004956453d433a0100000030000000000000000000000000000000000000000000000000000000ff00000000000000000057535c41707004" + "00000050000000010001000000000000000000000000000000000000000000080800000000000000000000000000000000000000000000000" + "00000000000000000000000000000ff00000000000000"}, +}; + +WinCpuMapTestCase _1sockets_4cores_hyperthreading_2_FMT7 = { + 8, + 1, + 1, + 4, + {{8, 4, 0, 4, 0, 0}}, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, + {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {3, 0, 0, 1, MAIN_CORE_PROC, 1, -1}, + {4, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, + {5, 0, 0, 2, MAIN_CORE_PROC, 2, -1}, + {6, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, + {7, 0, 0, 3, MAIN_CORE_PROC, 3, -1}, + }, + {"0000000030000000010000000000000000000000000000000000000000000100030000000000000000003d433a5c557302000000380000000" + "10840000080000002000000000000000000000000000000000000000000000003000000000000000000616d2046696c020000003800000001" + "08400000800000010000000000000000000000000000000000000000000000030000000000000000002046696c65730200000038000000020" + "44000000004000000000000000000000000000000000000000000000000000300000000000000000046696c65735c00000000300000000100" + "000000000000000000000000000000000000000001000c0000000000000000005c77696e646f0200000038000000010840000080000002000" + "00000000000000000000000000000000000000000000c0000000000000000004f53545f434802000000380000000108400000800000010000" + "0000000000000000000000000000000000000000000c0000000000000000003a5c50726f67020000003800000002044000000004000000000" + "000000000000000000000000000000000000000000c000000000000000000735c417070440000000030000000010000000000000000000000" + "000000000000000000000100300000000000000000004f434553534f020000003800000001084000008000000200000000000000000000000" + "00000000000000000000000300000000000000000007665726167650200000038000000010840000080000001000000000000000000000000" + "000000000000000000000030000000000000000000615c6a646b2d02000000380000000204400000000400000000000000000000000000000" + "000000000000000000000300000000000000000003b433a5c5072030000003000000000000000000000000000000000000000000000000000" + "0100ff0000000000000000005c6a617661700000000030000000010000000000000000000000000000000000000000000100c000000000000" + "00000006176615c6a6102000000380000000108400000800000020000000000000000000000000000000000000000000000c0000000000000" + "000000797374656d3302000000380000000108400000800000010000000000000000000000000000000000000000000000c00000000000000" + "000003b473a5c507202000000380000000204400000000400000000000000000000000000000000000000000000000000c000000000000000" + "0000726172795c6202000000380000000310400000008000000000000000000000000000000000000000000000000000ff000000000000000" + "0006c65735c47690100000030000000000000000000000000000000000000000000000000000000ff0000000000000000003b443a5c507204" + "00000050000000010001000000000000000000000000000000000000000000080800000000000000000000000000000000000000000000000" + "00000000000000000000000000000ff00000000000000"}, +}; + +WinCpuMapTestCase _1sockets_2cores_hyperthreading_FMT7 = { + 4, + 1, + 1, + 2, + {{4, 2, 0, 2, 0, 0}}, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, + {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {3, 0, 0, 1, MAIN_CORE_PROC, 1, -1}, + }, + {"000000003000000001000000000000000000000000000000000000000000010003000000000000000000cdcdcdcdcdcd02000000380000000" + "10840000080000002000000000000000000000000000000000000000000000003000000000000000000cdcdcdcdcdcd020000003800000001" + "0840000080000001000000000000000000000000000000000000000000000003000000000000000000cdcdcdcdcdcd0200000038000000020" + "840000000040000000000000000000000000000000000000000000000000003000000000000000000cdcdcdcdcdcd03000000300000000000" + "000000000000000000000000000000000000000001000f000000000000000000cdcdcdcdcdcd0000000030000000010000000000000000000" + "0000000000000000000000001000c000000000000000000cdcdcdcdcdcd020000003800000001084000008000000200000000000000000000" + "000000000000000000000000000c000000000000000000cdcdcdcdcdcd0200000038000000010840000080000001000000000000000000000" + "00000000000000000000000000c000000000000000000cdcdcdcdcdcd02000000380000000208400000000400000000000000000000000000" + "0000000000000000000000000c000000000000000000cdcdcdcdcdcd020000003800000003104000000040000000000000000000000000000" + "000000000000000000000000f000000000000000000cdcdcdcdcdcd0100000030000000000000000000000000000000000000000000000000" + "0000000f000000000000000000cdcdcdcdcdcd040000005000000001000100000000000000000000000000000000000000000004040000000" + "0000000000000000000000000000000000000000000000000000000000000000000000f00000000000000"}, +}; + TEST_P(WinCpuMapParserTests, WinCache) {} INSTANTIATE_TEST_SUITE_P(CPUMap, @@ -2103,7 +2205,10 @@ INSTANTIATE_TEST_SUITE_P(CPUMap, _1sockets_14cores_hyperthreading_set2, _1sockets_14cores_hyperthreading_set3, _1sockets_10cores_hyperthreading, - _1sockets_4cores_hyperthreading)); + _1sockets_4cores_hyperthreading, + _1sockets_4cores_hyperthreading_1_FMT7, + _1sockets_4cores_hyperthreading_2_FMT7, + _1sockets_2cores_hyperthreading_FMT7)); #endif From 2ed5e50bd1f9d4f841450f7b3abcfaad22f65133 Mon Sep 17 00:00:00 2001 From: Wanglei Shen Date: Fri, 11 Aug 2023 14:31:31 +0800 Subject: [PATCH 34/51] [CPU] Update stream info for mixing MAIN_CORE_PROC and HYPER_THREADING_PROC (#18863) --- .../intel_cpu/src/cpu_streams_calculation.cpp | 433 ++++++++++-------- .../intel_cpu/src/cpu_streams_calculation.hpp | 2 +- .../unit/streams_info/streams_e2e_test.cpp | 6 +- .../streams_info/streams_info_table_test.cpp | 205 ++++++--- 4 files changed, 398 insertions(+), 248 deletions(-) diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp index 77f0062817ef84..34bed35b907a0d 100644 --- a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp +++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp @@ -32,38 +32,58 @@ std::vector> get_streams_info_table(const int input_streams, const int model_prefer_threads, const std::string input_perf_hint, const Config::LatencyThreadingMode latencyThreadingMode, - const std::vector> proc_type_table) { + const std::vector>& proc_type_table) { std::vector stream_info(CPU_STREAMS_TABLE_SIZE, INIT_VAL); std::vector> streams_info_table; std::vector> proc_socket_table; int n_streams = 0; + int n_threads = 0; int n_threads_per_stream = 0; - auto update_mix_stream_info = [&]() { + auto update_ids_method = [&](const std::vector& one_proc_info) { + stream_info[STREAM_NUMA_NODE_ID] = one_proc_info[PROC_NUMA_NODE_ID]; + stream_info[STREAM_SOCKET_ID] = one_proc_info[PROC_SOCKET_ID]; + }; + + auto update_mix_stream_info = [&](const std::vector& one_proc_info, + const std::vector>& one_proc_table) { + stream_info[PROC_TYPE] = ALL_PROC; + stream_info[NUMBER_OF_STREAMS] = 1; + stream_info[THREADS_PER_STREAM] = n_threads_per_stream; + update_ids_method(one_proc_info); + streams_info_table.push_back(stream_info); stream_info[NUMBER_OF_STREAMS] = 0; - int n_threads = stream_info[THREADS_PER_STREAM]; + int total_threads = stream_info[THREADS_PER_STREAM]; + int numa_node_id = stream_info[STREAM_NUMA_NODE_ID]; + int socket_id = stream_info[STREAM_SOCKET_ID]; + int node_start = one_proc_table.size() == 1 ? 0 : 1; + int node_end = one_proc_table.size() == 1 ? 1 : one_proc_table.size(); for (int n = MAIN_CORE_PROC; n <= HYPER_THREADING_PROC; n++) { - if (0 != proc_type_table[0][n]) { - stream_info[PROC_TYPE] = n; - if (n_threads <= proc_type_table[0][n]) { - stream_info[THREADS_PER_STREAM] = n_threads; - streams_info_table.push_back(stream_info); - break; - } else { - stream_info[THREADS_PER_STREAM] = proc_type_table[0][n]; - streams_info_table.push_back(stream_info); - n_threads -= proc_type_table[0][n]; + for (int index = node_start; index < node_end; index++) { + if (((numa_node_id < 0) || (numa_node_id == one_proc_table[index][PROC_NUMA_NODE_ID])) && + ((socket_id < 0) || (socket_id == one_proc_table[index][PROC_SOCKET_ID]))) { + if (0 != one_proc_table[index][n]) { + stream_info[PROC_TYPE] = n; + if (total_threads <= one_proc_table[index][n]) { + stream_info[THREADS_PER_STREAM] = total_threads; + stream_info[STREAM_NUMA_NODE_ID] = one_proc_table[index][PROC_NUMA_NODE_ID]; + stream_info[STREAM_SOCKET_ID] = one_proc_table[index][PROC_SOCKET_ID]; + streams_info_table.push_back(stream_info); + return; + } else { + stream_info[THREADS_PER_STREAM] = one_proc_table[index][n]; + stream_info[STREAM_NUMA_NODE_ID] = one_proc_table[index][PROC_NUMA_NODE_ID]; + stream_info[STREAM_SOCKET_ID] = one_proc_table[index][PROC_SOCKET_ID]; + streams_info_table.push_back(stream_info); + total_threads -= one_proc_table[index][n]; + } + } } } } }; - auto update_ids_method = [&](const std::vector& one_proc_info) { - stream_info[STREAM_NUMA_NODE_ID] = one_proc_info[PROC_NUMA_NODE_ID]; - stream_info[STREAM_SOCKET_ID] = one_proc_info[PROC_SOCKET_ID]; - }; - auto update_streams_per_node = [&](const int& proc_type, const std::vector& one_proc_info) { if (0 != one_proc_info[proc_type]) { if (n_threads_per_stream == -1) { @@ -73,19 +93,33 @@ std::vector> get_streams_info_table(const int input_streams, update_ids_method(one_proc_info); stream_info[NUMBER_OF_STREAMS] = static_cast(one_proc_info[proc_type] / stream_info[THREADS_PER_STREAM]); - if ((stream_info[NUMBER_OF_STREAMS] == 0) && (proc_type == MAIN_CORE_PROC)) { - stream_info[NUMBER_OF_STREAMS] = - static_cast((one_proc_info[MAIN_CORE_PROC] + one_proc_info[HYPER_THREADING_PROC]) / - stream_info[THREADS_PER_STREAM]); - } if (n_streams < stream_info[NUMBER_OF_STREAMS]) { stream_info[NUMBER_OF_STREAMS] = n_streams; } - streams_info_table.push_back(stream_info); + if (stream_info[NUMBER_OF_STREAMS] > 0) { + streams_info_table.push_back(stream_info); + n_streams -= stream_info[NUMBER_OF_STREAMS]; + } + } + }; - n_streams -= stream_info[NUMBER_OF_STREAMS]; - proc_socket_table[one_proc_info[PROC_SOCKET_ID]][proc_type] -= - stream_info[NUMBER_OF_STREAMS] * stream_info[THREADS_PER_STREAM]; + auto check_threads_per_stream = [&]() { + int count = 0; + while (1) { + for (int n_type = MAIN_CORE_PROC; n_type <= HYPER_THREADING_PROC; n_type++) { + count += static_cast(proc_type_table[0][n_type] / n_threads_per_stream); + } + if (count >= n_streams) { + return; + } else { + count = 0; + if (n_threads_per_stream > 1) { + n_threads_per_stream--; + } else { + n_streams = n_threads; + return; + } + } } }; @@ -115,148 +149,95 @@ std::vector> get_streams_info_table(const int input_streams, if (((input_streams_changed == false) && (input_perf_hint == CONFIG_VALUE(LATENCY)) && ((latencyThreadingMode == Config::LatencyThreadingMode::PER_PLATFORM) || (proc_type_table.size() == 1))) || ((input_streams_changed == true) && (input_streams == 1))) { - stream_info[NUMBER_OF_STREAMS] = 1; - if (input_threads > 0) { - stream_info[THREADS_PER_STREAM] = std::min(proc_type_table[0][ALL_PROC], input_threads); - if ((stream_info[THREADS_PER_STREAM] > proc_type_table[0][MAIN_CORE_PROC]) && - (proc_type_table[0][MAIN_CORE_PROC] > 0) && (proc_type_table[0][EFFICIENT_CORE_PROC] > 0)) { - stream_info[PROC_TYPE] = ALL_PROC; + n_streams = 1; + if ((proc_type_table.size() == 1) && (model_prefer_threads > 0) && + ((input_threads == 0) || (input_threads > model_prefer_threads))) { + stream_info[NUMBER_OF_STREAMS] = n_streams; + if ((model_prefer_threads == proc_type_table[0][MAIN_CORE_PROC]) && + (proc_type_table[0][MAIN_CORE_PROC] > 0)) { + stream_info[PROC_TYPE] = MAIN_CORE_PROC; + n_threads_per_stream = proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; + stream_info[THREADS_PER_STREAM] = n_threads_per_stream; + update_ids_method(proc_type_table[0]); + } else if (proc_type_table[0][MAIN_CORE_PROC] == 0) { + stream_info[PROC_TYPE] = EFFICIENT_CORE_PROC; + n_threads_per_stream = proc_type_table[0][EFFICIENT_CORE_PROC]; + stream_info[THREADS_PER_STREAM] = n_threads_per_stream; update_ids_method(proc_type_table[0]); - streams_info_table.push_back(stream_info); - update_mix_stream_info(); } else { - if ((stream_info[THREADS_PER_STREAM] <= proc_type_table[0][MAIN_CORE_PROC]) || - (proc_type_table[0][EFFICIENT_CORE_PROC] == 0)) { - stream_info[PROC_TYPE] = MAIN_CORE_PROC; - } else { - stream_info[PROC_TYPE] = EFFICIENT_CORE_PROC; - } - if (proc_type_table.size() == 1) { - update_ids_method(proc_type_table[0]); - } else { - size_t i = 0; - for (i = 1; i < proc_type_table.size(); i++) { - if (proc_type_table[i][stream_info[PROC_TYPE]] >= stream_info[THREADS_PER_STREAM]) { - update_ids_method(proc_type_table[i]); - i = proc_type_table.size() + 1; - break; - } - } - if (i <= proc_type_table.size()) { - for (i = 0; i < proc_socket_table.size(); i++) { - if (proc_socket_table[i][stream_info[PROC_TYPE]] >= stream_info[THREADS_PER_STREAM]) { - update_ids_method(proc_socket_table[i]); - i = proc_socket_table.size() + 1; - break; - } - } - if (i <= proc_socket_table.size()) { - update_ids_method(proc_type_table[0]); - } - } - } - streams_info_table.push_back(stream_info); + stream_info[PROC_TYPE] = ALL_PROC; + n_threads_per_stream = proc_type_table[0][ALL_PROC]; } } else { - if (proc_type_table[0][ALL_PROC] == proc_type_table[0][EFFICIENT_CORE_PROC]) { - stream_info[PROC_TYPE] = EFFICIENT_CORE_PROC; - stream_info[THREADS_PER_STREAM] = - (model_prefer_threads == 0) - ? proc_type_table[0][EFFICIENT_CORE_PROC] - : std::min(proc_type_table[0][EFFICIENT_CORE_PROC], model_prefer_threads); - update_ids_method(proc_type_table[0]); - streams_info_table.push_back(stream_info); - } else if ((proc_type_table[0][EFFICIENT_CORE_PROC] > 0) && - ((model_prefer_threads == 0) || (model_prefer_threads > proc_type_table[0][MAIN_CORE_PROC]))) { + n_threads_per_stream = input_threads > 0 ? std::min(input_threads, proc_type_table[0][ALL_PROC]) + : proc_type_table[0][ALL_PROC]; + if ((proc_type_table.size() == 1) && (n_threads_per_stream > proc_type_table[0][MAIN_CORE_PROC]) && + (proc_type_table[0][MAIN_CORE_PROC] > 0)) { stream_info[PROC_TYPE] = ALL_PROC; - stream_info[THREADS_PER_STREAM] = - (model_prefer_threads == 0 || model_prefer_threads > proc_type_table[0][MAIN_CORE_PROC]) - ? proc_type_table[0][ALL_PROC] - : proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; - update_ids_method(proc_type_table[0]); - streams_info_table.push_back(stream_info); - update_mix_stream_info(); - } else { - stream_info[PROC_TYPE] = MAIN_CORE_PROC; - stream_info[THREADS_PER_STREAM] = - proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; - update_ids_method(proc_type_table[0]); - streams_info_table.push_back(stream_info); } } - return streams_info_table; - } else if ((input_streams_changed == false) && (input_perf_hint == CONFIG_VALUE(LATENCY))) { - if (latencyThreadingMode == Config::LatencyThreadingMode::PER_NUMA_NODE) { - if (proc_type_table.size() == 1) { - stream_info[NUMBER_OF_STREAMS] = 1; - stream_info[PROC_TYPE] = MAIN_CORE_PROC; - stream_info[THREADS_PER_STREAM] = proc_type_table[0][ALL_PROC]; - update_ids_method(proc_type_table[0]); - streams_info_table.push_back(stream_info); - } else { - for (size_t i = 1; i < proc_type_table.size(); i++) { - if (i != 1) { - if (proc_type_table[i][ALL_PROC] < streams_info_table[0][THREADS_PER_STREAM]) { - continue; - } else if (proc_type_table[i][ALL_PROC] < streams_info_table[0][THREADS_PER_STREAM]) { - streams_info_table.clear(); - } - } - stream_info[NUMBER_OF_STREAMS] = 1; - stream_info[PROC_TYPE] = MAIN_CORE_PROC; - stream_info[THREADS_PER_STREAM] = proc_type_table[i][ALL_PROC]; - update_ids_method(proc_type_table[i]); - streams_info_table.push_back(stream_info); - } + } else if ((input_streams_changed == false) && (input_perf_hint == CONFIG_VALUE(LATENCY)) && + (latencyThreadingMode == Config::LatencyThreadingMode::PER_SOCKET)) { + for (auto& row : proc_socket_table) { + n_threads_per_stream = std::max(n_threads_per_stream, row[ALL_PROC]); + } + n_threads_per_stream = input_threads > 0 ? std::min(input_threads, n_threads_per_stream) : n_threads_per_stream; + for (auto& row : proc_socket_table) { + if (n_threads_per_stream <= row[ALL_PROC]) { + n_streams++; } + } + n_streams = input_threads > 0 ? static_cast(input_threads / n_threads_per_stream) : n_streams; + n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, n_streams) : n_streams; + } else if ((input_streams_changed == false) && (input_perf_hint == CONFIG_VALUE(LATENCY)) && + (latencyThreadingMode == Config::LatencyThreadingMode::PER_NUMA_NODE)) { + if (proc_type_table.size() == 1) { + n_streams = 1; + n_threads_per_stream = input_threads > 0 ? std::min(input_threads, proc_type_table[0][ALL_PROC]) + : proc_type_table[0][ALL_PROC]; } else { - for (size_t i = 0; i < proc_socket_table.size(); i++) { - if (streams_info_table.size() != 0) { - if (streams_info_table[0][THREADS_PER_STREAM] > proc_socket_table[i][ALL_PROC]) { - continue; - } else if (streams_info_table[0][THREADS_PER_STREAM] < proc_socket_table[i][ALL_PROC]) { - streams_info_table.clear(); - } + for (size_t i = 1; i < proc_type_table.size(); i++) { + n_threads_per_stream = std::max(n_threads_per_stream, proc_type_table[i][ALL_PROC]); + } + n_threads_per_stream = + input_threads > 0 ? std::min(input_threads, n_threads_per_stream) : n_threads_per_stream; + for (size_t i = 1; i < proc_type_table.size(); i++) { + if (n_threads_per_stream <= proc_type_table[i][ALL_PROC]) { + n_streams++; } - stream_info[NUMBER_OF_STREAMS] = 1; - stream_info[PROC_TYPE] = MAIN_CORE_PROC; - stream_info[THREADS_PER_STREAM] = proc_socket_table[i][ALL_PROC]; - update_ids_method(proc_socket_table[i]); - streams_info_table.push_back(stream_info); } + n_streams = input_threads > 0 ? static_cast(input_threads / n_threads_per_stream) : n_streams; + n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, n_streams) : n_streams; } - return streams_info_table; } else { - int n_threads = 0; - int base_type = MAIN_CORE_PROC; - n_threads = - (0 == input_threads) ? proc_type_table[0][ALL_PROC] : std::min(proc_type_table[0][ALL_PROC], input_threads); - + input_threads > 0 ? std::min(proc_type_table[0][ALL_PROC], input_threads) : proc_type_table[0][ALL_PROC]; if ((input_streams_changed == true) && (input_streams > 0)) { - base_type = (proc_type_table[0][MAIN_CORE_PROC] == 0) ? EFFICIENT_CORE_PROC : MAIN_CORE_PROC; - n_streams = (input_infer_requests > 0) ? std::min(input_streams, input_infer_requests) : input_streams; + n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, input_streams) : input_streams; if (n_streams >= n_threads) { n_streams = n_threads; n_threads_per_stream = 1; } else { - n_threads_per_stream = std::min(std::max(1, n_threads / n_streams), proc_type_table[0][base_type]); - if (proc_type_table.size() == 1) { - if ((n_threads_per_stream > proc_type_table[0][base_type]) && - (n_threads_per_stream < proc_type_table[0][base_type] * 2)) { - n_threads_per_stream = proc_type_table[0][base_type]; - } else if (n_threads_per_stream < proc_type_table[0][base_type]) { - n_threads_per_stream = static_cast( - proc_type_table[0][base_type] / - ((proc_type_table[0][base_type] + n_threads_per_stream - 1) / n_threads_per_stream)); - } - } + n_threads_per_stream = + std::min(static_cast(n_threads / n_streams), + proc_type_table[0][MAIN_CORE_PROC] == 0 ? proc_type_table[0][EFFICIENT_CORE_PROC] + : proc_type_table[0][MAIN_CORE_PROC]); + check_threads_per_stream(); } } else { - base_type = (proc_type_table[0][MAIN_CORE_PROC] == 0) ? EFFICIENT_CORE_PROC : MAIN_CORE_PROC; + int base_type = (proc_type_table[0][MAIN_CORE_PROC] == 0) ? EFFICIENT_CORE_PROC : MAIN_CORE_PROC; if (0 == model_prefer_threads) { - int n_proc = (proc_type_table.size() == 1) ? std::min(n_threads, proc_type_table[0][base_type]) - : std::min(n_threads, proc_type_table[1][base_type]); + int n_proc = 0; + + if (proc_type_table.size() == 1) { + n_proc = std::min(n_threads, proc_type_table[0][base_type]); + } else { + for (size_t i = 1; i < proc_type_table.size(); i++) { + n_proc = std::max(n_proc, proc_type_table[i][base_type]); + } + n_proc = std::min(n_threads, n_proc); + } + if (0 == n_proc % 4) { n_threads_per_stream = 4; } else if (0 == n_proc % 5) { @@ -271,14 +252,14 @@ std::vector> get_streams_info_table(const int input_streams, n_streams = static_cast(n_threads / n_threads_per_stream); if ((input_infer_requests > 0) && (n_streams > input_infer_requests)) { n_streams = input_infer_requests; - n_threads_per_stream = - std::min(static_cast(n_threads / n_streams), proc_type_table[0][base_type]); + if (proc_type_table.size() == 1) { + n_threads_per_stream = std::min(static_cast(n_threads / n_streams), n_proc); + } else { + n_threads_per_stream = static_cast(n_threads / n_streams); + } } else { while (n_streams * 2 <= n_threads_per_stream) { n_threads_per_stream = static_cast(n_threads_per_stream / 2); - n_threads_per_stream = static_cast( - proc_type_table[0][base_type] / - ((proc_type_table[0][base_type] + n_threads_per_stream - 1) / n_threads_per_stream)); n_streams = static_cast(n_threads / n_threads_per_stream); } } @@ -288,68 +269,146 @@ std::vector> get_streams_info_table(const int input_streams, ? static_cast(n_threads - proc_type_table[0][EFFICIENT_CORE_PROC] / 2) : static_cast(proc_type_table[0][MAIN_CORE_PROC] + (n_threads - proc_type_table[0][MAIN_CORE_PROC]) / 2); - n_streams = (input_infer_requests > 0) ? std::min(n_streams, input_infer_requests) : n_streams; + n_streams = input_infer_requests > 0 ? std::min(n_streams, input_infer_requests) : n_streams; n_threads_per_stream = -1; } else { n_streams = ((n_threads + model_prefer_threads - 1) / model_prefer_threads); - n_streams = (input_infer_requests > 0) ? std::min(n_streams, input_infer_requests) : n_streams; - n_threads_per_stream = std::min(static_cast(n_threads / n_streams), proc_type_table[0][base_type]); + if ((input_infer_requests > 0) && (n_streams > input_infer_requests)) { + n_streams = input_infer_requests; + n_threads_per_stream = static_cast(n_threads / n_streams); + check_threads_per_stream(); + } else { + n_threads_per_stream = + model_prefer_threads > 0 ? model_prefer_threads : static_cast(n_threads / n_streams); + } } } + } + int total_streams = n_streams; + + if (stream_info[PROC_TYPE] == INIT_VAL) { stream_info[THREADS_PER_STREAM] = n_threads_per_stream; for (int n_type = MAIN_CORE_PROC; (n_type <= HYPER_THREADING_PROC) && (n_streams > 0); n_type++) { - if (proc_type_table[0][n_type] > 0) { - if (proc_type_table.size() == 1) { + if (proc_type_table.size() == 1) { + if (proc_type_table[0][n_type] >= stream_info[THREADS_PER_STREAM]) { update_streams_per_node(n_type, proc_type_table[0]); - } else { - for (size_t n_node = 1; (n_node < proc_type_table.size()) && (n_streams > 0); n_node++) { + } + } else { + for (size_t n_node = 1; (n_node < proc_type_table.size()) && (n_streams > 0); n_node++) { + if (proc_type_table[n_node][n_type] >= stream_info[THREADS_PER_STREAM]) { update_streams_per_node(n_type, proc_type_table[n_node]); } } } } + if (total_streams == n_streams) { + if (proc_type_table.size() == 1) { + if (proc_type_table[0][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { + update_mix_stream_info(proc_type_table[0], proc_type_table); + n_streams--; + } + } else { + for (size_t n_node = 1; (n_node < proc_type_table.size()) && (n_streams > 0); n_node++) { + if (proc_type_table[n_node][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { + update_mix_stream_info(proc_type_table[n_node], proc_type_table); + n_streams--; + } + } + } + for (size_t n_node = 0; (n_node < proc_socket_table.size()) && (n_streams > 0); n_node++) { + if (proc_socket_table[n_node][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { + update_mix_stream_info(proc_socket_table[n_node], proc_type_table); + n_streams--; + } + } + } + + if (total_streams == n_streams) { + for (size_t n_node = 0; (n_node < proc_socket_table.size()) && (n_streams > 0); n_node++) { + if (proc_socket_table[n_node][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { + update_mix_stream_info(proc_socket_table[n_node], proc_type_table); + n_streams--; + } + } + } + + if (total_streams == n_streams) { + update_mix_stream_info(proc_type_table[0], proc_type_table); + n_streams--; + } + if (n_streams > 0) { - for (int n_type = MAIN_CORE_PROC; n_type <= HYPER_THREADING_PROC; n_type++) { - int proc_sum = 0; - for (size_t n_socket = 0; n_socket < proc_socket_table.size(); n_socket++) { - if (proc_socket_table[n_socket][n_type] >= stream_info[THREADS_PER_STREAM]) { - stream_info[PROC_TYPE] = n_type; - stream_info[NUMBER_OF_STREAMS] = - static_cast(proc_socket_table[n_socket][n_type] / stream_info[THREADS_PER_STREAM]); - stream_info[STREAM_NUMA_NODE_ID] = -1; - stream_info[STREAM_SOCKET_ID] = n_socket; - streams_info_table.push_back(stream_info); - n_streams -= stream_info[NUMBER_OF_STREAMS]; - proc_socket_table[n_socket][n_type] -= - stream_info[THREADS_PER_STREAM] * stream_info[NUMBER_OF_STREAMS]; - if (n_streams <= 0) { - break; + std::vector> remain_proc_type_table(proc_type_table); + size_t stream_table_size = streams_info_table.size(); + + for (size_t i = 0; i < stream_table_size; i++) { + if ((streams_info_table[i][STREAM_NUMA_NODE_ID] >= 0) && + (streams_info_table[i][STREAM_SOCKET_ID] >= 0)) { + for (auto& row : remain_proc_type_table) { + if ((streams_info_table[i][STREAM_NUMA_NODE_ID] == row[PROC_NUMA_NODE_ID]) && + (streams_info_table[i][STREAM_SOCKET_ID] == row[PROC_SOCKET_ID])) { + row[streams_info_table[i][PROC_TYPE]] -= (streams_info_table[i][NUMBER_OF_STREAMS] == 0 + ? 1 + : streams_info_table[i][NUMBER_OF_STREAMS]) * + streams_info_table[i][THREADS_PER_STREAM]; } } - proc_sum += proc_socket_table[n_socket][n_type]; } - if (n_streams <= 0) { + } + + while (n_streams > 0) { + update_mix_stream_info(proc_type_table[0], remain_proc_type_table); + + if (stream_table_size == streams_info_table.size()) { break; } - if (proc_sum >= stream_info[THREADS_PER_STREAM]) { - stream_info[PROC_TYPE] = n_type; - stream_info[NUMBER_OF_STREAMS] = static_cast(proc_sum / stream_info[THREADS_PER_STREAM]); - stream_info[STREAM_NUMA_NODE_ID] = -1; - stream_info[STREAM_SOCKET_ID] = -1; - streams_info_table.push_back(stream_info); - n_streams -= stream_info[NUMBER_OF_STREAMS]; - if (n_streams <= 0) { - break; + n_streams--; + int numa_node_id = streams_info_table[stream_table_size + 1][STREAM_NUMA_NODE_ID]; + int socket_id = streams_info_table[stream_table_size + 1][STREAM_SOCKET_ID]; + for (size_t i = stream_table_size + 1; i < streams_info_table.size(); i++) { + numa_node_id = numa_node_id == streams_info_table[i][STREAM_NUMA_NODE_ID] ? numa_node_id : -1; + socket_id = socket_id == streams_info_table[i][STREAM_SOCKET_ID] ? socket_id : -1; + for (auto& row : remain_proc_type_table) { + if ((streams_info_table[i][STREAM_NUMA_NODE_ID] == row[PROC_NUMA_NODE_ID]) && + (streams_info_table[i][STREAM_SOCKET_ID] == row[PROC_SOCKET_ID])) { + row[streams_info_table[i][PROC_TYPE]] -= (streams_info_table[i][NUMBER_OF_STREAMS] == 0 + ? 1 + : streams_info_table[i][NUMBER_OF_STREAMS]) * + streams_info_table[i][THREADS_PER_STREAM]; + } } } + streams_info_table[stream_table_size][STREAM_NUMA_NODE_ID] = numa_node_id; + streams_info_table[stream_table_size][STREAM_SOCKET_ID] = socket_id; + stream_table_size = streams_info_table.size(); } } - - return streams_info_table; + } else { + if (stream_info[PROC_TYPE] == ALL_PROC) { + update_mix_stream_info(proc_socket_table[0], proc_type_table); + } else if (stream_info[PROC_TYPE] == MAIN_CORE_PROC) { + if (stream_info[THREADS_PER_STREAM] == proc_socket_table[0][MAIN_CORE_PROC]) { + streams_info_table.push_back(stream_info); + } else { + stream_info[PROC_TYPE] = ALL_PROC; + streams_info_table.push_back(stream_info); + stream_info[NUMBER_OF_STREAMS] = 0; + stream_info[PROC_TYPE] = MAIN_CORE_PROC; + stream_info[THREADS_PER_STREAM] = proc_socket_table[0][MAIN_CORE_PROC]; + streams_info_table.push_back(stream_info); + stream_info[PROC_TYPE] = HYPER_THREADING_PROC; + stream_info[THREADS_PER_STREAM] = proc_socket_table[0][HYPER_THREADING_PROC]; + streams_info_table.push_back(stream_info); + } + } else { + streams_info_table.push_back(stream_info); + } } + + return streams_info_table; } int get_model_prefer_threads(const int num_streams, diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp index db8baba4a18874..44d676014aad75 100644 --- a/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp +++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp @@ -50,7 +50,7 @@ std::vector> get_streams_info_table(const int input_streams, const int model_prefer_threads, const std::string input_perf_hint, const Config::LatencyThreadingMode latencyThreadingMode, - const std::vector> proc_type_table); + const std::vector>& proc_type_table); /** * @brief Get model_prefer_threads * @param[in] num_streams is target streams set by user via NUM_STREAMS or hints. diff --git a/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp b/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp index 42b81f5b715220..05ad350a5f67fa 100644 --- a/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp @@ -273,7 +273,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_4 = { false, ov::hint::PerformanceMode::LATENCY, {{12, 6, 0, 6, 0, 0}}, - {{1, MAIN_CORE_PROC, 12, 0, 0}}, + {{1, ALL_PROC, 12, 0, 0}, {0, MAIN_CORE_PROC, 6, 0, 0}, {0, HYPER_THREADING_PROC, 6, 0, 0}}, }; StreamGenerateionTestCase generation_latency_1sockets_14cores_5 = { @@ -365,7 +365,7 @@ StreamGenerateionTestCase generation_latency_2sockets_48cores_8 = { false, ov::hint::PerformanceMode::LATENCY, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, - {{1, MAIN_CORE_PROC, 48, -1, -1}}, + {{1, ALL_PROC, 48, -1, -1}, {0, MAIN_CORE_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 24, 1, 1}}, }; StreamGenerateionTestCase generation_latency_2sockets_48cores_9 = { @@ -388,7 +388,7 @@ StreamGenerateionTestCase generation_latency_2sockets_48cores_9 = { false, ov::hint::PerformanceMode::LATENCY, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, - {{1, MAIN_CORE_PROC, 48, -1, -1}}, + {{1, ALL_PROC, 48, -1, -1}, {0, MAIN_CORE_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 24, 1, 1}}, }; StreamGenerateionTestCase generation_tput_1sockets_14cores_2 = { diff --git a/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp b/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp index 7c7a96c1f26b35..b2587d82de217b 100644 --- a/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp @@ -61,9 +61,13 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_1 = { // simulation {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, - {104, 52, 0, 52, 1, 1}}, // param[in]: the proc_type_table in this simulation - {{1, MAIN_CORE_PROC, 208, -1, -1}}, // param[expected out]: the expected result of streams_info_table in this - // simulation + {104, 52, 0, 52, 1, 1}}, // param[in]: the proc_type_table in this simulation + {{1, ALL_PROC, 208, -1, -1}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, // param[expected out]: the expected result of streams_info_table in this + // simulation }; StreamsCalculationTestCase _2sockets_104cores_latency_platform_2 = { @@ -75,7 +79,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_2 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, -1, -1}}, + {{1, ALL_PROC, 104, -1, -1}, {0, MAIN_CORE_PROC, 52, 0, 0}, {0, MAIN_CORE_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_platform_3 = { 1, @@ -90,7 +94,15 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_3 = { {52, 26, 0, 26, 1, 0}, {52, 26, 0, 26, 2, 1}, {52, 26, 0, 26, 3, 1}}, - {{1, MAIN_CORE_PROC, 208, -1, -1}}, + {{1, ALL_PROC, 208, -1, -1}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}, + {0, HYPER_THREADING_PROC, 26, 0, 0}, + {0, HYPER_THREADING_PROC, 26, 1, 0}, + {0, HYPER_THREADING_PROC, 26, 2, 1}, + {0, HYPER_THREADING_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_platform_4 = { 1, @@ -100,8 +112,12 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_4 = { 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, - {{104, 104, 0, 0, -1, -1}, {26, 13, 0, 0, 0, 0}, {26, 13, 0, 0, 1, 0}, {26, 13, 0, 0, 2, 1}, {26, 13, 0, 0, 3, 1}}, - {{1, MAIN_CORE_PROC, 104, -1, -1}}, + {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, + {{1, ALL_PROC, 104, -1, -1}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_1 = { 1, @@ -112,7 +128,12 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_1 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, 0, 0}, {1, MAIN_CORE_PROC, 104, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {1, ALL_PROC, 104, 1, 1}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_2 = { 1, @@ -138,7 +159,16 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_3 = { {52, 26, 0, 26, 1, 0}, {52, 26, 0, 26, 2, 1}, {52, 26, 0, 26, 3, 1}}, - {{1, MAIN_CORE_PROC, 104, -1, 0}, {1, MAIN_CORE_PROC, 104, -1, 1}}, + {{1, ALL_PROC, 104, -1, 0}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, HYPER_THREADING_PROC, 26, 0, 0}, + {0, HYPER_THREADING_PROC, 26, 1, 0}, + {1, ALL_PROC, 104, -1, 1}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}, + {0, HYPER_THREADING_PROC, 26, 2, 1}, + {0, HYPER_THREADING_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_4 = { 1, @@ -148,8 +178,13 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_4 = { 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, - {{104, 104, 0, 0, -1, -1}, {26, 13, 0, 0, 0, 0}, {26, 13, 0, 0, 1, 0}, {26, 13, 0, 0, 2, 1}, {26, 13, 0, 0, 3, 1}}, - {{1, MAIN_CORE_PROC, 52, -1, 0}, {1, MAIN_CORE_PROC, 52, -1, 1}}, + {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, + {{1, ALL_PROC, 52, -1, 0}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {1, ALL_PROC, 52, -1, 1}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_5 = { 1, @@ -160,7 +195,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_5 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{60, 60, 0, 0, -1, -1}, {10, 10, 0, 0, 0, 0}, {10, 10, 0, 0, 1, 0}, {20, 20, 0, 0, 2, 1}, {20, 20, 0, 0, 3, 1}}, - {{1, MAIN_CORE_PROC, 40, -1, 1}}, + {{1, ALL_PROC, 40, -1, 1}, {0, MAIN_CORE_PROC, 20, 2, 1}, {0, MAIN_CORE_PROC, 20, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_6 = { 1, @@ -171,7 +206,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_6 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{60, 60, 0, 0, -1, -1}, {10, 10, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 1}, {10, 10, 0, 0, 2, 0}, {20, 20, 0, 0, 3, 1}}, - {{1, MAIN_CORE_PROC, 40, -1, 1}}, + {{1, ALL_PROC, 40, -1, 1}, {0, MAIN_CORE_PROC, 20, 1, 1}, {0, MAIN_CORE_PROC, 20, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_7 = { 1, @@ -181,8 +216,12 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_7 = { 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, - {{104, 104, 0, 0, -1, -1}, {26, 13, 0, 0, 0, 0}, {26, 13, 0, 0, 1, 0}, {26, 13, 0, 0, 2, 1}, {26, 13, 0, 0, 3, 1}}, - {{1, MAIN_CORE_PROC, 104, -1, -1}}, + {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, + {{1, ALL_PROC, 104, -1, -1}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_node_1 = { 1, @@ -193,7 +232,12 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_1 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, 0, 0}, {1, MAIN_CORE_PROC, 104, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {1, ALL_PROC, 104, 1, 1}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_node_2 = { 1, @@ -219,10 +263,18 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_3 = { {52, 26, 0, 26, 1, 0}, {52, 26, 0, 26, 2, 1}, {52, 26, 0, 26, 3, 1}}, - {{1, MAIN_CORE_PROC, 52, 0, 0}, - {1, MAIN_CORE_PROC, 52, 1, 0}, - {1, MAIN_CORE_PROC, 52, 2, 1}, - {1, MAIN_CORE_PROC, 52, 3, 1}}, + {{1, ALL_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, HYPER_THREADING_PROC, 26, 0, 0}, + {1, ALL_PROC, 52, 1, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, HYPER_THREADING_PROC, 26, 1, 0}, + {1, ALL_PROC, 52, 2, 1}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, HYPER_THREADING_PROC, 26, 2, 1}, + {1, ALL_PROC, 52, 3, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}, + {0, HYPER_THREADING_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_node_4 = { 1, @@ -232,7 +284,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_4 = { 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, - {{104, 104, 0, 0, -1, -1}, {26, 13, 0, 0, 0, 0}, {26, 13, 0, 0, 1, 0}, {26, 13, 0, 0, 2, 1}, {26, 13, 0, 0, 3, 1}}, + {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, {{1, MAIN_CORE_PROC, 26, 0, 0}, {1, MAIN_CORE_PROC, 26, 1, 0}, {1, MAIN_CORE_PROC, 26, 2, 1}, @@ -246,8 +298,12 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_5 = { 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, - {{104, 104, 0, 0, -1, -1}, {26, 13, 0, 0, 0, 0}, {26, 13, 0, 0, 1, 0}, {26, 13, 0, 0, 2, 1}, {26, 13, 0, 0, 3, 1}}, - {{1, MAIN_CORE_PROC, 104, -1, -1}}, + {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, + {{1, ALL_PROC, 104, -1, -1}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_1 = { 1, @@ -280,7 +336,11 @@ StreamsCalculationTestCase _2sockets_104cores_latency_3 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 208, -1, -1}}, + {{1, ALL_PROC, 208, -1, -1}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_4 = { 1, @@ -313,7 +373,11 @@ StreamsCalculationTestCase _2sockets_104cores_latency_6 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 208, -1, -1}}, + {{1, ALL_PROC, 208, -1, -1}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_1 = { 1, @@ -338,7 +402,12 @@ StreamsCalculationTestCase _2sockets_104cores_tput_2 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, 0, 0}, {1, MAIN_CORE_PROC, 104, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {1, ALL_PROC, 104, 1, 1}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_3 = { 1, @@ -403,8 +472,12 @@ StreamsCalculationTestCase _2sockets_104cores_tput_7 = { {6, MAIN_CORE_PROC, 8, 1, 1}, {6, HYPER_THREADING_PROC, 8, 0, 0}, {6, HYPER_THREADING_PROC, 8, 1, 1}, - {1, MAIN_CORE_PROC, 8, -1, -1}, - {1, HYPER_THREADING_PROC, 8, -1, -1}}, + {1, ALL_PROC, 8, -1, -1}, + {0, MAIN_CORE_PROC, 4, 0, 0}, + {0, MAIN_CORE_PROC, 4, 1, 1}, + {1, ALL_PROC, 8, -1, -1}, + {0, HYPER_THREADING_PROC, 4, 0, 0}, + {0, HYPER_THREADING_PROC, 4, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_7_1 = { 26, @@ -419,8 +492,12 @@ StreamsCalculationTestCase _2sockets_104cores_tput_7_1 = { {6, MAIN_CORE_PROC, 8, 1, 1}, {6, HYPER_THREADING_PROC, 8, 0, 0}, {6, HYPER_THREADING_PROC, 8, 1, 1}, - {1, MAIN_CORE_PROC, 8, -1, -1}, - {1, HYPER_THREADING_PROC, 8, -1, -1}}, + {1, ALL_PROC, 8, -1, -1}, + {0, MAIN_CORE_PROC, 4, 0, 0}, + {0, MAIN_CORE_PROC, 4, 1, 1}, + {1, ALL_PROC, 8, -1, -1}, + {0, HYPER_THREADING_PROC, 4, 0, 0}, + {0, HYPER_THREADING_PROC, 4, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_7_2 = { 1, @@ -435,18 +512,13 @@ StreamsCalculationTestCase _2sockets_104cores_tput_7_2 = { {52, 26, 0, 26, 1, 0}, {52, 26, 0, 26, 2, 1}, {52, 26, 0, 26, 3, 1}}, - {{6, MAIN_CORE_PROC, 4, 0, 0}, - {6, MAIN_CORE_PROC, 4, 1, 0}, - {6, MAIN_CORE_PROC, 4, 2, 1}, - {6, MAIN_CORE_PROC, 4, 3, 1}, - {6, HYPER_THREADING_PROC, 4, 0, 0}, - {6, HYPER_THREADING_PROC, 4, 1, 0}, - {6, HYPER_THREADING_PROC, 4, 2, 1}, - {6, HYPER_THREADING_PROC, 4, 3, 1}, - {1, MAIN_CORE_PROC, 4, -1, 0}, - {1, MAIN_CORE_PROC, 4, -1, 1}, - {1, HYPER_THREADING_PROC, 4, -1, 0}, - {1, HYPER_THREADING_PROC, 4, -1, 1}}, + {{6, MAIN_CORE_PROC, 4, 0, 0}, {6, MAIN_CORE_PROC, 4, 1, 0}, {6, MAIN_CORE_PROC, 4, 2, 1}, + {6, MAIN_CORE_PROC, 4, 3, 1}, {6, HYPER_THREADING_PROC, 4, 0, 0}, {6, HYPER_THREADING_PROC, 4, 1, 0}, + {6, HYPER_THREADING_PROC, 4, 2, 1}, {6, HYPER_THREADING_PROC, 4, 3, 1}, {1, ALL_PROC, 4, -1, 0}, + {0, MAIN_CORE_PROC, 2, 0, 0}, {0, MAIN_CORE_PROC, 2, 1, 0}, {1, ALL_PROC, 4, -1, 1}, + {0, MAIN_CORE_PROC, 2, 2, 1}, {0, MAIN_CORE_PROC, 2, 3, 1}, {1, ALL_PROC, 4, -1, 0}, + {0, HYPER_THREADING_PROC, 2, 0, 0}, {0, HYPER_THREADING_PROC, 2, 1, 0}, {1, ALL_PROC, 4, -1, 1}, + {0, HYPER_THREADING_PROC, 2, 2, 1}, {0, HYPER_THREADING_PROC, 2, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_8 = { 1, @@ -481,7 +553,12 @@ StreamsCalculationTestCase _2sockets_104cores_tput_10 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, 0, 0}, {1, MAIN_CORE_PROC, 104, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {1, ALL_PROC, 104, 1, 1}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_11 = { @@ -493,7 +570,12 @@ StreamsCalculationTestCase _2sockets_104cores_tput_11 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, 0, 0}, {1, MAIN_CORE_PROC, 104, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {1, ALL_PROC, 104, 1, 1}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_12 = { @@ -505,7 +587,12 @@ StreamsCalculationTestCase _2sockets_104cores_tput_12 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, MAIN_CORE_PROC, 104, 0, 0}, {1, MAIN_CORE_PROC, 104, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, + {0, MAIN_CORE_PROC, 52, 0, 0}, + {0, HYPER_THREADING_PROC, 52, 0, 0}, + {1, ALL_PROC, 104, 1, 1}, + {0, MAIN_CORE_PROC, 52, 1, 1}, + {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_13 = { @@ -565,7 +652,11 @@ StreamsCalculationTestCase _2sockets_104cores_tput_17 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, - {{6, MAIN_CORE_PROC, 8, 0, 0}, {6, MAIN_CORE_PROC, 8, 1, 1}, {1, MAIN_CORE_PROC, 8, -1, -1}}, + {{6, MAIN_CORE_PROC, 8, 0, 0}, + {6, MAIN_CORE_PROC, 8, 1, 1}, + {1, ALL_PROC, 8, -1, -1}, + {0, MAIN_CORE_PROC, 4, 0, 0}, + {0, MAIN_CORE_PROC, 4, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_18 = { @@ -613,7 +704,7 @@ StreamsCalculationTestCase _2sockets_48cores_latency_1 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, - {{1, MAIN_CORE_PROC, 48, -1, -1}}, + {{1, ALL_PROC, 48, -1, -1}, {0, MAIN_CORE_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 24, 1, 1}}, }; StreamsCalculationTestCase _2sockets_48cores_tput_1 = { @@ -697,7 +788,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_3 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, - {{1, MAIN_CORE_PROC, 12, 0, 0}}, + {{1, ALL_PROC, 12, 0, 0}, {0, MAIN_CORE_PROC, 6, 0, 0}, {0, HYPER_THREADING_PROC, 6, 0, 0}}, }; StreamsCalculationTestCase _1sockets_14cores_latency_4 = { @@ -814,7 +905,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_12 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, - {{1, MAIN_CORE_PROC, 12, 0, 0}}, + {{1, ALL_PROC, 12, 0, 0}, {0, MAIN_CORE_PROC, 6, 0, 0}, {0, HYPER_THREADING_PROC, 6, 0, 0}}, }; StreamsCalculationTestCase _1sockets_14cores_latency_13 = { @@ -931,7 +1022,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_3 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, - {{2, MAIN_CORE_PROC, 3, 0, 0}, {2, EFFICIENT_CORE_PROC, 3, 0, 0}}, + {{1, MAIN_CORE_PROC, 4, 0, 0}, {2, EFFICIENT_CORE_PROC, 4, 0, 0}, {1, HYPER_THREADING_PROC, 4, 0, 0}}, }; StreamsCalculationTestCase _1sockets_14cores_tput_4 = { @@ -1003,7 +1094,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_9 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, - {{2, MAIN_CORE_PROC, 3, 0, 0}, {2, EFFICIENT_CORE_PROC, 3, 0, 0}}, + {{1, MAIN_CORE_PROC, 4, 0, 0}, {2, EFFICIENT_CORE_PROC, 4, 0, 0}, {1, HYPER_THREADING_PROC, 4, 0, 0}}, }; StreamsCalculationTestCase _1sockets_14cores_tput_10 = { @@ -1015,7 +1106,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_10 = { "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, - {{2, MAIN_CORE_PROC, 3, 0, 0}, {2, EFFICIENT_CORE_PROC, 3, 0, 0}}, + {{1, MAIN_CORE_PROC, 4, 0, 0}, {2, EFFICIENT_CORE_PROC, 4, 0, 0}, {1, HYPER_THREADING_PROC, 4, 0, 0}}, }; StreamsCalculationTestCase _1sockets_14cores_tput_11 = { @@ -1126,7 +1217,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_3 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, - {{1, MAIN_CORE_PROC, 4, 0, 0}}, + {{1, ALL_PROC, 4, 0, 0}, {0, MAIN_CORE_PROC, 2, 0, 0}, {0, HYPER_THREADING_PROC, 2, 0, 0}}, }; StreamsCalculationTestCase _1sockets_10cores_latency_4 = { @@ -1291,7 +1382,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_3 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, - {{1, MAIN_CORE_PROC, 8, 0, 0}}, + {{1, ALL_PROC, 8, 0, 0}, {0, MAIN_CORE_PROC, 4, 0, 0}, {0, HYPER_THREADING_PROC, 4, 0, 0}}, }; StreamsCalculationTestCase _1sockets_8cores_latency_4 = { @@ -1450,7 +1541,7 @@ StreamsCalculationTestCase _1sockets_6cores_latency_1 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, - {{1, MAIN_CORE_PROC, 12, 0, 0}}, + {{1, ALL_PROC, 12, 0, 0}, {0, MAIN_CORE_PROC, 6, 0, 0}, {0, HYPER_THREADING_PROC, 6, 0, 0}}, }; StreamsCalculationTestCase _1sockets_6cores_latency_2 = { @@ -1462,7 +1553,7 @@ StreamsCalculationTestCase _1sockets_6cores_latency_2 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, - {{1, MAIN_CORE_PROC, 12, 0, 0}}, + {{1, ALL_PROC, 12, 0, 0}, {0, MAIN_CORE_PROC, 6, 0, 0}, {0, HYPER_THREADING_PROC, 6, 0, 0}}, }; StreamsCalculationTestCase _1sockets_6cores_latency_3 = { @@ -1570,7 +1661,7 @@ StreamsCalculationTestCase _1sockets_ecores_latency_4 = { "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, - {{1, EFFICIENT_CORE_PROC, 4, 0, 0}}, + {{1, EFFICIENT_CORE_PROC, 16, 0, 0}}, }; StreamsCalculationTestCase _1sockets_ecores_tput_1 = { From 0ed1749ad98b57f157ee767e94e243532d67d5e8 Mon Sep 17 00:00:00 2001 From: Sun Xiaoxia Date: Fri, 11 Aug 2023 06:38:21 +0000 Subject: [PATCH 35/51] [CPU] Removed socket id=-1 workaround on macOS (#18779) --- src/inference/src/dev/threading/cpu_streams_executor.cpp | 4 +--- src/inference/src/system_conf.cpp | 8 +++++++- src/plugins/intel_cpu/src/exec_network.cpp | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp index 0b22e913628ba7..2a45314f0ed9dd 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp @@ -133,9 +133,7 @@ struct CPUStreamsExecutor::Impl { const int concurrency, const int core_type, const int numa_node_id) { - _numaNodeId = (_impl->_usedNumaNodes.size() == 1 && _impl->_usedNumaNodes.at(0) == -1) - ? -1 // macOS - : std::max(0, numa_node_id); + _numaNodeId = std::max(0, numa_node_id); _socketId = get_socket_by_numa_node(_numaNodeId); if (stream_type == STREAM_WITHOUT_PARAM) { _taskArena.reset(new custom::task_arena{concurrency}); diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp index 16fe74bf754fa1..fcd018aa467029 100644 --- a/src/inference/src/system_conf.cpp +++ b/src/inference/src/system_conf.cpp @@ -247,7 +247,7 @@ int get_num_numa_nodes() { return cpu_info()._numa_nodes; } int get_num_sockets() { - return -1; + return cpu_info()._sockets; } void reserve_available_cpus(const std::vector> streams_info_table, std::vector>& stream_processors, @@ -255,6 +255,12 @@ void reserve_available_cpus(const std::vector> streams_info_tab void set_cpu_used(const std::vector& cpu_ids, const int used) {} int get_socket_by_numa_node(int numa_node_id) { + CPU& cpu = cpu_info(); + for (size_t i = 0; i < cpu._proc_type_table.size(); i++) { + if (cpu._proc_type_table[i][PROC_NUMA_NODE_ID] == numa_node_id) { + return cpu._proc_type_table[i][PROC_SOCKET_ID]; + } + } return -1; }; diff --git a/src/plugins/intel_cpu/src/exec_network.cpp b/src/plugins/intel_cpu/src/exec_network.cpp index 21ac20a2942f24..b779891df090fb 100644 --- a/src/plugins/intel_cpu/src/exec_network.cpp +++ b/src/plugins/intel_cpu/src/exec_network.cpp @@ -176,9 +176,7 @@ ExecNetwork::GraphGuard::Lock ExecNetwork::GetGraph() const { { std::lock_guard lock{*_mutex.get()}; // disable weights caching if graph was created only once - // "socketId != -1" is the WA for MacOS, will remove later - auto weightsCache = - (_cfg.streamExecutorConfig._streams != 1 && socketId != -1) ? _socketWeights[socketId] : nullptr; + auto weightsCache = _cfg.streamExecutorConfig._streams != 1 ? _socketWeights[socketId] : nullptr; auto isQuantizedFlag = (_cfg.lpTransformsMode == Config::On) && From 0a32ec0e76e195195a74bac18513c3c690186f72 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 11 Aug 2023 11:49:48 +0400 Subject: [PATCH 36/51] Fixed compilation with 32 bits (#19100) --- .../ngraph/runtime/reference/scatter_elements_update.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/reference/include/ngraph/runtime/reference/scatter_elements_update.hpp b/src/core/reference/include/ngraph/runtime/reference/scatter_elements_update.hpp index 3a4292144a9ebc..5b6a1fe4594d00 100644 --- a/src/core/reference/include/ngraph/runtime/reference/scatter_elements_update.hpp +++ b/src/core/reference/include/ngraph/runtime/reference/scatter_elements_update.hpp @@ -208,7 +208,8 @@ void scatter_elem_update_with_reduction(const DataType* input_data, std::inner_product(indices_cord.begin(), indices_cord.end(), indices_strides.begin(), uint64_t(0)); Coordinate out_cord(indices_cord); out_cord.at(axis) = normalize_index(indices[indices_offset], data_shape[axis]); - const auto out_offset = std::inner_product(out_cord.begin(), out_cord.end(), data_strides.begin(), uint64_t(0)); + const size_t out_offset = + std::inner_product(out_cord.begin(), out_cord.end(), data_strides.begin(), uint64_t(0)); idx_to_output_element.push_back({indices_offset, out_offset}); } From 85609d48813ea43f4470ea27404e31a14f306fa2 Mon Sep 17 00:00:00 2001 From: Yuan Hu Date: Fri, 11 Aug 2023 15:53:07 +0800 Subject: [PATCH 37/51] [Core] fix Memory Leak caused by create/inference request consequently in separate thread (#18868) * try to fix memory issue Signed-off-by: HU Yuan2 * save code Signed-off-by: Hu Yuan2 * fix life cycle issue Signed-off-by: Hu Yuan2 * update comment and save stream of master thread in tbb ThreadLocal Signed-off-by: Hu Yuan2 * update Signed-off-by: Hu Yuan2 * not save the main stream in tbb Signed-off-by: Hu Yuan2 * remote test code and update comment Signed-off-by: Hu Yuan2 * fix mistaken modify Signed-off-by: Hu Yuan2 * fix format issue Signed-off-by: Hu Yuan2 * add test Signed-off-by: HU Yuan2 * improve test Signed-off-by: HU Yuan2 * fix the test Signed-off-by: Hu Yuan2 * remote unused code Signed-off-by: Hu Yuan2 * update the comment of the code Signed-off-by: Hu Yuan2 * fix format issue Signed-off-by: Hu Yuan2 * revert test case Signed-off-by: Hu Yuan2 --------- Signed-off-by: HU Yuan2 Signed-off-by: Hu Yuan2 --- .../dev/threading/cpu_streams_executor.cpp | 73 +++++++++++++++++-- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp index 2a45314f0ed9dd..d43d3b1bba46fc 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -21,6 +22,8 @@ namespace ov { namespace threading { +// maybe there are two CPUStreamsExecutors in the same thread. +thread_local std::map> t_stream_count_map; struct CPUStreamsExecutor::Impl { struct Stream { #if OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO @@ -310,12 +313,71 @@ struct CPUStreamsExecutor::Impl { std::vector _cpu_ids; #endif }; + // if the thread is created by CPUStreamsExecutor, the Impl::Stream of the thread is stored by tbb Class + // enumerable_thread_specific, the alias is ThreadLocal, the limitations of ThreadLocal please refer to + // https://spec.oneapi.io/versions/latest/elements/oneTBB/source/thread_local_storage/enumerable_thread_specific_cls.html + // if the thread is created by customer, the Impl::Stream of the thread will be stored in variable _stream_map, and + // will be counted by thread_local t_stream_count_map. + // when the customer's thread is destoryed, the stream's count will became 1, + // Call local() will reuse one of them, and release others. + class CustomThreadLocal : public ThreadLocal> { + public: + CustomThreadLocal(std::function()> callback_construct, Impl* impl) + : ThreadLocal>(callback_construct), + _impl(impl) {} + std::shared_ptr local() { + auto id = std::this_thread::get_id(); + auto search = _thread_ids.find(id); + if (search != _thread_ids.end()) { + return ThreadLocal>::local(); + } + std::lock_guard guard(_stream_map_mutex); + for (auto& item : _stream_map) { + if (*(item.first.get()) == id) { + t_stream_count_map[(void*)this] = item.first; + return item.second; + } + } + std::shared_ptr stream = nullptr; + for (auto it = _stream_map.begin(); it != _stream_map.end();) { + if (it->first.use_count() == 1) { + if (stream == nullptr) { + stream = it->second; + } + _stream_map.erase(it++); + } else { + it++; + } + } + if (stream == nullptr) { + stream = std::make_shared(_impl); + } + auto id_ptr = std::make_shared(id); + t_stream_count_map[(void*)this] = id_ptr; + _stream_map[id_ptr] = stream; + return stream; + } + + void set_thread_ids_map(std::vector& threads) { + for (auto& thread : threads) { + _thread_ids.insert(thread.get_id()); + } + } + + private: + std::set _thread_ids; + Impl* _impl; + std::map, std::shared_ptr> _stream_map; + std::mutex _stream_map_mutex; + }; explicit Impl(const Config& config) : _config{config}, - _streams([this] { - return std::make_shared(this); - }) { + _streams( + [this] { + return std::make_shared(this); + }, + this) { _exectorMgr = executor_manager(); auto numaNodes = get_available_numa_nodes(); if (_config._streams != 0) { @@ -376,6 +438,7 @@ struct CPUStreamsExecutor::Impl { } }); } + _streams.set_thread_ids_map(_threads); } void Enqueue(Task task) { @@ -425,7 +488,7 @@ struct CPUStreamsExecutor::Impl { std::queue _taskQueue; bool _isStopped = false; std::vector _usedNumaNodes; - ThreadLocal> _streams; + CustomThreadLocal _streams; #if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO) // stream id mapping to the core type // stored in the reversed order (so the big cores, with the highest core_type_id value, are populated first) From 2a3132941c39a4eff645b33ddd82bb0a23a293e8 Mon Sep 17 00:00:00 2001 From: Anton Voronov Date: Fri, 11 Aug 2023 12:10:00 +0400 Subject: [PATCH 38/51] [FIX][CPU] Convert CF: added convert childs number check (#19022) * [FIX][CPU] Convert CF: added convert childs number check * code style fix * WIP: [CPU][TESTS] Convert CF: Added subgraph test with two outputs for Convert node * MatMulDecompressConvertTest refactoring + instances fixes * removed KeepConstAndDecompressionForMatMul pass and added cpu callback for KeepConstAndDecompression * MatMulDecompressConvertTest2: added graphs and small problem description * small review fix --- ...decompression_convert_constant_folding.hpp | 12 - ...decompression_convert_constant_folding.cpp | 29 +- .../transformation_pipeline.cpp | 11 +- .../src/matmul_decompress_convert.cpp | 253 ++++++++++++++---- 4 files changed, 208 insertions(+), 97 deletions(-) diff --git a/src/common/transformations/include/transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp b/src/common/transformations/include/transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp index b85eff6d575bde..29d335b0db1c06 100644 --- a/src/common/transformations/include/transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp +++ b/src/common/transformations/include/transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp @@ -14,7 +14,6 @@ namespace pass { class TRANSFORMATIONS_API EnableDecompressionConvertConstantFolding; class TRANSFORMATIONS_API DisableDecompressionConvertConstantFolding; class TRANSFORMATIONS_API KeepConstAndDecompression; -class TRANSFORMATIONS_API KeepConstAndDecompressionForMatMul; } // namespace pass } // namespace ov @@ -48,14 +47,3 @@ class ov::pass::KeepConstAndDecompression : public MatcherPass { OPENVINO_RTTI("KeepConstAndDecompression", "0"); KeepConstAndDecompression(); }; - -/** - * @ingroup ie_transformation_common_api - * @brief Disables ConstantFolding for Convert operation (just before MatMul operation only) and prevents conversion - * of f16 Consts to f32. - */ -class ov::pass::KeepConstAndDecompressionForMatMul : public MatcherPass { -public: - OPENVINO_RTTI("KeepConstAndDecompressionForMatMul", "0"); - KeepConstAndDecompressionForMatMul(); -}; diff --git a/src/common/transformations/src/transformations/fp16_compression/mark_decompression_convert_constant_folding.cpp b/src/common/transformations/src/transformations/fp16_compression/mark_decompression_convert_constant_folding.cpp index ad84d5a4f637a6..de03d931ac47cc 100644 --- a/src/common/transformations/src/transformations/fp16_compression/mark_decompression_convert_constant_folding.cpp +++ b/src/common/transformations/src/transformations/fp16_compression/mark_decompression_convert_constant_folding.cpp @@ -59,6 +59,10 @@ pass::KeepConstAndDecompression::KeepConstAndDecompression() { ov::is_shape_subgraph(node->shared_from_this())) return false; + if (transformation_callback(node)) { + return false; + } + disable_constant_folding(node); if (!is_type(node->input_value(0).get_node_shared_ptr())) @@ -70,28 +74,3 @@ pass::KeepConstAndDecompression::KeepConstAndDecompression() { auto m = std::make_shared(node_pattern, matcher_name); register_matcher(m, callback); } - -pass::KeepConstAndDecompressionForMatMul::KeepConstAndDecompressionForMatMul() { - MATCHER_SCOPE(KeepConstAndDecompressionForMatMul); - auto matmul = pass::pattern::wrap_type(); - - matcher_pass_callback callback = [=](pass::pattern::Matcher& m) { - auto node = m.get_match_root(); - - // input to matmul is decompression Convert - const auto& inp_convert = node->input_value(1).get_node_shared_ptr(); - if (!is_type(inp_convert) || !is_decompression(inp_convert)) - return false; - - disable_constant_folding(inp_convert); - - if (!is_type(inp_convert->input_value(0).get_node_shared_ptr())) - return false; - enable_keep_fp16_const(inp_convert->input_value(0).get_node_shared_ptr()); - - return false; - }; - - auto m = std::make_shared(matmul, matcher_name); - this->register_matcher(m, callback); -} diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index f8356a8f793e76..560a141c52745e 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -203,7 +203,14 @@ void Transformations::PreLpt(const std::vector& defaultPrecis manager.set_per_pass_validation(false); CPU_REGISTER_PASS_COMMON(manager, ov::pass::InitNodeInfo); CPU_REGISTER_PASS_COMMON(manager, ov::pass::MarkShapeOfSubgraphs); - CPU_REGISTER_PASS_COMMON(manager, ov::pass::KeepConstAndDecompressionForMatMul); + + CPU_REGISTER_PASS_COMMON(manager, ov::pass::KeepConstAndDecompression); + CPU_SET_CALLBACK_COMMON(manager, + [](const_node_ptr &node) -> bool { + const auto outputs = node->get_output_target_inputs(0); + return outputs.size() != 1 || !is_type(outputs.begin()->get_node()); + }, + ov::pass::KeepConstAndDecompression); const bool useLpt = !defaultPrecisions.empty(); if (useLpt) { @@ -434,7 +441,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis AUGRUCell node (see AUGRUCellFusion pass). In such cases, some constant paths will be unfolded, which can lead to crashes in the plugin. To avoid this, we re-mark decompression converts again and finally do CF for those constant paths that are not inputs to MatMul node */ CPU_REGISTER_PASS_COMMON(manager, ov::pass::EnableDecompressionConvertConstantFolding); - CPU_REGISTER_PASS_COMMON(manager, ov::pass::KeepConstAndDecompressionForMatMul); + CPU_REGISTER_PASS_COMMON(manager, ov::pass::KeepConstAndDecompression); CPU_REGISTER_PASS_COMMON(manager, ov::pass::ConstantFolding); manager.run_passes(model); diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp index bc2082d98366f0..d61280efc5ec9e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp @@ -140,7 +140,7 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface std::string { auto it = rtInfo.find(paramName); IE_ASSERT(rtInfo.end() != it); @@ -153,7 +153,7 @@ class MatMulDecompressConvertTest : public testing::WithParamInterfaceget_rt_info(), ExecGraphInfoSerialization::LAYER_TYPE) == "FullyConnected") { const auto &constNode = fcNode->get_input_node_shared_ptr(1); element::Type expectedType(getExecValue(constNode->get_rt_info(), ExecGraphInfoSerialization::OUTPUT_PRECISIONS)); - ASSERT_EQ(expectedType, weiConstElemType); + ASSERT_EQ(expectedType, expectedWeiElemType); } } } @@ -163,6 +163,7 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface inputShapes; std::pair transpose; + ElementType weiConstElemType; std::map additionalConfig; CPUSpecificParams cpuParams; @@ -174,8 +175,8 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface(inputB, convertOutType); mark_as_decompression(inputB); } + expectedWeiConstElemType = weiConstElemType; + auto matMul = builder::makeMatMul(paramOuts[0], inputB, transpA, transpB); function = CPUTestsBase::makeNgraphFunction(netType, params, matMul, cpuNodeType); @@ -221,15 +224,16 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface> inputShapes3D = { }, }; - -std::vector> filterAdditionalConfig() { - std::vector> additionalConfig; -#ifndef OV_CPU_WITH_MLAS - additionalConfig.push_back(std::map{/* empty config */}); -#endif - return additionalConfig; -} +std::map emptyConfig = {/* empty config */}; std::vector> filterAdditionalConfig_BF16() { std::vector> additionalConfig; @@ -290,23 +287,25 @@ std::vector> filterAdditionalConfig_BF16() { return additionalConfig; } -std::vector> filterAdditionalConfig_MLAS() { - std::vector> additionalConfig; - additionalConfig.push_back(std::map{/* empty config */}); - return additionalConfig; -} - -std::vector filterSpecificParams() { +std::vector filterSpecificParams(bool trySetMlas) { std::vector specificParams; - if (with_cpu_x86_avx512_core()) { - specificParams.push_back(CPUSpecificParams{{}, {}, {"brgemm_avx512"}, "brgemm_avx512"}); - } else if (with_cpu_x86_avx2()) { - specificParams.push_back(CPUSpecificParams{{}, {}, {"brgemm_avx2"}, "brgemm_avx2"}); + if (trySetMlas) { +#ifdef OV_CPU_WITH_MLAS + specificParams.push_back(CPUSpecificParams{{}, {}, {"gemm_mlas"}, "gemm_mlas"}); +#endif + } + // try set onednn jit params if we can't or shouldn't use mlas + if (specificParams.empty()) { + if (with_cpu_x86_avx512_core()) { + specificParams.push_back(CPUSpecificParams{{}, {}, {"brgemm_avx512"}, "brgemm_avx512"}); + } else if (with_cpu_x86_avx2()) { + specificParams.push_back(CPUSpecificParams{{}, {}, {"brgemm_avx2"}, "brgemm_avx2"}); + } } + return specificParams; } - std::vector filterSpecificParams_BF16() { std::vector specificParams; specificParams.push_back(CPUSpecificParams{{}, {}, {"jit_gemm"}, "jit_gemm"}); @@ -314,34 +313,25 @@ std::vector filterSpecificParams_BF16() { } -std::vector filterSpecificParams_MLAS() { - std::vector specificParams; - specificParams.push_back(CPUSpecificParams{{}, {}, {"gemm_mlas"}, "gemm_mlas"}); - return specificParams; -} - - -#ifdef OV_CPU_WITH_MLAS -const auto testParams2D_MLAS_smoke = ::testing::Combine( +const auto testParams2D_FP32_smoke = ::testing::Combine( ::testing::ValuesIn(inputShapes2D), ::testing::ValuesIn(transposeParams), ::testing::Values(ElementType::f32), - ::testing::ValuesIn(filterAdditionalConfig_MLAS()), - ::testing::ValuesIn(filterSpecificParams_MLAS())); + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filterSpecificParams(true))); -INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_MLAS, MatMulDecompressConvertTest, testParams2D_MLAS_smoke, +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP32, MatMulDecompressConvertTest, testParams2D_FP32_smoke, MatMulDecompressConvertTest::getTestCaseName); -#endif -const auto testParams2D_smoke = ::testing::Combine( +const auto testParams2D_FP16_smoke = ::testing::Combine( ::testing::ValuesIn(inputShapes2D), ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f32, ElementType::f16), - ::testing::ValuesIn(filterAdditionalConfig()), - ::testing::ValuesIn(filterSpecificParams())); + ::testing::Values(ElementType::f16), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filterSpecificParams(false))); -INSTANTIATE_TEST_SUITE_P(smoke_FC_2D, MatMulDecompressConvertTest, testParams2D_smoke, +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP16, MatMulDecompressConvertTest, testParams2D_FP16_smoke, MatMulDecompressConvertTest::getTestCaseName); @@ -356,27 +346,25 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_BF16, MatMulDecompressConvertTest, testPara MatMulDecompressConvertTest::getTestCaseName); -#ifdef OV_CPU_WITH_MLAS -const auto testParams3D_MLAS_smoke = ::testing::Combine( +const auto testParams3D_FP32_smoke = ::testing::Combine( ::testing::ValuesIn(inputShapes3D), ::testing::ValuesIn(transposeParams), ::testing::Values(ElementType::f32), - ::testing::ValuesIn(filterAdditionalConfig_MLAS()), - ::testing::ValuesIn(filterSpecificParams_MLAS())); + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filterSpecificParams(true))); -INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_MLAS, MatMulDecompressConvertTest, testParams3D_MLAS_smoke, +INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP32, MatMulDecompressConvertTest, testParams3D_FP32_smoke, MatMulDecompressConvertTest::getTestCaseName); -#endif -const auto testParams3D_smoke = ::testing::Combine( +const auto testParams3D_FP16_smoke = ::testing::Combine( ::testing::ValuesIn(inputShapes3D), ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f32, ElementType::f16), - ::testing::ValuesIn(filterAdditionalConfig()), - ::testing::ValuesIn(filterSpecificParams())); + ::testing::Values(ElementType::f16), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filterSpecificParams(false))); -INSTANTIATE_TEST_SUITE_P(smoke_FC_3D, MatMulDecompressConvertTest, testParams3D_smoke, +INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP16, MatMulDecompressConvertTest, testParams3D_FP16_smoke, MatMulDecompressConvertTest::getTestCaseName); @@ -392,4 +380,153 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_BF16, MatMulDecompressConvertTest, testPara } // namespace + +/* In case of Convert has 2 or more consumers there is a problem with memory allocation in CPU plug-in (see Edge::init() method). + Maybe we can just remove the check (edgePtr->getParent()->isConstant() && !edgePtr->getChild()->isConstant()) and everything will be OK, + But this solution should be additionally checked. For now, for these cases we will not be doing CF on the CPU side and it should be done + on the ngraph side. + + * Graph before: + ------------ ------------ ------------ + |Input(f32)| |Input(f16)| |Input(f32)| + ------------ ------------ ------------ + | | | + | --------------------------------- | + | |Convert(decompression f16->f32)| | + | --------------------------------- | + | | | | + ----------------------- ----------------------- + | MatMul | | MatMul | + ----------------------- ----------------------- + | | + --------------------------------- + | Concat | + --------------------------------- + | + -------- + |Output| + -------- + + * Exec graph: + ------------ -------------------------------- ------------ + |Input(f32)| | Input(f32) | |Input(f32)| + ------------ -------------------------------- ------------ + | | | | + ----------------------- ----------------------- + | MatMul | | MatMul | + ----------------------- ----------------------- + | | + --------------------------------- + | Concat | + --------------------------------- + | + -------- + |Output| + -------- +*/ +using MatMulDecompressConvertParams2 = std::tuple< + std::vector, // input shapes + std::pair, // transposeA, transposeB + ElementType, // weights precision + std::map, // additional config + CPUSpecificParams +>; + +class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { +protected: + void SetUp() override { + targetDevice = ov::test::utils::DEVICE_CPU; + + std::vector inputShapes; + std::pair transpose; + ElementType weiConstElemType; + std::map additionalConfig; + CPUSpecificParams cpuParams; + + std::tie(inputShapes, transpose, weiConstElemType, additionalConfig, cpuParams) = this->GetParam(); + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + + init_input_shapes(inputShapes); + + bool transpA = transpose.first; + bool transpB = transpose.second; + + fullyConnectedCount = 2; + if (transpA) transposeCount += 2; + if (!transpB) transposeCount++; + + if (transpA) { + transposeShape(inputDynamicShapes[0]); + for (auto& shapes : targetStaticShapes) { + transposeShape(shapes[0]); + } + transposeShape(inputDynamicShapes[1]); + for (auto& shapes : targetStaticShapes) { + transposeShape(shapes[1]); + } + } + if (transpB) { + transposeShape(inputDynamicShapes[2]); + for (auto& shapes : targetStaticShapes) { + transposeShape(shapes[2]); + } + } + + const auto& inShapeFC0 = inputDynamicShapes[0]; + const auto& inShapeFC1 = inputDynamicShapes[1]; + const auto& inShapeWeights = inputDynamicShapes[2]; + + configuration.insert(additionalConfig.begin(), additionalConfig.end()); + + ElementType netType = ElementType::f32; + ElementType convertOutType = ElementType::f32; + if (additionalConfig[PluginConfigParams::KEY_ENFORCE_BF16] == PluginConfigParams::YES) { + convertOutType = inType = outType = netType = ElementType::bf16; + weiConstElemType = (weiConstElemType != ElementType::f32) ? weiConstElemType : ElementType::bf16; + } else { + inType = outType = netType; + } + + std::string cpuNodeType = "FullyConnected"; + selectedType = makeSelectedTypeStr(selectedType, outType); + + auto params = builder::makeDynamicParams(inType, {inShapeFC0, inShapeFC1}); + auto paramOuts = helpers::convert2OutputVector(helpers::castOps2Nodes(params)); + std::shared_ptr inputWeights = builder::makeConstant(weiConstElemType, inShapeWeights.get_shape(), {}, true); + if (weiConstElemType == ElementType::f16) { + inputWeights = std::make_shared(inputWeights, convertOutType); + mark_as_decompression(inputWeights); + } + // In this test, convert must be folded on the ngraph side, so the constant with fp32 precision is expected + expectedWeiConstElemType = ElementType::f32; + + auto matMul0 = builder::makeMatMul(paramOuts[0], inputWeights, transpA, transpB); + auto matMul1 = builder::makeMatMul(paramOuts[1], inputWeights, transpA, transpB); + + auto concat = builder::makeConcat({matMul0, matMul1}, 0); + + function = CPUTestsBase::makeNgraphFunction(netType, params, concat, cpuNodeType); + } +}; + +TEST_P(MatMulDecompressConvertTest2, CompareWithRefs) { + SKIP_IF_CURRENT_TEST_IS_DISABLED(); + run(); + CheckExecutionGraph(); +} + +namespace { + +const auto testParams2D_FP16_2_smoke = ::testing::Combine( + ::testing::Values(static_shapes_to_test_representation({{2, 3}, {2, 3}, {3, 4}})), + ::testing::Values(std::pair{false, true}), + ::testing::Values(ElementType::f16), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filterSpecificParams(true))); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP16_2, MatMulDecompressConvertTest2, testParams2D_FP16_2_smoke, + MatMulDecompressConvertTest2::getTestCaseName); + +} // namespace + } // namespace SubgraphTestsDefinitions From c1c4c4cd513344d1f65957d2310a101c2059fd2d Mon Sep 17 00:00:00 2001 From: Mingyu Kim Date: Fri, 11 Aug 2023 17:41:41 +0900 Subject: [PATCH 39/51] [GPU] Onednn version update to latest 3.2 (#19135) --- src/plugins/intel_gpu/thirdparty/onednn_gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_gpu/thirdparty/onednn_gpu b/src/plugins/intel_gpu/thirdparty/onednn_gpu index 25575c2d20a988..4b82a66ed38eca 160000 --- a/src/plugins/intel_gpu/thirdparty/onednn_gpu +++ b/src/plugins/intel_gpu/thirdparty/onednn_gpu @@ -1 +1 @@ -Subproject commit 25575c2d20a9885640c89771c99a0d27b5444b4d +Subproject commit 4b82a66ed38ecaa993352e5cc6ed7753656b8a26 From cc08b0091e99f25ca60457231ed8f508423a89ab Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Fri, 11 Aug 2023 10:46:04 +0200 Subject: [PATCH 40/51] [PT FE] Remove torch strides compensation (#19129) --- .../openvino/frontend/pytorch/fx_decoder.py | 22 ------------------- .../openvino/frontend/pytorch/ts_decoder.py | 16 -------------- .../src/openvino/frontend/pytorch/utils.py | 7 +----- .../pyopenvino/frontend/pytorch/decoder.hpp | 8 ------- .../openvino/frontend/pytorch/decoder.hpp | 6 ----- .../pytorch/src/translate_session.cpp | 18 --------------- src/frontends/pytorch/src/utils.hpp | 6 ----- .../pytorch_tests/pytorch_layer_test_class.py | 2 +- .../pytorch_tests/test_quantized_convnd.py | 11 +++------- 9 files changed, 5 insertions(+), 91 deletions(-) diff --git a/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py index 47ee16d8282324..dfa795b5d0fe22 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py @@ -154,28 +154,6 @@ def get_type_for_value(self, value): else: return OVAny(OVType.f32) - def get_input_transpose_order(self, index): - return [] - # TODO TBD - - input = self._raw_input(index) - if input.type() is not None and input.type().kind() == 'TensorType': - strides = input.type().strides() - if strides is not None: - return [s[0] for s in sorted(enumerate(strides), key=lambda x:x[1], reverse=True)] - return [] - - def get_output_transpose_order(self, index): - return [] - - # old code - output = self._raw_output(index) - if output.type() is not None and output.type().kind() == 'TensorType': - strides = output.type().strides() - if strides is not None: - return [s[0] for s in sorted(enumerate(strides), key=lambda x:x[1], reverse=True)] - return [] - def get_subgraph_size(self): if issubclass(type(self.pt_module), torch.fx.Node): return 0 diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py index 1090dce0163ced..da4942bb5a720e 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py @@ -261,22 +261,6 @@ def get_type_for_value(self, value: torch.Value): full_type = self._get_known_type_for_value(value.type()) return full_type - def get_input_transpose_order(self, index: int) -> list: - raw_input = self._raw_input(index) - if raw_input.type() is not None and raw_input.type().kind() == "TensorType": - strides = raw_input.type().strides() - if strides is not None: - return [s[0] for s in sorted(enumerate(strides), key=lambda x:x[1], reverse=True)] - return [] - - def get_output_transpose_order(self, index: int) -> list: - output = self._raw_output(index) - if output.type() is not None and output.type().kind() == "TensorType": - strides = output.type().strides() - if strides is not None: - return [s[0] for s in sorted(enumerate(strides), key=lambda x:x[1], reverse=True)] - return [] - def get_subgraph_size(self) -> int: if isinstance(self.graph_element, torch.Node): return len(self.get_subgraphs()) diff --git a/src/bindings/python/src/openvino/frontend/pytorch/utils.py b/src/bindings/python/src/openvino/frontend/pytorch/utils.py index 0e7ffd66780c61..3c658119bb1c2a 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/utils.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/utils.py @@ -56,20 +56,15 @@ def get_type_from_py_type(value): def torch_tensor_to_ov_const(torch_t: torch.Tensor, shared_memory=True): - torch_t = torch_t.to(memory_format=torch.contiguous_format) + torch_t = torch_t.contiguous() if torch_t.dtype == torch.bfloat16: # reinterpret bfloat16 data as float16 to allow conversion to numpy torch_t = torch_t.view(torch.float16) narr = torch_t.numpy(force=True) - if not narr.flags['C_CONTIGUOUS']: - narr = np.ascontiguousarray(narr) - # TODO: this tensor doesn't share memory with initial tensor tensor = Tensor(narr, torch_t.shape, OVType.bf16) ov_const = op.Constant(tensor, shared_memory=shared_memory) else: narr = torch_t.numpy(force=True) - if not narr.flags['C_CONTIGUOUS']: - narr = np.ascontiguousarray(narr) ov_const = op.Constant(narr, shared_memory=shared_memory) return ov_const diff --git a/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp b/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp index 4b32c1b6b0d4e4..004fc19b209ca3 100644 --- a/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp +++ b/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp @@ -38,10 +38,6 @@ class PyDecoder : public ov::frontend::pytorch::TorchDecoder { PYBIND11_OVERRIDE_PURE(ov::Any, TorchDecoder, get_input_type, index); } - const std::vector& get_input_transpose_order(size_t index) const override { - PYBIND11_OVERRIDE_PURE(const std::vector&, TorchDecoder, get_input_transpose_order, index); - } - const std::string& get_output_debug_name(size_t index) const override { PYBIND11_OVERRIDE_PURE(const std::string&, TorchDecoder, get_output_debug_name, index); } @@ -54,10 +50,6 @@ class PyDecoder : public ov::frontend::pytorch::TorchDecoder { PYBIND11_OVERRIDE_PURE(ov::Any, TorchDecoder, get_output_type, index); } - const std::vector& get_output_transpose_order(size_t index) const override { - PYBIND11_OVERRIDE_PURE(const std::vector&, TorchDecoder, get_output_transpose_order, index); - } - bool input_is_none(size_t index) const override { PYBIND11_OVERRIDE_PURE(bool, TorchDecoder, input_is_none, index); } diff --git a/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp b/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp index 21517bea278555..abab389a9c4ccc 100644 --- a/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp +++ b/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp @@ -44,9 +44,6 @@ class TorchDecoder : public IDecoder { // (see custom_type.hpp) virtual Any get_input_type(size_t index) const = 0; - // TODO: Consider deleting this method, probably it doesn't make sence outside Torch JIT execution - virtual const std::vector& get_input_transpose_order(size_t index) const = 0; - // Return debug name of the input tensor virtual const std::string& get_output_debug_name(size_t index) const = 0; @@ -56,9 +53,6 @@ class TorchDecoder : public IDecoder { // Return element::Type when it the original type can be represented, otherwise returns PT-specific data type object // (see custom_type.hpp) virtual Any get_output_type(size_t index) const = 0; - - // TODO: Consider deleting this method, probably it doesn't make sence outside Torch JIT execution - virtual const std::vector& get_output_transpose_order(size_t index) const = 0; // ------------------------------ // TODO: required? can be implemented in the context of a single node? diff --git a/src/frontends/pytorch/src/translate_session.cpp b/src/frontends/pytorch/src/translate_session.cpp index 894b6bd3f15c20..c075373f01717a 100644 --- a/src/frontends/pytorch/src/translate_session.cpp +++ b/src/frontends/pytorch/src/translate_session.cpp @@ -118,20 +118,6 @@ std::shared_ptr TranslateSession::convert_pytorch_model( encode_tensor_name(parameter->output(0), inputs.at(i), {pytorch_model->get_input_debug_name(i)}); parameters->push_back(parameter); input_node = parameter; - auto order = pytorch_model->get_input_transpose_order(i); - if (order.size() > 0 && !std::is_sorted(order.begin(), order.end())) { - FRONT_END_GENERAL_CHECK(pshape.is_static(), "Shape must be static."); // TODO: make dynamic - auto sh = pshape.get_shape(); - Shape new_shape(sh.size()); - for (size_t i = 0; i < sh.size(); i++) { - new_shape[order[i]] = sh[i]; - } - auto shape_const = v0::Constant::create(element::i32, {new_shape.size()}, new_shape); - auto reshape = std::make_shared(parameter, shape_const, false); - auto order_const = v0::Constant::create(element::i32, {order.size()}, order); - auto transpose = std::make_shared(reshape, order_const); - input_node = transpose; - } } (*tensor_map)[inputs.at(i)] = input_node; } @@ -167,7 +153,6 @@ std::shared_ptr TranslateSession::convert_pytorch_model( dtype = type.as(); } auto parameter = std::make_shared(dtype, ps); - // TODO: Missing get_input_transpose_order handling for not trivial layouts (*tensor_map)[input] = parameter; // set name of parameter to the index of node in the model encode_tensor_name(parameter->output(0), input); @@ -240,9 +225,6 @@ std::shared_ptr TranslateSession::convert_pytorch_model( (*tensor_map)[id] = parameter; } auto ov_output = tensor_map->at(id); - auto order = pytorch_model->get_output_transpose_order(i); - FRONT_END_GENERAL_CHECK(order.size() == 0 || std::is_sorted(order.begin(), order.end()), - "Output strides have wrong order."); FRONT_END_GENERAL_CHECK(ov_output.get_names().size() > 0, "Tensor doesn't have name, while it should have name: ", id); diff --git a/src/frontends/pytorch/src/utils.hpp b/src/frontends/pytorch/src/utils.hpp index 565476e7974ad8..376ce0277689f8 100644 --- a/src/frontends/pytorch/src/utils.hpp +++ b/src/frontends/pytorch/src/utils.hpp @@ -161,9 +161,6 @@ class DummyDecoder : public TorchDecoder { virtual Any get_input_type(size_t index) const override { FRONT_END_NOT_IMPLEMENTED(get_input_type); } - virtual const std::vector& get_input_transpose_order(size_t index) const override { - FRONT_END_NOT_IMPLEMENTED(get_input_transpose_order); - } virtual const std::string& get_output_debug_name(size_t index) const override { FRONT_END_NOT_IMPLEMENTED(get_output_debug_name); } @@ -173,9 +170,6 @@ class DummyDecoder : public TorchDecoder { virtual Any get_output_type(size_t index) const override { FRONT_END_NOT_IMPLEMENTED(get_output_type); } - virtual const std::vector& get_output_transpose_order(size_t index) const override { - FRONT_END_NOT_IMPLEMENTED(get_output_transpose_order); - } virtual bool input_is_none(size_t index) const override { FRONT_END_NOT_IMPLEMENTED(input_is_none); } diff --git a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py index 851036c03061fb..68bad824d7d24d 100644 --- a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py +++ b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py @@ -136,7 +136,7 @@ def use_torch_compile_backend(): assert 'quant_size' in kwargs, "quant size must be specified for quantized_ops flag" quant_size = kwargs['quant_size'] for i in range(len(infer_res)): - cur_fw_res = flatten_fw_res[i].to(memory_format=torch.contiguous_format).numpy( + cur_fw_res = flatten_fw_res[i].contiguous().numpy( ) if isinstance(flatten_fw_res[i], torch.Tensor) else flatten_fw_res[i] if np.array(cur_fw_res).size == 0: continue diff --git a/tests/layer_tests/pytorch_tests/test_quantized_convnd.py b/tests/layer_tests/pytorch_tests/test_quantized_convnd.py index 45ef28c47ce18f..e0caaa31c4fa48 100644 --- a/tests/layer_tests/pytorch_tests/test_quantized_convnd.py +++ b/tests/layer_tests/pytorch_tests/test_quantized_convnd.py @@ -41,7 +41,7 @@ def forward(self, x): x_quantized = torch.quantize_per_tensor( x, 1.0, 0, torch.quint8) conv = self.conv(x_quantized) - return torch.dequantize(conv).contiguous() + return torch.dequantize(conv) ref_net = None if not relu: @@ -54,13 +54,8 @@ def forward(self, x): @pytest.mark.parametrize( "params", [ - pytest.param( - {"weights_shape": [1, 3, 3, 3], "strides": 1, - "pads": 0, "dilations": 1, "groups": 1}, - marks=pytest.mark.xfail( - reason="Output channels equal to 1 creates output that fails to cast to contiguous." - ), - ), + {"weights_shape": [1, 3, 3, 3], "strides": 1, + "pads": 0, "dilations": 1, "groups": 1}, {"weights_shape": [2, 3, 3, 3], "strides": 1, "pads": 0, "dilations": 1, "groups": 1}, {"weights_shape": [2, 3, 3, 3], "strides": 2, From cc5ab26a953dbf13ec693d7c2d8f975fccbde261 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 11 Aug 2023 13:03:12 +0400 Subject: [PATCH 41/51] Remove explicit CRT options from MLAS (#19115) --- src/plugins/intel_cpu/thirdparty/mlas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/thirdparty/mlas b/src/plugins/intel_cpu/thirdparty/mlas index c215a2c97b47ed..219f114e988527 160000 --- a/src/plugins/intel_cpu/thirdparty/mlas +++ b/src/plugins/intel_cpu/thirdparty/mlas @@ -1 +1 @@ -Subproject commit c215a2c97b47ed01be7675f75bc463c820ac6e6d +Subproject commit 219f114e988527bb0ecaf2636622562859afa6e1 From a251346031ac3bc7ee0c5ec9d8aeec00dcba82f7 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 11 Aug 2023 13:54:44 +0400 Subject: [PATCH 42/51] [CPU] Give different output name for dnnl (#19136) * Give different output name for dnnl * Apply suggestions from code review added prefix to library name --- src/plugins/intel_cpu/thirdparty/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt index ce6c99dd661982..98935a0792cc01 100644 --- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt @@ -36,6 +36,7 @@ function(ov_add_onednn) # select needed primitives set(DNNL_ENABLE_PRIMITIVE "CONVOLUTION;DECONVOLUTION;CONCAT;LRN;INNER_PRODUCT;MATMUL;POOLING;REDUCTION;REORDER;RNN;SOFTMAX" CACHE STRING "" FORCE) set(DNNL_ENABLE_WORKLOAD "INFERENCE" CACHE STRING "" FORCE) + set(DNNL_LIBRARY_NAME "openvino_onednn_cpu" CACHE STRING "" FORCE) # Allow to enable oneDNN verbose with CPU_DEBUG_CAPS and rely on oneDNN default configuration otherwise if(ENABLE_CPU_DEBUG_CAPS) From 45a60639af44039b060a32335057833d80a53626 Mon Sep 17 00:00:00 2001 From: Przemyslaw Wysocki Date: Fri, 11 Aug 2023 12:03:59 +0200 Subject: [PATCH 43/51] [PyOV] Add `sympy` dependency for torchvision preprocessor tests (#19112) --- src/bindings/python/requirements_test.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bindings/python/requirements_test.txt b/src/bindings/python/requirements_test.txt index d2d92b04dcb942..d05ebd2ec7e74f 100644 --- a/src/bindings/python/requirements_test.txt +++ b/src/bindings/python/requirements_test.txt @@ -43,4 +43,6 @@ singledispatchmethod torch torchvision; platform_machine == 'arm64' and python_version >= '3.8' torchvision; platform_machine != 'arm64' +sympy; platform_machine == 'arm64' and python_version >= '3.8' +sympy; platform_machine != 'arm64' pillow From 2bdb7bd23e5c2ebf6fdf8c2941928820a34ffff2 Mon Sep 17 00:00:00 2001 From: Gorokhov Dmitriy Date: Fri, 11 Aug 2023 14:14:32 +0400 Subject: [PATCH 44/51] [CPU] FullyConnected acceleration with 8bit weights decompression on SPR (#19111) --- .../intel_cpu/src/dnnl_postops_composer.cpp | 29 ++++-- .../intel_cpu/src/dnnl_postops_composer.h | 5 +- src/plugins/intel_cpu/src/graph_optimizer.cpp | 25 ++++- .../intel_cpu/src/nodes/fullyconnected.cpp | 15 ++- .../src/matmul_weights_decompression.cpp | 96 +++++++++++++++---- src/plugins/intel_cpu/thirdparty/onednn | 2 +- 6 files changed, 132 insertions(+), 40 deletions(-) diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp index c363bffd6b6175..c5e368ebd5efc0 100644 --- a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp @@ -251,7 +251,22 @@ void DnnlPostOpsComposer::appendClip(const std::vector& low, const std::v } } -void DnnlPostOpsComposer::appendDecompressionScales(const std::vector& scales) { +MemoryPtr DnnlPostOpsComposer::prepackDecompressionParams(const std::vector& params, size_t icBlock) { + // Prepacking params from [oc] to [oc, icBlock] layout, where for each icBlock corresponding parameter is duplicated + DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape({icBlock * params.size()})); + auto mem = std::make_shared(engine, memoryDesc); + size_t dstIdx = 0; + auto decomp_scales_buf = static_cast(mem->getData()); + for (size_t oc = 0; oc < params.size(); oc++) { + for (size_t intIdx = 0; intIdx < icBlock; intIdx++) { + decomp_scales_buf[dstIdx] = params[oc]; + dstIdx++; + } + } + return mem; +} + +void DnnlPostOpsComposer::appendDecompressionScales(const std::vector& scales, size_t icBlock) { if (scales.empty()) return; @@ -259,13 +274,10 @@ void DnnlPostOpsComposer::appendDecompressionScales(const std::vector& sc DEBUG_LOG("Set weights scales mask ", "DNNL_ARG: ", DNNL_ARG_WEIGHTS, " mask: ", mask); attr.set_scales_mask(DNNL_ARG_WEIGHTS, mask); - DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape({scales.size()})); - auto mem = std::make_shared(engine, memoryDesc); - memcpy(mem->getData(), scales.data(), scales.size() * sizeof(float)); - args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = mem; + args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = prepackDecompressionParams(scales, icBlock); } -void DnnlPostOpsComposer::appendDecompressionZeroPoints(const std::vector& zero_points) { +void DnnlPostOpsComposer::appendDecompressionZeroPoints(const std::vector& zero_points, size_t icBlock) { if (zero_points.empty()) return; @@ -273,10 +285,7 @@ void DnnlPostOpsComposer::appendDecompressionZeroPoints(const std::vector DEBUG_LOG("Set weights zero points mask ", "DNNL_ARG: ", DNNL_ARG_WEIGHTS, " mask: ", mask); attr.set_zero_points_mask(DNNL_ARG_WEIGHTS, mask); - DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape({zero_points.size()})); - auto mem = std::make_shared(engine, memoryDesc); - memcpy(mem->getData(), zero_points.data(), zero_points.size() * sizeof(float)); - args[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = mem; + args[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = prepackDecompressionParams(zero_points, icBlock); } } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.h b/src/plugins/intel_cpu/src/dnnl_postops_composer.h index 344d93e649a60e..365ab0a6f32239 100644 --- a/src/plugins/intel_cpu/src/dnnl_postops_composer.h +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.h @@ -42,8 +42,8 @@ class DnnlPostOpsComposer { bool appendLinear(const std::vector& scale, const std::vector& shift, bool isLastPostOp, bool allowBinary = true); void appendClip(const std::vector& low, const std::vector& high); - void appendDecompressionScales(const std::vector& scales); - void appendDecompressionZeroPoints(const std::vector& zero_points); + void appendDecompressionScales(const std::vector& scales, size_t icBlock); + void appendDecompressionZeroPoints(const std::vector& zero_points, size_t icBlock); const VectorDims& getOutputDims() { return outputDims; @@ -69,6 +69,7 @@ class DnnlPostOpsComposer { void updateWeiScales(); void updateDestScales(); + MemoryPtr prepackDecompressionParams(const std::vector& params, size_t icBlock); }; } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/graph_optimizer.cpp b/src/plugins/intel_cpu/src/graph_optimizer.cpp index d6956665bd24a7..791ff04021737c 100644 --- a/src/plugins/intel_cpu/src/graph_optimizer.cpp +++ b/src/plugins/intel_cpu/src/graph_optimizer.cpp @@ -287,6 +287,7 @@ void GraphOptimizer::FuseConvMatmulFCDeconvAndDQScales(Graph &graph) { void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { const std::set supportedWeightsPrecisions{InferenceEngine::Precision::U8}; + const std::set supportedDataPrecisions{InferenceEngine::Precision::FP32, InferenceEngine::Precision::BF16}; auto expectedNode = [](NodePtr node, Type expectedType) { return node->getType() == expectedType && node->getChildEdges().size() == 1; }; @@ -334,14 +335,14 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { continue; // Precision limitations - if (fcNode->getOriginalInputPrecisionAtPort(0) != Precision::FP32) - continue; if (multiplyConstNode->getOriginalOutputPrecisionAtPort(0) != Precision::FP32) continue; - if (supportedWeightsPrecisions.find(weightsNode->getOriginalOutputPrecisionAtPort(0)) == supportedWeightsPrecisions.end()) - continue; if (withSubtract && subtractConstNode->getOriginalOutputPrecisionAtPort(0) != Precision::FP32) continue; + if (supportedDataPrecisions.find(fcNode->getOriginalInputPrecisionAtPort(0)) == supportedDataPrecisions.end()) + continue; + if (supportedWeightsPrecisions.find(weightsNode->getOriginalOutputPrecisionAtPort(0)) == supportedWeightsPrecisions.end()) + continue; // Shape limitations const auto weightsShape = weightsNode->getOutputShapeAtPort(0); @@ -356,6 +357,22 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { if (withSubtract && subtractConstNode->getOutputShapeAtPort(0).getDims() != expectedDims) continue; + // HW specific shape limitations + if (impl::cpu::x64::mayiuse(impl::cpu::x64::avx512_core_amx)) { + // OneDNN AMX IP implementation has limited shapes support due to performance considerations. As a current solution conditions below are copied + // from OneDNN to make sure correct IP impl will be used since fallback one doesn't support weights decompression feature. + size_t OC = withTranspose ? weightsShape.getDims()[1] : weightsShape.getDims()[0]; + size_t IC = withTranspose ? weightsShape.getDims()[0] : weightsShape.getDims()[1]; + size_t simdWidth = 16; + size_t vnniFactor = 2; + size_t maxSize = 512; + auto amxRow = vnniFactor * simdWidth; + + if ((IC <= amxRow && OC <= amxRow) || (IC <= maxSize && OC <= maxSize && IC % amxRow != 0)) + continue; + } + + // Fusion processing fcNode->fuseDecompressionMultiply(multiplyConstNode); if (withSubtract) fcNode->fuseDecompressionSubtract(subtractConstNode); diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp index 823e8448b28695..77f286cf373967 100644 --- a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp +++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp @@ -204,7 +204,8 @@ void FullyConnected::getSupportedDescriptors() { useSparseWeights = useSparseWeightsDecompression(); useWeightsDecompressionImpl = dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2) && - inputDataType == memory::data_type::f32 && weightsDataType == memory::data_type::u8; + one_of(inputDataType, memory::data_type::f32, memory::data_type::bf16) && + weightsDataType == memory::data_type::u8; // revert back outputDataType on special cases if (inputDataType == memory::data_type::f32) { @@ -594,10 +595,18 @@ void FullyConnected::setPostOps(dnnl::primitive_attr& attr, const VectorDims& di DnnlPostOpsComposer dnnlpoc(getEngine(), attr, ops, postOpsArgs, dims, dims.size() - 1, canBeExecutedInInt8(), 1 << 0, getDQScales(), withBiases); + NodeDesc *selected_pd = getSelectedPrimitiveDescriptor(); + if (selected_pd == nullptr) + IE_THROW() << "Preferable primitive descriptor is not set for node " << getName() << "."; + // OneDNN API doesn't provide an abilitiy to query optimal layout for runtime attributes + // As workaround we assume that all AMX IP implementations use equal internal IC block size for weights layout + // and prepack runtime attributes accordingly for better performance + bool withAMX = selected_pd->getImplementationType() & impl_desc_type::amx; + int icBlock = withAMX ? 2 : 1; if (!decompressionMultiply.empty()) - dnnlpoc.appendDecompressionScales(decompressionMultiply); + dnnlpoc.appendDecompressionScales(decompressionMultiply, icBlock); if (!decompressionSubtract.empty()) - dnnlpoc.appendDecompressionZeroPoints(decompressionSubtract); + dnnlpoc.appendDecompressionZeroPoints(decompressionSubtract, icBlock); for (size_t i = 0; i < fusedWith.size(); ++i) { auto& node = fusedWith[i]; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp index f1d0ebb70e0848..ab6259873988d6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp @@ -37,7 +37,8 @@ using MatmulWeightsDecompressionParams = std::tuple, // bool, // decompression subtract bool, // reshape on decompression constants std::map, // additional config - fusingSpecificParams>; + fusingSpecificParams, + bool>; // should use decompression implementation class MatmulWeightsDecompression : public testing::WithParamInterface, virtual public SubgraphBaseTest, @@ -51,6 +52,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface additional_config; fusingSpecificParams fusing_params; + bool should_fuse; std::tie(inputShapes, weights_precision, @@ -58,7 +60,8 @@ class MatmulWeightsDecompression : public testing::WithParamInterface additional_config; fusingSpecificParams fusing_params; + bool should_fuse; std::tie(inputShapes, weights_precision, @@ -165,15 +169,14 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(test_param); + bool should_fuse = std::get<7>(test_param); for (const auto& n : compiledModel.get_runtime_model()->get_ordered_ops()) { if (n->get_friendly_name() == "Compressed_weights") { ASSERT_EQ(n->get_output_element_type(0), weights_precision); @@ -189,9 +193,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface additional_config = std::get<5>(test_param); - const size_t expected_count = - InferenceEngine::with_cpu_x86_avx2() && - additional_config[PluginConfigParams::KEY_ENFORCE_BF16] != PluginConfigParams::YES ? 0 : 1; + const size_t expected_count = should_fuse ? 0 : 1; CheckNumberOfNodesWithType(compiledModel, "Convert", expected_count); CheckNumberOfNodesWithType(compiledModel, "Eltwise", expected_count); CheckNumberOfNodesWithType(compiledModel, "Subgraph", 0); @@ -206,25 +208,49 @@ TEST_P(MatmulWeightsDecompression, CompareWithRefs) { namespace { -std::vector> filterAdditionalConfig() { - std::vector> additional_config{CPUTestUtils::cpuEmptyPluginConfig}; - if (with_cpu_x86_avx512_core()) +std::vector> filterAdditionalConfigBasic() { + std::vector> additional_config = {CPUTestUtils::cpuEmptyPluginConfig}; + return additional_config; +} +std::vector> filterAdditionalConfigBig() { + std::vector> additional_config = {CPUTestUtils::cpuEmptyPluginConfig}; + if (with_cpu_x86_avx512_core_amx()) additional_config.push_back({{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}); return additional_config; } +bool shouldUseDecompressionKernelBig() { + // No decompression support on non-avx systems + if (!with_cpu_x86_avx2()) + return false; + + return true; +} + +bool shouldUseDecompressionKernelBasic() { + // AMX decompression support has shape limitations + if (with_cpu_x86_avx512_core_amx()) + return false; + + return shouldUseDecompressionKernelBig(); +} + const std::vector weights_precisions = {ov::element::u8}; const std::vector> input_shapes_basic = { {{{-1, -1, -1}, {{1, 4, 16}, {10, 16, 16}}}, {{}, {{16, 32}}}}, {{{}, {{1, 4, 16}}}, {{}, {{1, 16, 32}}}}, {{{}, {{10, 40, 496}}}, {{}, {{1, 496, 240}}}}, - {{{}, {{1, 4, 32}}}, {{}, {{32, 256}}}}, {{{}, {{1, 4, 48}}}, {{}, {{48, 256}}}}, + {{{}, {{11, 339, 377}}}, {{}, {{377, 335}}}}, +}; +const std::vector> input_shapes_big = { + {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {{}, {{1, 480, 256}}}}, + {{{}, {{1, 4, 32}}}, {{}, {{32, 256}}}}, {{{}, {{1, 4, 512}}}, {{}, {{512, 256}}}}, {{{}, {{1, 16, 32}}}, {{}, {{32, 64}}}}, {{{}, {{2, 4, 32}}}, {{}, {{32, 65}}}}, - {{{}, {{11, 339, 377}}}, {{}, {{377, 335}}}}, {{{}, {{3, 12, 768}}}, {{}, {{768, 1024}}}}, + {{{}, {{11, 339, 577}}}, {{}, {{577, 335}}}}, }; const std::vector fusingParamsSet { emptyFusingSpec, @@ -238,27 +264,57 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic, ::testing::Values(true), ::testing::Values(true), ::testing::Values(true), - ::testing::ValuesIn(filterAdditionalConfig()), - ::testing::ValuesIn(fusingParamsSet)), + ::testing::ValuesIn(filterAdditionalConfigBasic()), + ::testing::ValuesIn(fusingParamsSet), + ::testing::Values(shouldUseDecompressionKernelBasic())), MatmulWeightsDecompression::getTestCaseName); -const std::vector> input_shapes_corner_cases = { +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_big, + MatmulWeightsDecompression, + ::testing::Combine(::testing::ValuesIn(input_shapes_big), + ::testing::ValuesIn(weights_precisions), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(true), + ::testing::ValuesIn(filterAdditionalConfigBig()), + ::testing::ValuesIn(fusingParamsSet), + ::testing::Values(shouldUseDecompressionKernelBig())), + MatmulWeightsDecompression::getTestCaseName); + +const std::vector> input_shapes_corner_cases_basic = { {{{-1, -1, -1}, {{1, 4, 16}}}, {{}, {{1, 16, 32}}}}, {{{-1, -1, -1}, {{1, 4, 16}}}, {{}, {{16, 32}}}}, }; +const std::vector> input_shapes_corner_cases_big = { + {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {{}, {{1, 480, 256}}}}, +}; + const std::vector transpose_weights = {true, false}; const std::vector add_decompression_sub = {true, false}; const std::vector reshape_on_decompression = {true, false}; -INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases, +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_basic, + MatmulWeightsDecompression, + ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_basic), + ::testing::ValuesIn(weights_precisions), + ::testing::ValuesIn(transpose_weights), + ::testing::ValuesIn(add_decompression_sub), + ::testing::ValuesIn(reshape_on_decompression), + ::testing::ValuesIn(filterAdditionalConfigBasic()), + ::testing::Values(emptyFusingSpec), + ::testing::Values(shouldUseDecompressionKernelBasic())), + MatmulWeightsDecompression::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_big, MatmulWeightsDecompression, - ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases), + ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_big), ::testing::ValuesIn(weights_precisions), ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), - ::testing::Values(CPUTestUtils::cpuEmptyPluginConfig), - ::testing::Values(emptyFusingSpec)), + ::testing::ValuesIn(filterAdditionalConfigBig()), + ::testing::Values(emptyFusingSpec), + ::testing::Values(shouldUseDecompressionKernelBig())), MatmulWeightsDecompression::getTestCaseName); } // namespace diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index ec7a051b3f4a9e..6b6f9fcebf840c 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit ec7a051b3f4a9e65b22382f3d787e84ce74efe07 +Subproject commit 6b6f9fcebf840c665e1db4361f75c42ac77e5e72 From 6bf75f569cb6e9a8c51830f60241534eb73ca3fc Mon Sep 17 00:00:00 2001 From: Anastasiia Pnevskaia Date: Fri, 11 Aug 2023 13:19:07 +0200 Subject: [PATCH 45/51] Fix of tensor names loosing for cf=True flag in MOC transformations. (#19014) * Added shape and type infer for result nodes in MOC transformations. * Clang format. * Added validate_nodes_and_infer_types() pass at the end of MOC pipeline. * Clang format. * Added test. * Clang format. --- .../moc_transformations.cpp | 2 +- .../moc_transformations.cpp | 60 +++++++++++++++++++ .../mo_python_api_tests/test_mo_convert_tf.py | 32 ++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/common/transformations/tests/common_optimizations/moc_transformations.cpp diff --git a/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp b/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp index e67fc4d4d62933..bfe4daa66d8f68 100644 --- a/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp @@ -255,8 +255,8 @@ bool ov::pass::MOCTransformations::run_on_model(const std::shared_ptrget_parameters()) { param->set_partial_shape(input_shapes.at(param.get())); } - f->validate_nodes_and_infer_types(); } + f->validate_nodes_and_infer_types(); return false; } diff --git a/src/common/transformations/tests/common_optimizations/moc_transformations.cpp b/src/common/transformations/tests/common_optimizations/moc_transformations.cpp new file mode 100644 index 00000000000000..2e90bd5de677f1 --- /dev/null +++ b/src/common/transformations/tests/common_optimizations/moc_transformations.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include + +#include "openvino/core/model.hpp" +#include "openvino/opsets/opset12.hpp" +#include "openvino/pass/manager.hpp" + +using namespace testing; +using namespace ov; +using namespace ov::opset12; + +TEST(TransformationTests, TestModelTensorsConsistencyUseShapesTrue) { + auto input = std::make_shared(element::f32, Shape{1}); + auto const1 = opset12::Constant::create(element::f32, Shape{1}, {1}); + auto const2 = opset12::Constant::create(element::f32, Shape{1}, {2}); + auto const3 = opset12::Constant::create(element::f32, Shape{1}, {3}); + auto add1 = std::make_shared(input, const1); + auto add2 = std::make_shared(add1, const2); + auto add3 = std::make_shared(add2, const3); + + auto model = std::make_shared(NodeVector{add3}, ParameterVector{input}); + ov::pass::Manager m; + m.register_pass(true); + m.run_passes(model); + + std::unordered_set new_tensors = {"new_name"}; + model->outputs()[0].set_names(new_tensors); + EXPECT_TRUE(model->outputs()[0].get_names() == new_tensors); + + model->validate_nodes_and_infer_types(); + EXPECT_TRUE(model->outputs()[0].get_names() == new_tensors); +} + +TEST(TransformationTests, TestModelTensorsConsistencyUseShapesFalse) { + auto input = std::make_shared(element::f32, Shape{1}); + auto const1 = opset12::Constant::create(element::f32, Shape{1}, {1}); + auto const2 = opset12::Constant::create(element::f32, Shape{1}, {2}); + auto const3 = opset12::Constant::create(element::f32, Shape{1}, {3}); + auto add1 = std::make_shared(input, const1); + auto add2 = std::make_shared(add1, const2); + auto add3 = std::make_shared(add2, const3); + + auto model = std::make_shared(NodeVector{add3}, ParameterVector{input}); + ov::pass::Manager m; + m.register_pass(false); + m.run_passes(model); + + std::unordered_set new_tensors = {"new_name"}; + model->outputs()[0].set_names(new_tensors); + EXPECT_TRUE(model->outputs()[0].get_names() == new_tensors); + + model->validate_nodes_and_infer_types(); + EXPECT_TRUE(model->outputs()[0].get_names() == new_tensors); +} diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py index b7b2c85032b58c..59c90cd7b3d415 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_tf.py @@ -903,6 +903,38 @@ def test_memory_loss(self, ie_device, precision, ir_version, temp_dir): assert CommonLayerTest().compare_ie_results_with_framework(ov_infer2, {"add:0": fw_infer2}, eps) assert CommonLayerTest().compare_ie_results_with_framework(ov_infer1, {"add:0": [2.6, 9.6, 12.4]}, eps) + def test_tensor_names(self, ie_device, precision, ir_version, temp_dir): + import tensorflow as tf + class LayerModel(tf.Module): + def __init__(self): + super(LayerModel, self).__init__() + self.var1 = tf.Variable([7., 5., 6.], name='var1') + self.var2 = tf.Variable([5., 7., 3.], name='var2') + self.var3 = tf.Variable([5., 7., 3.], name='var2') + + + @tf.function + def sub_function(self, input): + return input + self.var1 + self.var2 + self.var3 + + @tf.function() + def __call__(self, input): + return self.sub_function(input) + + from openvino.tools.ovc import convert_model + model = LayerModel() + ov_model = convert_model(model) + + ov_model.outputs[0].get_tensor().set_names({"name1"}) + assert ov_model.outputs[0].names == {"name1"} + + ov_model.validate_nodes_and_infer_types() + assert ov_model.outputs[0].names == {"name1"} + + ov_model.outputs[0].get_tensor().set_names({"name2"}) + assert ov_model.outputs[0].names == {"name2"} + + class TFConvertTest(unittest.TestCase): @pytest.mark.nightly From a957764362bb83d117cc1d039a8f6d9b08dbd73d Mon Sep 17 00:00:00 2001 From: Wanglei Shen Date: Fri, 11 Aug 2023 19:23:29 +0800 Subject: [PATCH 46/51] block SOC Ecore to be used in multi-threading on Windows (#18910) --- .../dev_api/openvino/runtime/system_conf.hpp | 5 ++-- src/inference/src/os/win/win_system_conf.cpp | 20 +++++++++---- .../unit/cpu_map_parser/parser_windows.cpp | 28 +++++++++---------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/inference/dev_api/openvino/runtime/system_conf.hpp b/src/inference/dev_api/openvino/runtime/system_conf.hpp index 36cbdcdd2fe4ea..c2e0cc37fd942c 100644 --- a/src/inference/dev_api/openvino/runtime/system_conf.hpp +++ b/src/inference/dev_api/openvino/runtime/system_conf.hpp @@ -228,8 +228,9 @@ enum ColumnOfProcessorTypeTable { * @brief Definition of CPU_MAP_USED_FLAG column in CPU mapping table. */ enum ProcessorUseStatus { - NOT_USED = -1, //!< Processor is not bound to thread - CPU_USED = 1, //!< CPU is in using + CPU_BLOCKED = -100, //!< Processor is blocked to use + NOT_USED = -1, //!< Processor is not bound to thread + CPU_USED = 1, //!< CPU is in using }; /** diff --git a/src/inference/src/os/win/win_system_conf.cpp b/src/inference/src/os/win/win_system_conf.cpp index 11b172ba5c2abd..01460db7cc8c2c 100644 --- a/src/inference/src/os/win/win_system_conf.cpp +++ b/src/inference/src/os/win/win_system_conf.cpp @@ -63,6 +63,7 @@ void parse_processor_info_win(const char* base_ptr, int group_end = 0; int group_id = 0; int group_type = 0; + int num_blocked = 0; int num_package = 0; @@ -141,14 +142,18 @@ void parse_processor_info_win(const char* base_ptr, if ((_processors > group_start) && (_processors <= group_end)) { proc_info[CPU_MAP_CORE_TYPE] = group_type; proc_info[CPU_MAP_GROUP_ID] = group_id; - _proc_type_table[0][group_type]++; + if (group_id == CPU_BLOCKED) { + proc_info[CPU_MAP_USED_FLAG] = CPU_BLOCKED; + num_blocked++; + } else { + _proc_type_table[0][group_type]++; + } } _cpu_mapping_table.push_back(proc_info); } _proc_type_table[0][ALL_PROC] += list_len; _processors += list_len; _cores++; - } else if ((info->Relationship == RelationCache) && (info->Cache.Level == 2)) { MaskToList(info->Cache.GroupMask.Mask); @@ -170,15 +175,15 @@ void parse_processor_info_win(const char* base_ptr, if (_processors <= list[list_len - 1] + base_proc) { group_start = list[0]; group_end = list[list_len - 1]; - group_id = group; + group_id = CPU_BLOCKED; group_type = EFFICIENT_CORE_PROC; } for (int m = 0; m < _processors - list[0]; m++) { _cpu_mapping_table[list[m] + base_proc][CPU_MAP_CORE_TYPE] = EFFICIENT_CORE_PROC; - _cpu_mapping_table[list[m] + base_proc][CPU_MAP_GROUP_ID] = group; - _proc_type_table[0][EFFICIENT_CORE_PROC]++; + _cpu_mapping_table[list[m] + base_proc][CPU_MAP_GROUP_ID] = group_id; + _cpu_mapping_table[list[m] + base_proc][CPU_MAP_USED_FLAG] = CPU_BLOCKED; } - group++; + num_blocked++; } else if (1 == list_len) { _cpu_mapping_table[list[0] + base_proc][CPU_MAP_CORE_TYPE] = MAIN_CORE_PROC; _cpu_mapping_table[list[0] + base_proc][CPU_MAP_GROUP_ID] = group; @@ -188,6 +193,9 @@ void parse_processor_info_win(const char* base_ptr, } } _sockets++; + _processors -= num_blocked; + _cores -= num_blocked; + _proc_type_table[0][ALL_PROC] -= num_blocked; if (_sockets > 1) { _proc_type_table.push_back(_proc_type_table[0]); _proc_type_table[0] = proc_init_line; diff --git a/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp b/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp index 58d8e0441c0965..1e0da72b68199e 100644 --- a/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp +++ b/src/inference/tests/unit/cpu_map_parser/parser_windows.cpp @@ -1672,23 +1672,23 @@ WinCpuMapTestCase _1sockets_24cores_hyperthreading_set2 = { }; WinCpuMapTestCase _1sockets_22cores_hyperthreading = { - 22, + 20, 1, 1, - 16, - {{22, 6, 10, 6, 0, 0}}, + 14, + {{20, 6, 8, 6, 0, 0}}, { - {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, - {2, 0, 0, 1, EFFICIENT_CORE_PROC, 1, -1}, {3, 0, 0, 2, EFFICIENT_CORE_PROC, 1, -1}, - {4, 0, 0, 3, EFFICIENT_CORE_PROC, 1, -1}, {5, 0, 0, 4, EFFICIENT_CORE_PROC, 1, -1}, - {6, 0, 0, 5, EFFICIENT_CORE_PROC, 2, -1}, {7, 0, 0, 6, EFFICIENT_CORE_PROC, 2, -1}, - {8, 0, 0, 7, EFFICIENT_CORE_PROC, 2, -1}, {9, 0, 0, 8, EFFICIENT_CORE_PROC, 2, -1}, - {10, 0, 0, 9, HYPER_THREADING_PROC, 3, -1}, {11, 0, 0, 9, MAIN_CORE_PROC, 3, -1}, - {12, 0, 0, 10, HYPER_THREADING_PROC, 4, -1}, {13, 0, 0, 10, MAIN_CORE_PROC, 4, -1}, - {14, 0, 0, 11, HYPER_THREADING_PROC, 5, -1}, {15, 0, 0, 11, MAIN_CORE_PROC, 5, -1}, - {16, 0, 0, 12, HYPER_THREADING_PROC, 6, -1}, {17, 0, 0, 12, MAIN_CORE_PROC, 6, -1}, - {18, 0, 0, 13, HYPER_THREADING_PROC, 7, -1}, {19, 0, 0, 13, MAIN_CORE_PROC, 7, -1}, - {20, 0, 0, 14, EFFICIENT_CORE_PROC, 8, -1}, {21, 0, 0, 15, EFFICIENT_CORE_PROC, 8, -1}, + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, EFFICIENT_CORE_PROC, 1, -1}, {3, 0, 0, 2, EFFICIENT_CORE_PROC, 1, -1}, + {4, 0, 0, 3, EFFICIENT_CORE_PROC, 1, -1}, {5, 0, 0, 4, EFFICIENT_CORE_PROC, 1, -1}, + {6, 0, 0, 5, EFFICIENT_CORE_PROC, 2, -1}, {7, 0, 0, 6, EFFICIENT_CORE_PROC, 2, -1}, + {8, 0, 0, 7, EFFICIENT_CORE_PROC, 2, -1}, {9, 0, 0, 8, EFFICIENT_CORE_PROC, 2, -1}, + {10, 0, 0, 9, HYPER_THREADING_PROC, 3, -1}, {11, 0, 0, 9, MAIN_CORE_PROC, 3, -1}, + {12, 0, 0, 10, HYPER_THREADING_PROC, 4, -1}, {13, 0, 0, 10, MAIN_CORE_PROC, 4, -1}, + {14, 0, 0, 11, HYPER_THREADING_PROC, 5, -1}, {15, 0, 0, 11, MAIN_CORE_PROC, 5, -1}, + {16, 0, 0, 12, HYPER_THREADING_PROC, 6, -1}, {17, 0, 0, 12, MAIN_CORE_PROC, 6, -1}, + {18, 0, 0, 13, HYPER_THREADING_PROC, 7, -1}, {19, 0, 0, 13, MAIN_CORE_PROC, 7, -1}, + {20, 0, 0, 14, EFFICIENT_CORE_PROC, -100, -100}, {21, 0, 0, 15, EFFICIENT_CORE_PROC, -100, -100}, }, {"0300000030000000000000000000000000000000000000000000000000000100ffff3f0000000000000000000000000000000000300000000" "10100000000000000000000000000000000000000000100030000000000000000000000000000000700000030000000000000000000000000" From 9fd8a13fe6bea701edf99c49b9dc06dd6ace2405 Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Fri, 11 Aug 2023 14:49:18 +0300 Subject: [PATCH 47/51] [PT FE] aten::concat (#19101) * [PT FE] aten::concat * Update src/frontends/pytorch/src/op/cat.cpp * add out * fix tests --- src/frontends/pytorch/src/op/cat.cpp | 8 +- src/frontends/pytorch/src/op_table.cpp | 1 + .../src/transforms/aten_cat_replacer.cpp | 2 + tests/layer_tests/pytorch_tests/test_cat.py | 90 +++++++++++++------ 4 files changed, 74 insertions(+), 27 deletions(-) diff --git a/src/frontends/pytorch/src/op/cat.cpp b/src/frontends/pytorch/src/op/cat.cpp index 76b5a542cf4671..7c2a43f0c38ff5 100644 --- a/src/frontends/pytorch/src/op/cat.cpp +++ b/src/frontends/pytorch/src/op/cat.cpp @@ -41,10 +41,14 @@ OutputVector translate_cat_common(const NodeContext& context, OutputVector translate_cat(const NodeContext& context) { // This translator is only needed to get axis as constant from external scope - num_inputs_check(context, 2, 2); + num_inputs_check(context, 2, 3); const auto&& list_elems = get_list_as_outputs(context.get_input(0)); auto axis = context.const_input(1); - return translate_cat_common(context, list_elems, axis); + auto out = translate_cat_common(context, list_elems, axis); + if (!context.input_is_none(2)) { + context.mutate_input(2, out[0]); + } + return out; }; OutputVector translate_cat_fx(const NodeContext& context) { diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp index f3815d17369b87..6ba7e70ab73869 100644 --- a/src/frontends/pytorch/src/op_table.cpp +++ b/src/frontends/pytorch/src/op_table.cpp @@ -248,6 +248,7 @@ const std::map get_supported_ops_ts() { {"aten::bmm", op::translate_1to1_match_2_inputs}, {"aten::Bool", op::translate_bool}, {"aten::cat", op::translate_cat}, + {"aten::concat", op::translate_cat}, {"aten::cdist", op::translate_cdist}, {"aten::ceil", op::translate_1to1_match_1_inputs}, {"aten::ceil_", op::inplace_op>}, diff --git a/src/frontends/pytorch/src/transforms/aten_cat_replacer.cpp b/src/frontends/pytorch/src/transforms/aten_cat_replacer.cpp index 79296bcd6c5670..fe0c828a33c082 100644 --- a/src/frontends/pytorch/src/transforms/aten_cat_replacer.cpp +++ b/src/frontends/pytorch/src/transforms/aten_cat_replacer.cpp @@ -37,6 +37,8 @@ AtenCatToConcat::AtenCatToConcat() { ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { auto cat = cast_fw_node(m.get_match_root(), "aten::cat"); + if (!cat) + cat = cast_fw_node(m.get_match_root(), "aten::concat"); if (!cat) cat = cast_fw_node(m.get_match_root(), "quantized::cat"); if (!cat) diff --git a/tests/layer_tests/pytorch_tests/test_cat.py b/tests/layer_tests/pytorch_tests/test_cat.py index b1d3fcef5eac47..7d590336ad1794 100644 --- a/tests/layer_tests/pytorch_tests/test_cat.py +++ b/tests/layer_tests/pytorch_tests/test_cat.py @@ -7,60 +7,100 @@ from pytorch_layer_test_class import PytorchLayerTest + class aten_cat(torch.nn.Module): def forward(self, x): - return torch.cat([x, x], 1) + return torch.cat(self.prepare_input(x), 1) + def prepare_input(self, x): + return [x, x] -class aten_append_cat(torch.nn.Module): - def forward(self, x): +class aten_cat_out(aten_cat): + def forward(self, x, out): + return torch.cat(self.prepare_input(x), 1, out=out), out + +class aten_append_cat(aten_cat): + def prepare_input(self, x): list = [] list.append(x) list.append(x) - return torch.cat(list, 1) + return list +class aten_append_cat_out(aten_cat_out): + def prepare_input(self, x): + list = [] + list.append(x) + list.append(x) + return list -class aten_loop_append_cat(torch.nn.Module): - def forward(self, x): +class aten_loop_append_cat(aten_cat): + def prepare_input(self, x): list = [] for i in range(3): list.append(x) - return torch.cat(list, 1) + return list + +class aten_loop_append_cat_out(aten_cat_out): + def prepare_input(self, x): + list = [] + for i in range(3): + list.append(x) + return list -class aten_add_cat(torch.nn.Module): +class aten_add_cat(aten_cat): def forward(self, x): - list = [x, x] - list2 = list + [x, x] - return torch.cat(list2, 1) + list1 = self.prepare_input(x) + list2 = self.prepare_input(x) + return torch.cat(list1 + list2, dim=1) + +class aten_add_cat_out(aten_cat_out): + def forward(self, x, out): + list1 = self.prepare_input(x) + list2 = self.prepare_input(x) + return torch.cat(list1 + list2, dim=1, out=out) class TestCat(PytorchLayerTest): - def _prepare_input(self): + def _prepare_input(self, out=False, num_repeats=2): import numpy as np - return (np.random.randn(2, 1, 3),) + data = np.random.randn(2, 1, 3) + if not out: + return (data, ) + concat = [data for _ in range(num_repeats)] + out = np.zeros_like(np.concatenate(concat, axis=1)) + return (data, out) + @pytest.mark.nightly @pytest.mark.precommit - def test_cat(self, ie_device, precision, ir_version): - self._test(aten_cat(), None, ["aten::cat", "prim::ListConstruct"], - ie_device, precision, ir_version) + @pytest.mark.parametrize("out", [False, True]) + def test_cat(self, out, ie_device, precision, ir_version): + model = aten_cat() if not out else aten_cat_out() + self._test(model, None, ["aten::cat", "prim::ListConstruct"], + ie_device, precision, ir_version, kwargs_to_prepare_input={"out": out, "num_repeats": 2}) @pytest.mark.nightly @pytest.mark.precommit - def test_append_cat(self, ie_device, precision, ir_version): - self._test(aten_append_cat(), None, ["aten::cat", "aten::append", "prim::ListConstruct"], - ie_device, precision, ir_version) + @pytest.mark.parametrize("out", [False, True]) + def test_append_cat(self, out, ie_device, precision, ir_version): + model = aten_append_cat() if not out else aten_append_cat_out() + self._test(model, None, ["aten::cat", "aten::append", "prim::ListConstruct"], + ie_device, precision, ir_version, kwargs_to_prepare_input={"out": out, "num_repeats": 2}) @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.xfail(reason="Transformation RemoveMultiSubGraphOpDanglingParamsResults doesn't support removing unused merged inputs, ticket 112833.") - def test_loop_append_cat(self, ie_device, precision, ir_version): - self._test(aten_loop_append_cat(), None, ["aten::cat", "aten::append", "prim::ListConstruct", "prim::Loop"], - ie_device, precision, ir_version, freeze_model=False) + @pytest.mark.parametrize("out", [False, True]) + def test_loop_append_cat(self, out, ie_device, precision, ir_version): + model = aten_loop_append_cat() if not out else aten_loop_append_cat_out() + self._test(model, None, ["aten::cat", "aten::append", "prim::ListConstruct", "prim::Loop"], + ie_device, precision, ir_version, freeze_model=False, kwargs_to_prepare_input={"out": out, "num_repeats": 3}) @pytest.mark.nightly @pytest.mark.precommit - def test_add_cat(self, ie_device, precision, ir_version): - self._test(aten_add_cat(), None, ["aten::cat", "aten::add", "prim::ListConstruct"], - ie_device, precision, ir_version, freeze_model=False) + @pytest.mark.parametrize("out", [False, True]) + def test_add_cat(self, out, ie_device, precision, ir_version): + model = aten_add_cat() if not out else aten_add_cat_out() + self._test(model, None, ["aten::cat", "aten::add", "prim::ListConstruct"], + ie_device, precision, ir_version, freeze_model=False, kwargs_to_prepare_input={"out": out, "num_repeats": 4}) From 260273932a0855c1677f7652e352a34aaf79a11c Mon Sep 17 00:00:00 2001 From: Sebastian Golebiewski Date: Fri, 11 Aug 2023 14:01:22 +0200 Subject: [PATCH 48/51] remove-howto (#19139) --- docs/HOWTO/img/converted_subgraph.png | 3 - docs/HOWTO/img/unsupported_subgraph.png | 3 - docs/HOWTO/mo_extensions/front/tf/Complex.py | 40 ------- .../mo_extensions/front/tf/ComplexAbs.py | 27 ----- docs/HOWTO/mo_extensions/front/tf/FFT_ext.py | 33 ------ docs/HOWTO/mo_extensions/ops/FFT.py | 27 ----- docs/HOWTO/mri_reconstruction_demo.py | 106 ------------------ 7 files changed, 239 deletions(-) delete mode 100644 docs/HOWTO/img/converted_subgraph.png delete mode 100644 docs/HOWTO/img/unsupported_subgraph.png delete mode 100644 docs/HOWTO/mo_extensions/front/tf/Complex.py delete mode 100644 docs/HOWTO/mo_extensions/front/tf/ComplexAbs.py delete mode 100644 docs/HOWTO/mo_extensions/front/tf/FFT_ext.py delete mode 100644 docs/HOWTO/mo_extensions/ops/FFT.py delete mode 100644 docs/HOWTO/mri_reconstruction_demo.py diff --git a/docs/HOWTO/img/converted_subgraph.png b/docs/HOWTO/img/converted_subgraph.png deleted file mode 100644 index 6a5b7220777d54..00000000000000 --- a/docs/HOWTO/img/converted_subgraph.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f7c8ab4f15874d235968471bcf876c89c795d601e69891208107b8b72aa58eb1 -size 70014 diff --git a/docs/HOWTO/img/unsupported_subgraph.png b/docs/HOWTO/img/unsupported_subgraph.png deleted file mode 100644 index 80f7084a78a859..00000000000000 --- a/docs/HOWTO/img/unsupported_subgraph.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3d5ccf51fe1babb93d96d042494695a6a6e055d1f8ebf7eef5083d54d8987a23 -size 58789 diff --git a/docs/HOWTO/mo_extensions/front/tf/Complex.py b/docs/HOWTO/mo_extensions/front/tf/Complex.py deleted file mode 100644 index 169a3e500500b4..00000000000000 --- a/docs/HOWTO/mo_extensions/front/tf/Complex.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -#! [complex:transformation] - -from openvino.tools.mo.front.common.replacement import FrontReplacementSubgraph -from openvino.tools.mo.graph.graph import Graph - - -class Complex(FrontReplacementSubgraph): - enabled = True - - def pattern(self): - return dict( - nodes=[ - ('strided_slice_real', dict(op='StridedSlice')), - ('strided_slice_imag', dict(op='StridedSlice')), - ('complex', dict(op='Complex')), - ], - edges=[ - ('strided_slice_real', 'complex', {'in': 0}), - ('strided_slice_imag', 'complex', {'in': 1}), - ]) - - @staticmethod - def replace_sub_graph(graph: Graph, match: dict): - strided_slice_real = match['strided_slice_real'] - strided_slice_imag = match['strided_slice_imag'] - complex_node = match['complex'] - - # make sure that both strided slice operations get the same data as input - assert strided_slice_real.in_port(0).get_source() == strided_slice_imag.in_port(0).get_source() - - # identify the output port of the operation producing datat for strided slice nodes - input_node_output_port = strided_slice_real.in_port(0).get_source() - input_node_output_port.disconnect() - - # change the connection so now all consumers of "complex_node" get data from input node of strided slice nodes - complex_node.out_port(0).get_connection().set_source(input_node_output_port) -#! [complex:transformation] diff --git a/docs/HOWTO/mo_extensions/front/tf/ComplexAbs.py b/docs/HOWTO/mo_extensions/front/tf/ComplexAbs.py deleted file mode 100644 index 5659443861105e..00000000000000 --- a/docs/HOWTO/mo_extensions/front/tf/ComplexAbs.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -#! [complex_abs:transformation] -import numpy as np - -from openvino.tools.mo.ops.elementwise import Pow -from openvino.tools.mo.ops.ReduceOps import ReduceSum -from openvino.tools.mo.front.common.replacement import FrontReplacementOp -from openvino.tools.mo.graph.graph import Graph, Node -from openvino.tools.mo.ops.const import Const - - -class ComplexAbs(FrontReplacementOp): - op = "ComplexAbs" - enabled = True - - def replace_op(self, graph: Graph, node: Node): - pow_2 = Const(graph, {'value': np.float32(2.0)}).create_node() - reduce_axis = Const(graph, {'value': np.int32(-1)}).create_node() - pow_0_5 = Const(graph, {'value': np.float32(0.5)}).create_node() - - sq = Pow(graph, dict(name=node.in_node(0).name + '/sq', power=2.0)).create_node([node.in_node(0), pow_2]) - sum = ReduceSum(graph, dict(name=sq.name + '/sum')).create_node([sq, reduce_axis]) - sqrt = Pow(graph, dict(name=sum.name + '/sqrt', power=0.5)).create_node([sum, pow_0_5]) - return [sqrt.id] -#! [complex_abs:transformation] diff --git a/docs/HOWTO/mo_extensions/front/tf/FFT_ext.py b/docs/HOWTO/mo_extensions/front/tf/FFT_ext.py deleted file mode 100644 index ac1cfbdcbf8c36..00000000000000 --- a/docs/HOWTO/mo_extensions/front/tf/FFT_ext.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -# ! [fft_ext:extractor] -from ...ops.FFT import FFT -from openvino.tools.mo.front.extractor import FrontExtractorOp - - -class FFT2DFrontExtractor(FrontExtractorOp): - op = 'FFT2D' - enabled = True - - @classmethod - def extract(cls, node): - attrs = { - 'inverse': 0 - } - FFT.update_node_stat(node, attrs) - return cls.enabled - - -class IFFT2DFrontExtractor(FrontExtractorOp): - op = 'IFFT2D' - enabled = True - - @classmethod - def extract(cls, node): - attrs = { - 'inverse': 1 - } - FFT.update_node_stat(node, attrs) - return cls.enabled -# ! [fft_ext:extractor] diff --git a/docs/HOWTO/mo_extensions/ops/FFT.py b/docs/HOWTO/mo_extensions/ops/FFT.py deleted file mode 100644 index 604d893cfdf131..00000000000000 --- a/docs/HOWTO/mo_extensions/ops/FFT.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -#! [fft:operation] -from openvino.tools.mo.front.common.partial_infer.elemental import copy_shape_infer -from openvino.tools.mo.graph.graph import Graph -from openvino.tools.mo.ops.op import Op - - -class FFT(Op): - op = 'FFT' - enabled = False - - def __init__(self, graph: Graph, attrs: dict): - super().__init__(graph, { - 'type': self.op, - 'op': self.op, - 'version': 'custom_opset', - 'inverse': None, - 'in_ports_count': 1, - 'out_ports_count': 1, - 'infer': copy_shape_infer - }, attrs) - - def backend_attrs(self): - return ['inverse'] -#! [fft:operation] diff --git a/docs/HOWTO/mri_reconstruction_demo.py b/docs/HOWTO/mri_reconstruction_demo.py deleted file mode 100644 index d694d8819cfe3c..00000000000000 --- a/docs/HOWTO/mri_reconstruction_demo.py +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -#! [mri_demo:demo] -import numpy as np -import cv2 as cv -import argparse -import time -from openvino.inference_engine import IECore - - -def kspace_to_image(kspace): - assert(len(kspace.shape) == 3 and kspace.shape[-1] == 2) - fft = cv.idft(kspace, flags=cv.DFT_SCALE) - img = cv.magnitude(fft[:,:,0], fft[:,:,1]) - return cv.normalize(img, dst=None, alpha=255, beta=0, norm_type=cv.NORM_MINMAX, dtype=cv.CV_8U) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='MRI reconstrution demo for network from https://github.com/rmsouza01/Hybrid-CS-Model-MRI (https://arxiv.org/abs/1810.12473)') - parser.add_argument('-i', '--input', dest='input', help='Path to input .npy file with MRI scan data.') - parser.add_argument('-p', '--pattern', dest='pattern', help='Path to sampling mask in .npy format.') - parser.add_argument('-m', '--model', dest='model', help='Path to .xml file of OpenVINO IR.') - parser.add_argument('-l', '--cpu_extension', dest='cpu_extension', help='Path to extensions library with FFT implementation.') - parser.add_argument('-d', '--device', dest='device', default='CPU', - help='Optional. Specify the target device to infer on; CPU, ' - 'GPU, GNA is acceptable. For non-CPU targets, ' - 'HETERO plugin is used with CPU fallbacks to FFT implementation. ' - 'Default value is CPU') - args = parser.parse_args() - - xml_path = args.model - assert(xml_path.endswith('.xml')) - bin_path = xml_path[:xml_path.rfind('.xml')] + '.bin' - - ie = IECore() - ie.add_extension(args.cpu_extension, "CPU") - - net = ie.read_network(xml_path, bin_path) - - device = 'CPU' if args.device == 'CPU' else ('HETERO:' + args.device + ',CPU') - exec_net = ie.load_network(net, device) - - # Hybrid-CS-Model-MRI/Data/stats_fs_unet_norm_20.npy - stats = np.array([2.20295299e-01, 1.11048916e+03, 4.16997984e+00, 4.71741395e+00], dtype=np.float32) - # Hybrid-CS-Model-MRI/Data/sampling_mask_20perc.npy - var_sampling_mask = np.load(args.pattern) # TODO: can we generate it in runtime? - print('Sampling ratio:', 1.0 - var_sampling_mask.sum() / var_sampling_mask.size) - - data = np.load(args.input) - num_slices, height, width = data.shape[0], data.shape[1], data.shape[2] - pred = np.zeros((num_slices, height, width), dtype=np.uint8) - data /= np.sqrt(height * width) - - print('Compute...') - start = time.time() - for slice_id, kspace in enumerate(data): - kspace = kspace.copy() - - # Apply sampling - kspace[var_sampling_mask] = 0 - kspace = (kspace - stats[0]) / stats[1] - - # Forward through network - input = np.expand_dims(kspace.transpose(2, 0, 1), axis=0) - outputs = exec_net.infer(inputs={'input_1': input}) - output = next(iter(outputs.values())) - output = output.reshape(height, width) - - # Save predictions - pred[slice_id] = cv.normalize(output, dst=None, alpha=255, beta=0, norm_type=cv.NORM_MINMAX, dtype=cv.CV_8U) - - print('Elapsed time: %.1f seconds' % (time.time() - start)) - - WIN_NAME = 'MRI reconstruction with OpenVINO' - - slice_id = 0 - def callback(pos): - global slice_id - slice_id = pos - - kspace = data[slice_id] - img = kspace_to_image(kspace) - - kspace[var_sampling_mask] = 0 - masked = kspace_to_image(kspace) - - rec = pred[slice_id] - - # Add a header - border_size = 20 - render = cv.hconcat((img, masked, rec)) - render = cv.copyMakeBorder(render, border_size, 0, 0, 0, cv.BORDER_CONSTANT, value=255) - cv.putText(render, 'Original', (0, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, color=0) - cv.putText(render, 'Sampled (PSNR %.1f)' % cv.PSNR(img, masked), (width, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, color=0) - cv.putText(render, 'Reconstructed (PSNR %.1f)' % cv.PSNR(img, rec), (width*2, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, color=0) - - cv.imshow(WIN_NAME, render) - cv.waitKey(1) - - cv.namedWindow(WIN_NAME, cv.WINDOW_NORMAL) - print(num_slices) - cv.createTrackbar('Slice', WIN_NAME, num_slices // 2, num_slices - 1, callback) - callback(num_slices // 2) # Trigger initial visualization - cv.waitKey() -#! [mri_demo:demo] From edc8015a65c2b8a66c116da5fdc330b6d249005d Mon Sep 17 00:00:00 2001 From: Sergey Lyalin Date: Fri, 11 Aug 2023 17:29:56 +0400 Subject: [PATCH 49/51] Fixed description for `convert_partially` (#19133) * Update src/frontends/common/include/openvino/frontend/frontend.hpp Co-authored-by: Roman Kazantsev * Better and correct description of convert_partially (normalize or not normalize) * Update src/frontends/common/include/openvino/frontend/frontend.hpp Co-authored-by: Maxim Vafin --------- Co-authored-by: Roman Kazantsev Co-authored-by: Maxim Vafin --- .../common/include/openvino/frontend/frontend.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontends/common/include/openvino/frontend/frontend.hpp b/src/frontends/common/include/openvino/frontend/frontend.hpp index 30717a0ecdda38..8a74d27e80c0d0 100644 --- a/src/frontends/common/include/openvino/frontend/frontend.hpp +++ b/src/frontends/common/include/openvino/frontend/frontend.hpp @@ -83,9 +83,10 @@ class FRONTEND_API FrontEnd { virtual void convert(const std::shared_ptr& partially_converted) const; /// \brief Convert only those parts of the model that can be converted leaving others - /// as-is. Converted parts are not normalized by additional transformations; normalize - /// Model or another form of convert Model should be called to finalize the - /// conversion process. + /// as-is wrapped by FrameworkNode. Converted parts are normalized by additional + /// transformations like it is done in convert method. If part of the graph cannot be + /// converted, it is not guaranteed that the converted regions are completely normalized. + /// Normalize should be called for each completely converted parts individually in this case. /// \param model Input model /// \return partially converted OV Model virtual std::shared_ptr convert_partially(const InputModel::Ptr& model) const; From e33de350633eed464e34424fa4769cfaebab958d Mon Sep 17 00:00:00 2001 From: Fang Xu Date: Fri, 11 Aug 2023 19:42:38 +0530 Subject: [PATCH 50/51] [CPU] Add max_threads_per_core setting into StreamExecutor (#18857) --- .../cpu_streams_executor_internal.hpp | 4 +- .../dev/threading/cpu_streams_executor.cpp | 29 +++- .../cpu_streams_executor_internal.cpp | 68 +++++--- src/inference/src/system_conf.cpp | 8 + src/inference/tests/unit/cpu_reserve_test.cpp | 159 +++++++++++++++++- .../tests/unit/cpu_stream_info_test.cpp | 42 ++++- 6 files changed, 266 insertions(+), 44 deletions(-) diff --git a/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp b/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp index e03388d34d5705..c85e9bc3158ec1 100644 --- a/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp +++ b/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp @@ -32,6 +32,7 @@ enum StreamCreateType { * @param[out] concurrency the number of threads created at the same time * @param[out] core_type core type * @param[out] numa_node_id numa node id + * @param[out] max_threads_per_core the max number of threads per cpu core */ void get_cur_stream_info(const int stream_id, const bool cpu_reservation, @@ -40,7 +41,8 @@ void get_cur_stream_info(const int stream_id, StreamCreateType& stream_type, int& concurrency, int& core_type, - int& numa_node_id); + int& numa_node_id, + int& max_threads_per_core); /** * @brief Reserve cpu resource by streams info diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp index d43d3b1bba46fc..dba0082d647080 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp @@ -135,19 +135,27 @@ struct CPUStreamsExecutor::Impl { const StreamCreateType stream_type, const int concurrency, const int core_type, - const int numa_node_id) { + const int numa_node_id, + const int max_threads_per_core) { _numaNodeId = std::max(0, numa_node_id); _socketId = get_socket_by_numa_node(_numaNodeId); if (stream_type == STREAM_WITHOUT_PARAM) { - _taskArena.reset(new custom::task_arena{concurrency}); + _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{} + .set_max_concurrency(concurrency) + .set_max_threads_per_core(max_threads_per_core)}); } else if (stream_type == STREAM_WITH_NUMA_ID) { - _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{_numaNodeId, concurrency}}); + _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{} + .set_numa_id(_numaNodeId) + .set_max_concurrency(concurrency) + .set_max_threads_per_core(max_threads_per_core)}); } else if (stream_type == STREAM_WITH_CORE_TYPE) { const auto real_core_type = (core_type == MAIN_CORE_PROC || core_type == HYPER_THREADING_PROC) ? custom::info::core_types().back() : custom::info::core_types().front(); - _taskArena.reset(new custom::task_arena{ - custom::task_arena::constraints{}.set_core_type(real_core_type).set_max_concurrency(concurrency)}); + _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{} + .set_core_type(real_core_type) + .set_max_concurrency(concurrency) + .set_max_threads_per_core(max_threads_per_core)}); } else { _taskArena.reset(new custom::task_arena{concurrency}); _cpu_ids = static_cast(_impl->_config._stream_processor_ids.size()) == _impl->_config._streams @@ -176,6 +184,7 @@ struct CPUStreamsExecutor::Impl { int concurrency; int cpu_core_type; int numa_node_id; + int max_threads_per_core; StreamCreateType stream_type; const auto org_proc_type_table = get_org_proc_type_table(); const auto stream_id = _streamId >= _impl->_config._streams ? _impl->_config._streams - 1 : _streamId; @@ -187,11 +196,17 @@ struct CPUStreamsExecutor::Impl { stream_type, concurrency, cpu_core_type, - numa_node_id); + numa_node_id, + max_threads_per_core); if (concurrency <= 0) { return; } - create_tbb_task_arena(stream_id, stream_type, concurrency, cpu_core_type, numa_node_id); + create_tbb_task_arena(stream_id, + stream_type, + concurrency, + cpu_core_type, + numa_node_id, + max_threads_per_core); } void init_stream_legacy() { diff --git a/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp b/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp index 44e2df4c53fccc..c05509e225c7f5 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp @@ -20,7 +20,8 @@ void get_cur_stream_info(const int stream_id, StreamCreateType& stream_type, int& concurrency, int& core_type, - int& numa_node_id) { + int& numa_node_id, + int& max_threads_per_core) { int stream_total = 0; size_t stream_info_id = 0; bool cpu_reserve = cpu_reservation; @@ -34,6 +35,21 @@ void get_cur_stream_info(const int stream_id, concurrency = streams_info_table[stream_info_id][THREADS_PER_STREAM]; core_type = streams_info_table[stream_info_id][PROC_TYPE]; numa_node_id = streams_info_table[stream_info_id][STREAM_NUMA_NODE_ID]; + max_threads_per_core = 1; + if (core_type == ALL_PROC) { + for (size_t i = stream_info_id + 1; i < streams_info_table.size(); i++) { + if (streams_info_table[i][NUMBER_OF_STREAMS] == 0) { + if (streams_info_table[i][PROC_TYPE] == HYPER_THREADING_PROC) { + max_threads_per_core = 2; + break; + } + } else { + break; + } + } + } else if (core_type == HYPER_THREADING_PROC) { + max_threads_per_core = 2; + } #if defined(_WIN32) || defined(__APPLE__) cpu_reserve = false; @@ -56,52 +72,58 @@ void reserve_cpu_by_streams_info(const std::vector> _streams_in std::vector>& _proc_type_table, std::vector>& _stream_processors, const int _cpu_status) { - std::vector> streams_info_table = _streams_info_table; + std::vector> streams_table; std::vector> stream_conditions; std::vector stream_pos; std::vector stream_num; int num_streams = 0; + int num_conditions = 0; + int condition_idx = 0; + bool last_all_proc = false; - stream_pos.assign(_streams_info_table.size(), 0); - stream_num.assign(_streams_info_table.size(), 0); for (size_t i = 0; i < _streams_info_table.size(); i++) { - stream_pos[i] = num_streams; + if (_streams_info_table[i][NUMBER_OF_STREAMS] > 0) { + stream_pos.push_back(num_streams); + } num_streams += _streams_info_table[i][NUMBER_OF_STREAMS]; } + num_conditions = static_cast(stream_pos.size()); _stream_processors.assign(num_streams, std::vector()); - stream_conditions.assign(_streams_info_table.size(), std::vector()); + stream_conditions.assign(num_conditions, std::vector()); + stream_num.assign(num_conditions, 0); + for (size_t i = 0; i < _streams_info_table.size(); i++) { std::vector proc_types; std::vector numa_nodes; std::vector sockets; - if (_streams_info_table[i][PROC_TYPE] > ALL_PROC && _streams_info_table[i][NUMBER_OF_STREAMS] > 0) { - proc_types.push_back(std::to_string(_streams_info_table[i][PROC_TYPE])); + if (_streams_info_table[i][NUMBER_OF_STREAMS] > 0) { + streams_table.push_back(_streams_info_table[i]); } - if (num_streams == 1 && _streams_info_table[0][PROC_TYPE] == MAIN_CORE_PROC && - _streams_info_table[0][THREADS_PER_STREAM] > _proc_type_table[0][MAIN_CORE_PROC]) { - proc_types.push_back(std::to_string(HYPER_THREADING_PROC)); + if (last_all_proc && _streams_info_table[i][NUMBER_OF_STREAMS] > 0) { + last_all_proc = false; + condition_idx++; } - if (_streams_info_table[i][STREAM_NUMA_NODE_ID] < 0) { - for (int j = 0; j < _numa_nodes; j++) { - numa_nodes.push_back(std::to_string(j)); - } + if (_streams_info_table[i][PROC_TYPE] > ALL_PROC) { + proc_types.push_back(std::to_string(_streams_info_table[i][PROC_TYPE])); } else { + last_all_proc = true; + } + if (_streams_info_table[i][STREAM_NUMA_NODE_ID] >= 0) { numa_nodes.push_back(std::to_string(_streams_info_table[i][STREAM_NUMA_NODE_ID])); } - if (_streams_info_table[i][STREAM_SOCKET_ID] < 0) { - for (int j = 0; j < _numa_nodes; j++) { - sockets.push_back(std::to_string(j)); - } - } else { + if (_streams_info_table[i][STREAM_SOCKET_ID] >= 0) { sockets.push_back(std::to_string(_streams_info_table[i][STREAM_SOCKET_ID])); } for (auto t : proc_types) { for (auto n : numa_nodes) { for (auto s : sockets) { - stream_conditions[i].push_back(t + n + s); + stream_conditions[condition_idx].push_back(t + n + s); } } } + if (_streams_info_table[i][PROC_TYPE] > ALL_PROC && _streams_info_table[i][NUMBER_OF_STREAMS] > 0) { + condition_idx++; + } } for (size_t i = 0; i < _cpu_mapping_table.size(); i++) { @@ -114,11 +136,11 @@ void reserve_cpu_by_streams_info(const std::vector> _streams_in _stream_processors[stream_pos[j]].push_back(_cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID]); _cpu_mapping_table[i][CPU_MAP_USED_FLAG] = _cpu_status; if (static_cast(_stream_processors[stream_pos[j]].size()) == - _streams_info_table[j][THREADS_PER_STREAM]) { + streams_table[j][THREADS_PER_STREAM]) { stream_pos[j]++; stream_num[j]++; } - if (stream_num[j] >= _streams_info_table[j][NUMBER_OF_STREAMS]) { + if (stream_num[j] >= streams_table[j][NUMBER_OF_STREAMS]) { stream_conditions[j].clear(); } break; diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp index fcd018aa467029..72437e758b7695 100644 --- a/src/inference/src/system_conf.cpp +++ b/src/inference/src/system_conf.cpp @@ -369,6 +369,14 @@ void reserve_available_cpus(const std::vector> streams_info_tab << streams_info_table[i][THREADS_PER_STREAM] << " " << streams_info_table[i][STREAM_NUMA_NODE_ID] << " " << streams_info_table[i][STREAM_SOCKET_ID]; } + OPENVINO_DEBUG << "[ threading ] stream_processors:"; + for (size_t i = 0; i < stream_processors.size(); i++) { + OPENVINO_DEBUG << "{"; + for (size_t j = 0; j < stream_processors[i].size(); j++) { + OPENVINO_DEBUG << stream_processors[i][j] << ","; + } + OPENVINO_DEBUG << "},"; + } } void set_cpu_used(const std::vector& cpu_ids, const int used) { diff --git a/src/inference/tests/unit/cpu_reserve_test.cpp b/src/inference/tests/unit/cpu_reserve_test.cpp index 523bb792b6dd97..7a5427d777bea7 100644 --- a/src/inference/tests/unit/cpu_reserve_test.cpp +++ b/src/inference/tests/unit/cpu_reserve_test.cpp @@ -199,7 +199,11 @@ LinuxCpuReserveTestCase _2sockets_72cores_hyper_7streams = { {68, 1, 1, 68, MAIN_CORE_PROC, 68, -1}, {69, 1, 1, 69, MAIN_CORE_PROC, 69, -1}, {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, }, - {{3, MAIN_CORE_PROC, 5, 0, 0}, {3, MAIN_CORE_PROC, 5, 1, 1}, {1, MAIN_CORE_PROC, 5, -1, -1}}, + {{3, MAIN_CORE_PROC, 5, 0, 0}, + {3, MAIN_CORE_PROC, 5, 1, 1}, + {1, ALL_PROC, 5, -1, -1}, + {0, MAIN_CORE_PROC, 3, 0, 0}, + {0, MAIN_CORE_PROC, 2, 1, 1}}, { {36, 37, 38, 39, 40}, {41, 42, 43, 44, 45}, @@ -308,7 +312,11 @@ LinuxCpuReserveTestCase _2sockets_72cores_hyper_9streams = { {68, 1, 1, 68, MAIN_CORE_PROC, 32, -1}, {69, 1, 1, 69, MAIN_CORE_PROC, 33, -1}, {70, 1, 1, 70, MAIN_CORE_PROC, 34, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 35, -1}, }, - {{4, MAIN_CORE_PROC, 4, 0, 0}, {4, MAIN_CORE_PROC, 4, 1, 1}, {1, MAIN_CORE_PROC, 4, -1, -1}}, + {{4, MAIN_CORE_PROC, 4, 0, 0}, + {4, MAIN_CORE_PROC, 4, 1, 1}, + {1, ALL_PROC, 4, -1, -1}, + {0, MAIN_CORE_PROC, 2, 0, 0}, + {0, MAIN_CORE_PROC, 2, 1, 1}}, { {36, 37, 38, 39}, {40, 41, 42, 43}, @@ -477,6 +485,142 @@ LinuxCpuReserveTestCase _2sockets_72cores_hyper_3streams_plugin_reserve = { }, CPU_USED, }; +LinuxCpuReserveTestCase _2sockets_104cores_2streams = { + 208, + 2, + {{208, 104, 0, 104, -1, -1}, + {52, 26, 0, 26, 0, 0}, + {52, 26, 0, 26, 1, 0}, + {52, 26, 0, 26, 2, 1}, + {52, 26, 0, 26, 3, 1}}, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {2, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, {3, 0, 0, 1, MAIN_CORE_PROC, 1, -1}, + {4, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, {5, 0, 0, 2, MAIN_CORE_PROC, 2, -1}, + {6, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, {7, 0, 0, 3, MAIN_CORE_PROC, 3, -1}, + {8, 0, 0, 4, HYPER_THREADING_PROC, 4, -1}, {9, 0, 0, 4, MAIN_CORE_PROC, 4, -1}, + {10, 0, 0, 5, HYPER_THREADING_PROC, 5, -1}, {11, 0, 0, 5, MAIN_CORE_PROC, 5, -1}, + {12, 0, 0, 6, HYPER_THREADING_PROC, 6, -1}, {13, 0, 0, 6, MAIN_CORE_PROC, 6, -1}, + {14, 0, 0, 7, HYPER_THREADING_PROC, 7, -1}, {15, 0, 0, 7, MAIN_CORE_PROC, 7, -1}, + {16, 0, 0, 8, HYPER_THREADING_PROC, 8, -1}, {17, 0, 0, 8, MAIN_CORE_PROC, 8, -1}, + {18, 0, 0, 9, HYPER_THREADING_PROC, 9, -1}, {19, 0, 0, 9, MAIN_CORE_PROC, 9, -1}, + {20, 0, 0, 10, HYPER_THREADING_PROC, 10, -1}, {21, 0, 0, 10, MAIN_CORE_PROC, 10, -1}, + {22, 0, 0, 11, HYPER_THREADING_PROC, 11, -1}, {23, 0, 0, 11, MAIN_CORE_PROC, 11, -1}, + {24, 0, 0, 12, HYPER_THREADING_PROC, 12, -1}, {25, 0, 0, 12, MAIN_CORE_PROC, 12, -1}, + {26, 1, 0, 13, HYPER_THREADING_PROC, 13, -1}, {27, 1, 0, 13, MAIN_CORE_PROC, 13, -1}, + {28, 1, 0, 14, HYPER_THREADING_PROC, 14, -1}, {29, 1, 0, 14, MAIN_CORE_PROC, 14, -1}, + {30, 1, 0, 15, HYPER_THREADING_PROC, 15, -1}, {31, 1, 0, 15, MAIN_CORE_PROC, 15, -1}, + {32, 1, 0, 16, HYPER_THREADING_PROC, 16, -1}, {33, 1, 0, 16, MAIN_CORE_PROC, 16, -1}, + {34, 1, 0, 17, HYPER_THREADING_PROC, 17, -1}, {35, 1, 0, 17, MAIN_CORE_PROC, 17, -1}, + {36, 1, 0, 18, HYPER_THREADING_PROC, 18, -1}, {37, 1, 0, 18, MAIN_CORE_PROC, 18, -1}, + {38, 1, 0, 19, HYPER_THREADING_PROC, 19, -1}, {39, 1, 0, 19, MAIN_CORE_PROC, 19, -1}, + {40, 1, 0, 20, HYPER_THREADING_PROC, 20, -1}, {41, 1, 0, 20, MAIN_CORE_PROC, 20, -1}, + {42, 1, 0, 21, HYPER_THREADING_PROC, 21, -1}, {43, 1, 0, 21, MAIN_CORE_PROC, 21, -1}, + {44, 1, 0, 22, HYPER_THREADING_PROC, 22, -1}, {45, 1, 0, 22, MAIN_CORE_PROC, 22, -1}, + {46, 1, 0, 23, HYPER_THREADING_PROC, 23, -1}, {47, 1, 0, 23, MAIN_CORE_PROC, 23, -1}, + {48, 1, 0, 24, HYPER_THREADING_PROC, 24, -1}, {49, 1, 0, 24, MAIN_CORE_PROC, 24, -1}, + {50, 1, 0, 25, HYPER_THREADING_PROC, 25, -1}, {51, 1, 0, 25, MAIN_CORE_PROC, 25, -1}, + {52, 2, 1, 26, HYPER_THREADING_PROC, 26, -1}, {53, 2, 1, 26, MAIN_CORE_PROC, 26, -1}, + {54, 2, 1, 27, HYPER_THREADING_PROC, 27, -1}, {55, 2, 1, 27, MAIN_CORE_PROC, 27, -1}, + {56, 2, 1, 28, HYPER_THREADING_PROC, 28, -1}, {57, 2, 1, 28, MAIN_CORE_PROC, 28, -1}, + {58, 2, 1, 29, HYPER_THREADING_PROC, 29, -1}, {59, 2, 1, 29, MAIN_CORE_PROC, 29, -1}, + {60, 2, 1, 30, HYPER_THREADING_PROC, 30, -1}, {61, 2, 1, 30, MAIN_CORE_PROC, 30, -1}, + {62, 2, 1, 31, HYPER_THREADING_PROC, 31, -1}, {63, 2, 1, 31, MAIN_CORE_PROC, 31, -1}, + {64, 2, 1, 32, HYPER_THREADING_PROC, 32, -1}, {65, 2, 1, 32, MAIN_CORE_PROC, 32, -1}, + {66, 2, 1, 33, HYPER_THREADING_PROC, 33, -1}, {67, 2, 1, 33, MAIN_CORE_PROC, 33, -1}, + {68, 2, 1, 34, HYPER_THREADING_PROC, 34, -1}, {69, 2, 1, 34, MAIN_CORE_PROC, 34, -1}, + {70, 2, 1, 35, HYPER_THREADING_PROC, 35, -1}, {71, 2, 1, 35, MAIN_CORE_PROC, 35, -1}, + {72, 2, 1, 36, HYPER_THREADING_PROC, 36, -1}, {73, 2, 1, 36, MAIN_CORE_PROC, 36, -1}, + {74, 2, 1, 37, HYPER_THREADING_PROC, 37, -1}, {75, 2, 1, 37, MAIN_CORE_PROC, 37, -1}, + {76, 2, 1, 38, HYPER_THREADING_PROC, 38, -1}, {77, 2, 1, 38, MAIN_CORE_PROC, 38, -1}, + {78, 3, 1, 39, HYPER_THREADING_PROC, 39, -1}, {79, 3, 1, 39, MAIN_CORE_PROC, 39, -1}, + {80, 3, 1, 40, HYPER_THREADING_PROC, 40, -1}, {81, 3, 1, 40, MAIN_CORE_PROC, 40, -1}, + {82, 3, 1, 41, HYPER_THREADING_PROC, 41, -1}, {83, 3, 1, 41, MAIN_CORE_PROC, 41, -1}, + {84, 3, 1, 42, HYPER_THREADING_PROC, 42, -1}, {85, 3, 1, 42, MAIN_CORE_PROC, 42, -1}, + {86, 3, 1, 43, HYPER_THREADING_PROC, 43, -1}, {87, 3, 1, 43, MAIN_CORE_PROC, 43, -1}, + {88, 3, 1, 44, HYPER_THREADING_PROC, 44, -1}, {89, 3, 1, 44, MAIN_CORE_PROC, 44, -1}, + {90, 3, 1, 45, HYPER_THREADING_PROC, 45, -1}, {91, 3, 1, 45, MAIN_CORE_PROC, 45, -1}, + {92, 3, 1, 46, HYPER_THREADING_PROC, 46, -1}, {93, 3, 1, 46, MAIN_CORE_PROC, 46, -1}, + {94, 3, 1, 47, HYPER_THREADING_PROC, 47, -1}, {95, 3, 1, 47, MAIN_CORE_PROC, 47, -1}, + {96, 3, 1, 48, HYPER_THREADING_PROC, 48, -1}, {97, 3, 1, 48, MAIN_CORE_PROC, 48, -1}, + {98, 3, 1, 49, HYPER_THREADING_PROC, 49, -1}, {99, 3, 1, 49, MAIN_CORE_PROC, 49, -1}, + {100, 3, 1, 50, HYPER_THREADING_PROC, 50, -1}, {101, 3, 1, 50, MAIN_CORE_PROC, 50, -1}, + {102, 3, 1, 51, HYPER_THREADING_PROC, 51, -1}, {103, 3, 1, 51, MAIN_CORE_PROC, 51, -1}, + {104, 0, 0, 52, HYPER_THREADING_PROC, 52, -1}, {105, 0, 0, 52, MAIN_CORE_PROC, 52, -1}, + {106, 0, 0, 53, HYPER_THREADING_PROC, 53, -1}, {107, 0, 0, 53, MAIN_CORE_PROC, 53, -1}, + {108, 0, 0, 54, HYPER_THREADING_PROC, 54, -1}, {109, 0, 0, 54, MAIN_CORE_PROC, 54, -1}, + {110, 0, 0, 55, HYPER_THREADING_PROC, 55, -1}, {111, 0, 0, 55, MAIN_CORE_PROC, 55, -1}, + {112, 0, 0, 56, HYPER_THREADING_PROC, 56, -1}, {113, 0, 0, 56, MAIN_CORE_PROC, 56, -1}, + {114, 0, 0, 57, HYPER_THREADING_PROC, 57, -1}, {115, 0, 0, 57, MAIN_CORE_PROC, 57, -1}, + {116, 0, 0, 58, HYPER_THREADING_PROC, 58, -1}, {117, 0, 0, 58, MAIN_CORE_PROC, 58, -1}, + {118, 0, 0, 59, HYPER_THREADING_PROC, 59, -1}, {119, 0, 0, 59, MAIN_CORE_PROC, 59, -1}, + {120, 0, 0, 60, HYPER_THREADING_PROC, 60, -1}, {121, 0, 0, 60, MAIN_CORE_PROC, 60, -1}, + {122, 0, 0, 61, HYPER_THREADING_PROC, 61, -1}, {123, 0, 0, 61, MAIN_CORE_PROC, 61, -1}, + {124, 0, 0, 62, HYPER_THREADING_PROC, 62, -1}, {125, 0, 0, 62, MAIN_CORE_PROC, 62, -1}, + {126, 0, 0, 63, HYPER_THREADING_PROC, 63, -1}, {127, 0, 0, 63, MAIN_CORE_PROC, 63, -1}, + {128, 0, 0, 64, HYPER_THREADING_PROC, 64, -1}, {129, 0, 0, 64, MAIN_CORE_PROC, 64, -1}, + {130, 1, 0, 65, HYPER_THREADING_PROC, 65, -1}, {131, 1, 0, 65, MAIN_CORE_PROC, 65, -1}, + {132, 1, 0, 66, HYPER_THREADING_PROC, 66, -1}, {133, 1, 0, 66, MAIN_CORE_PROC, 66, -1}, + {134, 1, 0, 67, HYPER_THREADING_PROC, 67, -1}, {135, 1, 0, 67, MAIN_CORE_PROC, 67, -1}, + {136, 1, 0, 68, HYPER_THREADING_PROC, 68, -1}, {137, 1, 0, 68, MAIN_CORE_PROC, 68, -1}, + {138, 1, 0, 69, HYPER_THREADING_PROC, 69, -1}, {139, 1, 0, 69, MAIN_CORE_PROC, 69, -1}, + {140, 1, 0, 70, HYPER_THREADING_PROC, 70, -1}, {141, 1, 0, 70, MAIN_CORE_PROC, 70, -1}, + {142, 1, 0, 71, HYPER_THREADING_PROC, 71, -1}, {143, 1, 0, 71, MAIN_CORE_PROC, 71, -1}, + {144, 1, 0, 72, HYPER_THREADING_PROC, 72, -1}, {145, 1, 0, 72, MAIN_CORE_PROC, 72, -1}, + {146, 1, 0, 73, HYPER_THREADING_PROC, 73, -1}, {147, 1, 0, 73, MAIN_CORE_PROC, 73, -1}, + {148, 1, 0, 74, HYPER_THREADING_PROC, 74, -1}, {149, 1, 0, 74, MAIN_CORE_PROC, 74, -1}, + {150, 1, 0, 75, HYPER_THREADING_PROC, 75, -1}, {151, 1, 0, 75, MAIN_CORE_PROC, 75, -1}, + {152, 1, 0, 76, HYPER_THREADING_PROC, 76, -1}, {153, 1, 0, 76, MAIN_CORE_PROC, 76, -1}, + {154, 1, 0, 77, HYPER_THREADING_PROC, 77, -1}, {155, 1, 0, 77, MAIN_CORE_PROC, 77, -1}, + {156, 2, 1, 78, HYPER_THREADING_PROC, 78, -1}, {157, 2, 1, 78, MAIN_CORE_PROC, 78, -1}, + {158, 2, 1, 79, HYPER_THREADING_PROC, 79, -1}, {159, 2, 1, 79, MAIN_CORE_PROC, 79, -1}, + {160, 2, 1, 80, HYPER_THREADING_PROC, 80, -1}, {161, 2, 1, 80, MAIN_CORE_PROC, 80, -1}, + {162, 2, 1, 81, HYPER_THREADING_PROC, 81, -1}, {163, 2, 1, 81, MAIN_CORE_PROC, 81, -1}, + {164, 2, 1, 82, HYPER_THREADING_PROC, 82, -1}, {165, 2, 1, 82, MAIN_CORE_PROC, 82, -1}, + {166, 2, 1, 83, HYPER_THREADING_PROC, 83, -1}, {167, 2, 1, 83, MAIN_CORE_PROC, 83, -1}, + {168, 2, 1, 84, HYPER_THREADING_PROC, 84, -1}, {169, 2, 1, 84, MAIN_CORE_PROC, 84, -1}, + {170, 2, 1, 85, HYPER_THREADING_PROC, 85, -1}, {171, 2, 1, 85, MAIN_CORE_PROC, 85, -1}, + {172, 2, 1, 86, HYPER_THREADING_PROC, 86, -1}, {173, 2, 1, 86, MAIN_CORE_PROC, 86, -1}, + {174, 2, 1, 87, HYPER_THREADING_PROC, 87, -1}, {175, 2, 1, 87, MAIN_CORE_PROC, 87, -1}, + {176, 2, 1, 88, HYPER_THREADING_PROC, 88, -1}, {177, 2, 1, 88, MAIN_CORE_PROC, 88, -1}, + {178, 2, 1, 89, HYPER_THREADING_PROC, 89, -1}, {179, 2, 1, 89, MAIN_CORE_PROC, 89, -1}, + {180, 2, 1, 90, HYPER_THREADING_PROC, 90, -1}, {181, 2, 1, 90, MAIN_CORE_PROC, 90, -1}, + {182, 3, 1, 91, HYPER_THREADING_PROC, 91, -1}, {183, 3, 1, 91, MAIN_CORE_PROC, 91, -1}, + {184, 3, 1, 92, HYPER_THREADING_PROC, 92, -1}, {185, 3, 1, 92, MAIN_CORE_PROC, 92, -1}, + {186, 3, 1, 93, HYPER_THREADING_PROC, 93, -1}, {187, 3, 1, 93, MAIN_CORE_PROC, 93, -1}, + {188, 3, 1, 94, HYPER_THREADING_PROC, 94, -1}, {189, 3, 1, 94, MAIN_CORE_PROC, 94, -1}, + {190, 3, 1, 95, HYPER_THREADING_PROC, 95, -1}, {191, 3, 1, 95, MAIN_CORE_PROC, 95, -1}, + {192, 3, 1, 96, HYPER_THREADING_PROC, 96, -1}, {193, 3, 1, 96, MAIN_CORE_PROC, 96, -1}, + {194, 3, 1, 97, HYPER_THREADING_PROC, 97, -1}, {195, 3, 1, 97, MAIN_CORE_PROC, 97, -1}, + {196, 3, 1, 98, HYPER_THREADING_PROC, 98, -1}, {197, 3, 1, 98, MAIN_CORE_PROC, 98, -1}, + {198, 3, 1, 99, HYPER_THREADING_PROC, 99, -1}, {199, 3, 1, 99, MAIN_CORE_PROC, 99, -1}, + {200, 3, 1, 100, HYPER_THREADING_PROC, 100, -1}, {201, 3, 1, 100, MAIN_CORE_PROC, 100, -1}, + {202, 3, 1, 101, HYPER_THREADING_PROC, 101, -1}, {203, 3, 1, 101, MAIN_CORE_PROC, 101, -1}, + {204, 3, 1, 102, HYPER_THREADING_PROC, 102, -1}, {205, 3, 1, 102, MAIN_CORE_PROC, 102, -1}, + {206, 3, 1, 103, HYPER_THREADING_PROC, 103, -1}, {207, 3, 1, 103, MAIN_CORE_PROC, 103, -1}, + }, + {{1, ALL_PROC, 104, -1, 0}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, HYPER_THREADING_PROC, 26, 0, 0}, + {0, HYPER_THREADING_PROC, 26, 1, 0}, + {1, ALL_PROC, 104, -1, 1}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}, + {0, HYPER_THREADING_PROC, 26, 2, 1}, + {0, HYPER_THREADING_PROC, 26, 3, 1}}, + {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155}, + {52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, + 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, + 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207}}, + NOT_USED, +}; LinuxCpuReserveTestCase _2sockets_20cores_hyper_20streams = { 40, 2, @@ -574,7 +718,11 @@ LinuxCpuReserveTestCase _2sockets_20cores_hyper_5streams = { {38, 0, 0, 38, MAIN_CORE_PROC, 18, -1}, {39, 1, 1, 39, MAIN_CORE_PROC, 19, -1}, }, - {{2, MAIN_CORE_PROC, 4, 0, 0}, {2, MAIN_CORE_PROC, 4, 1, 1}, {1, MAIN_CORE_PROC, 4, -1, -1}}, + {{2, MAIN_CORE_PROC, 4, 0, 0}, + {2, MAIN_CORE_PROC, 4, 1, 1}, + {1, ALL_PROC, 4, -1, -1}, + {0, MAIN_CORE_PROC, 2, 0, 0}, + {0, MAIN_CORE_PROC, 2, 1, 1}}, { {20, 22, 24, 26}, {28, 30, 32, 34}, @@ -747,7 +895,7 @@ LinuxCpuReserveTestCase _1socket_18cores_hyper_1streams = { {32, 0, 0, 14, MAIN_CORE_PROC, 14, -1}, {33, 0, 0, 15, MAIN_CORE_PROC, 15, -1}, {34, 0, 0, 16, MAIN_CORE_PROC, 16, -1}, {35, 0, 0, 17, MAIN_CORE_PROC, 17, -1}, }, - {{1, MAIN_CORE_PROC, 36, 0, 0}}, + {{1, ALL_PROC, 36, 0, 0}, {0, MAIN_CORE_PROC, 18, 0, 0}, {0, HYPER_THREADING_PROC, 18, 0, 0}}, { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}, @@ -809,7 +957,7 @@ LinuxCpuReserveTestCase _1socket_32cores_hyper_1streams = { }, {{1, ALL_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 8, 0, 0}, {0, EFFICIENT_CORE_PROC, 16, 0, 0}}, { - {}, + {1, 3, 5, 7, 9, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, }, NOT_USED, }; @@ -826,6 +974,7 @@ INSTANTIATE_TEST_SUITE_P(CPUReserve, _2sockets_72cores_hyper_3streams, _2sockets_72cores_hyper_5streams, _2sockets_72cores_hyper_3streams_plugin_reserve, + _2sockets_104cores_2streams, _2sockets_20cores_hyper_20streams, _2sockets_20cores_hyper_4streams, _2sockets_20cores_hyper_5streams, diff --git a/src/inference/tests/unit/cpu_stream_info_test.cpp b/src/inference/tests/unit/cpu_stream_info_test.cpp index f9c297f87bdff5..51d07015077fb1 100644 --- a/src/inference/tests/unit/cpu_stream_info_test.cpp +++ b/src/inference/tests/unit/cpu_stream_info_test.cpp @@ -30,6 +30,7 @@ struct LinuxCpuStreamTypeCase { std::vector _concurrency; std::vector _core_type; std::vector _numa_node_id; + std::vector _max_threads_per_core; }; class LinuxCpuStreamTypeTests : public ov::test::TestsCommon, @@ -43,6 +44,7 @@ class LinuxCpuStreamTypeTests : public ov::test::TestsCommon, std::vector test_concurrencys; std::vector test_core_types; std::vector test_numa_node_ids; + std::vector test_max_threads_per_cores; int streams = 0; for (size_t i = 0; i < test_data._streams_info_table.size(); i++) { @@ -61,6 +63,7 @@ class LinuxCpuStreamTypeTests : public ov::test::TestsCommon, int test_concurrency; int test_core_type; int test_numa_node_id; + int test_max_threads_per_core; get_cur_stream_info(i, test_data._cpu_reservation, test_data._proc_type_table, @@ -68,17 +71,20 @@ class LinuxCpuStreamTypeTests : public ov::test::TestsCommon, test_stream_type, test_concurrency, test_core_type, - test_numa_node_id); + test_numa_node_id, + test_max_threads_per_core); test_stream_types.push_back(test_stream_type); test_concurrencys.push_back(test_concurrency); test_core_types.push_back(test_core_type); test_numa_node_ids.push_back(test_numa_node_id); + test_max_threads_per_cores.push_back(test_max_threads_per_core); } ASSERT_EQ(test_data._stream_type, test_stream_types); ASSERT_EQ(test_data._concurrency, test_concurrencys); ASSERT_EQ(test_data._core_type, test_core_types); ASSERT_EQ(test_data._numa_node_id, test_numa_node_ids); + ASSERT_EQ(test_data._max_threads_per_core, test_max_threads_per_cores); } }; @@ -152,6 +158,8 @@ LinuxCpuStreamTypeCase _2sockets_72cores_nobinding_36streams = { }, // param[out]: numa_node_id per stream used in new task_arena {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + // param[out]: max_threads_per_core per stream used in new task_arena + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, }; LinuxCpuStreamTypeCase _2sockets_72cores_nobinding_9streams = { false, @@ -195,7 +203,11 @@ LinuxCpuStreamTypeCase _2sockets_72cores_nobinding_9streams = { {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, }, {{72, 36, 0, 36, -1, -1}, {36, 18, 0, 18, 0, 0}, {36, 18, 0, 18, 1, 1}}, - {{4, MAIN_CORE_PROC, 4, 0, 0}, {4, MAIN_CORE_PROC, 4, 1, 1}, {1, MAIN_CORE_PROC, 4, -1, -1}}, + {{4, MAIN_CORE_PROC, 4, 0, 0}, + {4, MAIN_CORE_PROC, 4, 1, 1}, + {1, ALL_PROC, 4, -1, -1}, + {0, MAIN_CORE_PROC, 2, 0, 0}, + {0, MAIN_CORE_PROC, 2, 1, 1}}, { STREAM_WITH_NUMA_ID, STREAM_WITH_NUMA_ID, @@ -217,9 +229,10 @@ LinuxCpuStreamTypeCase _2sockets_72cores_nobinding_9streams = { MAIN_CORE_PROC, MAIN_CORE_PROC, MAIN_CORE_PROC, - MAIN_CORE_PROC, + ALL_PROC, }, {0, 0, 0, 0, 1, 1, 1, 1, NUMA_ALL}, + {1, 1, 1, 1, 1, 1, 1, 1, 1}, }; LinuxCpuStreamTypeCase _2sockets_72cores_binding_9streams = { true, @@ -263,7 +276,11 @@ LinuxCpuStreamTypeCase _2sockets_72cores_binding_9streams = { {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, }, {{72, 36, 0, 36, -1, -1}, {36, 18, 0, 18, 0, 0}, {36, 18, 0, 18, 1, 1}}, - {{4, MAIN_CORE_PROC, 4, 0, 0}, {4, MAIN_CORE_PROC, 4, 1, 1}, {1, MAIN_CORE_PROC, 4, -1, -1}}, + {{4, MAIN_CORE_PROC, 4, 0, 0}, + {4, MAIN_CORE_PROC, 4, 1, 1}, + {1, ALL_PROC, 4, -1, -1}, + {0, MAIN_CORE_PROC, 2, 0, 0}, + {0, MAIN_CORE_PROC, 2, 1, 1}}, # if defined(__linux__) { STREAM_WITH_OBSERVE, @@ -299,9 +316,10 @@ LinuxCpuStreamTypeCase _2sockets_72cores_binding_9streams = { MAIN_CORE_PROC, MAIN_CORE_PROC, MAIN_CORE_PROC, - MAIN_CORE_PROC, + ALL_PROC, }, {0, 0, 0, 0, 1, 1, 1, 1, NUMA_ALL}, + {1, 1, 1, 1, 1, 1, 1, 1, 1}, }; LinuxCpuStreamTypeCase _1sockets_4cores_nobinding = { false, @@ -317,11 +335,12 @@ LinuxCpuStreamTypeCase _1sockets_4cores_nobinding = { {7, 0, 0, 3, MAIN_CORE_PROC, 3, -1}, }, {{8, 4, 0, 4, 0, 0}}, - {{1, MAIN_CORE_PROC, 8, 0, 0}}, + {{1, ALL_PROC, 8, 0, 0}, {0, MAIN_CORE_PROC, 4, 0, 0}, {0, HYPER_THREADING_PROC, 4, 0, 0}}, {STREAM_WITHOUT_PARAM}, {8}, - {MAIN_CORE_PROC}, + {ALL_PROC}, {0}, + {2}, }; LinuxCpuStreamTypeCase _1sockets_4cores_binding = { true, @@ -361,7 +380,9 @@ LinuxCpuStreamTypeCase _1sockets_4cores_binding = { MAIN_CORE_PROC, }, {0, 0, 0, 0}, + {1, 1, 1, 1}, }; + LinuxCpuStreamTypeCase _1sockets_12cores_pcore_nobinding = { false, 1, @@ -383,6 +404,7 @@ LinuxCpuStreamTypeCase _1sockets_12cores_pcore_nobinding = { {8}, {MAIN_CORE_PROC}, {0}, + {1}, }; LinuxCpuStreamTypeCase _1sockets_12cores_pcore_binding = { true, @@ -418,6 +440,7 @@ LinuxCpuStreamTypeCase _1sockets_12cores_pcore_binding = { MAIN_CORE_PROC, }, {0, 0}, + {1, 1}, }; LinuxCpuStreamTypeCase _1sockets_12cores_ecore_nobinding = { false, @@ -446,6 +469,7 @@ LinuxCpuStreamTypeCase _1sockets_12cores_ecore_nobinding = { EFFICIENT_CORE_PROC, }, {0, 0}, + {1, 1}, }; LinuxCpuStreamTypeCase _1sockets_12cores_ecore_binding = { true, @@ -487,6 +511,7 @@ LinuxCpuStreamTypeCase _1sockets_12cores_ecore_binding = { EFFICIENT_CORE_PROC, }, {0, 0, 0, 0}, + {1, 1, 1, 1}, }; LinuxCpuStreamTypeCase _1sockets_24cores_all_proc = { false, @@ -510,11 +535,12 @@ LinuxCpuStreamTypeCase _1sockets_24cores_all_proc = { {30, 0, 0, 22, EFFICIENT_CORE_PROC, 11, -1}, {31, 0, 0, 23, EFFICIENT_CORE_PROC, 11, -1}, }, {{32, 8, 16, 8, 0, 0}}, - {{1, ALL_PROC, 24, 0, 0}}, + {{1, ALL_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 8, 0, 0}, {0, EFFICIENT_CORE_PROC, 16, 0, 0}}, {STREAM_WITHOUT_PARAM}, {24}, {ALL_PROC}, {0}, + {1}, }; TEST_P(LinuxCpuStreamTypeTests, LinuxCpuStreamType) {} From 396a899b752ccb7fd8bf79e73e0e2e7fb2d280f8 Mon Sep 17 00:00:00 2001 From: Zlobin Vladimir Date: Fri, 11 Aug 2023 19:09:48 +0400 Subject: [PATCH 51/51] benhcmark_app: fix -api sync -i multiple images (#19142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Python version uses `app_inputs_info` to represent different input configurations, but the C++ version extends that use case and uses `app_inputs_info` to represent different input images as well. That means that the assumption that if `app_input_info.size() > 1`, then input shape is dynamic, doesn’t always hold for C++ Ticket 117673 --- samples/cpp/benchmark_app/utils.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/samples/cpp/benchmark_app/utils.cpp b/samples/cpp/benchmark_app/utils.cpp index af0691693545d9..a22040a10b9dc8 100644 --- a/samples/cpp/benchmark_app/utils.cpp +++ b/samples/cpp/benchmark_app/utils.cpp @@ -109,7 +109,14 @@ std::vector split_float(const std::string& s, char delim) { } bool can_measure_as_static(const std::vector& app_input_info) { - return app_input_info.size() == 1; + for (const benchmark_app::InputsInfo& info : app_input_info) { + for (const auto& pair : info) { + if (pair.second.partialShape.is_dynamic() && app_input_info.size() > 1) { + return false; + } + } + } + return true; } static const std::vector meta_plugins{"MULTI", "HETERO", "AUTO"};