From 05cae2714f395a87e62e1d845e02c5377f69f89e Mon Sep 17 00:00:00 2001 From: Mikhail Nosov Date: Tue, 27 Apr 2021 08:59:20 +0300 Subject: [PATCH 1/8] Generate unique file names for GNAAOTTests (#5403) Issue can be reproduced on stress testing: Get stress scripts from git@github.com:google/gtest-parallel.git > python3 /gtest-parallel/gtest_parallel.py ./InferenceEngineUnitTests --gtest_filter=*GNAAOT* -r 100 It starts each test separately in different threads/processes and there is big chance of conflicts with unit_tests.bin --- .../unit/engines/gna/gna_graph_aot_test.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp index 74fbe74043f..a9c8844f11c 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp @@ -3,6 +3,8 @@ // #include +#include +#include #include #include #include "gna_matcher.hpp" @@ -18,6 +20,15 @@ class GNAAOTTests : public GNATest<>{ files_to_remove.push_back(file_to_remove); return file_to_remove; } + + std::string generateFileName(const std::string& baseName) const { + using namespace std::chrono; + std::stringstream ss; + auto ts = duration_cast(high_resolution_clock::now().time_since_epoch()); + ss << std::this_thread::get_id() << "_" << ts.count() << "_" << baseName; + return ss.str(); + } + void TearDown() override { for (auto & file : files_to_remove) { std::remove(file.c_str()); @@ -30,7 +41,7 @@ class GNAAOTTests : public GNATest<>{ TEST_F(GNAAOTTests, DISABLED_AffineWith2AffineOutputs_canbe_export_imported) { - const std::string X = registerFileForRemove("unit_tests.bin"); + const std::string X = registerFileForRemove(generateFileName("unit_tests.bin")); // running export to a file export_network(AffineWith2AffineOutputsModel()) @@ -52,7 +63,7 @@ TEST_F(GNAAOTTests, DISABLED_AffineWith2AffineOutputs_canbe_imported_verify_stru save_args().onInferModel(AffineWith2AffineOutputsModel()) .inNotCompactMode().withGNAConfig(GNA_CONFIG_KEY(SCALE_FACTOR), 1.0f).from().gna().propagate_forward().to(&nnet_type); - const std::string X = registerFileForRemove("unit_tests.bin"); + const std::string X = registerFileForRemove(generateFileName("unit_tests.bin")); // running export to a file export_network(AffineWith2AffineOutputsModel()) @@ -70,7 +81,7 @@ TEST_F(GNAAOTTests, TwoInputsModel_canbe_export_imported) { GTEST_SKIP(); #endif - const std::string X = registerFileForRemove("unit_tests.bin"); + const std::string X = registerFileForRemove(generateFileName("unit_tests.bin")); // running export to a file export_network(TwoInputsModelForIO()) @@ -90,7 +101,7 @@ TEST_F(GNAAOTTests, PermuteModel_canbe_export_imported) { GTEST_SKIP(); #endif - const std::string X = registerFileForRemove("unit_tests.bin"); + const std::string X = registerFileForRemove(generateFileName("unit_tests.bin")); // running export to a file export_network(PermuteModelForIO()) @@ -107,7 +118,7 @@ TEST_F(GNAAOTTests, PoolingModel_canbe_export_imported) { GTEST_SKIP(); #endif - const std::string X = registerFileForRemove("unit_tests.bin"); + const std::string X = registerFileForRemove(generateFileName("unit_tests.bin")); // running export to a file export_network(maxpoolAfterRelu()) @@ -127,7 +138,7 @@ TEST_F(GNAAOTTests, DISABLED_CanConvertFromAOTtoSueModel) { .inNotCompactMode().inNotCompactMode().withGNAConfig(GNA_CONFIG_KEY(SCALE_FACTOR), 1.0f) .from().gna().propagate_forward().to(&nnet_type); - const std::string X = registerFileForRemove("unit_tests.bin"); + const std::string X = registerFileForRemove(generateFileName("unit_tests.bin")); // running export to a file export_network(AffineWith2AffineOutputsModel()) From 0337b055dbb1f045437d3cef08b482942cdd2a88 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 27 Apr 2021 09:12:55 +0300 Subject: [PATCH 2/8] Added GetAvailableDevices for AUTO device (#5377) * Added GetAvailableDevices for AUTO device * Fixed tests compilation --- inference-engine/include/ie_core.hpp | 2 +- .../src/inference_engine/ie_core.cpp | 67 +++++++++++-------- inference-engine/src/plugin_api/ie_icore.hpp | 8 +++ .../cpp_interfaces/interface/mock_icore.hpp | 1 + 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/inference-engine/include/ie_core.hpp b/inference-engine/include/ie_core.hpp index fddf2b29069..2829d3234f2 100644 --- a/inference-engine/include/ie_core.hpp +++ b/inference-engine/include/ie_core.hpp @@ -238,7 +238,7 @@ public: * @brief Returns devices available for neural networks inference * * @return A vector of devices. The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD } - If there more than one device of specific type, they are enumerated with .# suffix. + * If there more than one device of specific type, they are enumerated with .# suffix. */ std::vector GetAvailableDevices() const; diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index 2143bafbccd..94165f0887b 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -591,6 +591,43 @@ public: return copyParameterValue(GetCPPPluginByName(parsed._deviceName).GetMetric(name, parsed._config)); } + /** + * @brief Returns devices available for neural networks inference + * + * @return A vector of devices. The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD } + * If there more than one device of specific type, they are enumerated with .# suffix. + */ + std::vector GetAvailableDevices() const override { + std::vector devices; + const std::string propertyName = METRIC_KEY(AVAILABLE_DEVICES); + + for (auto&& deviceName : GetListOfDevicesInRegistry()) { + std::vector devicesIDs; + try { + const Parameter p = GetMetric(deviceName, propertyName); + devicesIDs = p.as>(); + } catch (Exception&) { + // plugin is not created by e.g. invalid env + } catch (const std::exception& ex) { + IE_THROW() << "An exception is thrown while trying to create the " << deviceName + << " device and call GetMetric: " << ex.what(); + } catch (...) { + IE_THROW() << "Unknown exception is thrown while trying to create the " << deviceName + << " device and call GetMetric"; + } + + if (devicesIDs.size() > 1) { + for (auto&& deviceID : devicesIDs) { + devices.push_back(deviceName + '.' + deviceID); + } + } else if (!devicesIDs.empty()) { + devices.push_back(deviceName); + } + } + + return devices; + } + /** * @brief Returns reference to CPP plugin wrapper by a device name * @param deviceName A name of device @@ -1007,35 +1044,7 @@ Parameter Core::GetMetric(const std::string& deviceName, const std::string& name } std::vector Core::GetAvailableDevices() const { - std::vector devices; - - std::string propertyName = METRIC_KEY(AVAILABLE_DEVICES); - - for (auto&& deviceName : _impl->GetListOfDevicesInRegistry()) { - std::vector devicesIDs; - try { - Parameter p = GetMetric(deviceName, propertyName); - devicesIDs = p.as>(); - } catch (Exception&) { - // plugin is not created by e.g. invalid env - } catch (const std::exception& ex) { - IE_THROW() << "An exception is thrown while trying to create the " << deviceName - << " device and call GetMetric: " << ex.what(); - } catch (...) { - IE_THROW() << "Unknown exception is thrown while trying to create the " << deviceName - << " device and call GetMetric"; - } - - if (devicesIDs.size() > 1) { - for (auto&& deviceID : devicesIDs) { - devices.push_back(deviceName + '.' + deviceID); - } - } else if (!devicesIDs.empty()) { - devices.push_back(deviceName); - } - } - - return devices; + return _impl->GetAvailableDevices(); } void Core::RegisterPlugin(const std::string& pluginName, const std::string& deviceName) { diff --git a/inference-engine/src/plugin_api/ie_icore.hpp b/inference-engine/src/plugin_api/ie_icore.hpp index 7534c8c765e..d8acf837640 100644 --- a/inference-engine/src/plugin_api/ie_icore.hpp +++ b/inference-engine/src/plugin_api/ie_icore.hpp @@ -100,6 +100,14 @@ public: */ virtual Parameter GetMetric(const std::string& deviceName, const std::string& name) const = 0; + /** + * @brief Returns devices available for neural networks inference + * + * @return A vector of devices. The devices are returned as { CPU, FPGA.0, FPGA.1, MYRIAD } + * If there more than one device of specific type, they are enumerated with .# suffix. + */ + virtual std::vector GetAvailableDevices() const = 0; + /** * @brief Default virtual destructor */ diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp index e52f79bb156..c1adf355f16 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp @@ -28,6 +28,7 @@ public: const InferenceEngine::CNNNetwork&, const std::string&, const std::map&)); MOCK_QUALIFIED_METHOD2(GetMetric, const, InferenceEngine::Parameter(const std::string&, const std::string&)); + MOCK_QUALIFIED_METHOD0(GetAvailableDevices, const, std::vector()); ~MockICore() = default; }; From fa7d67b07f3defa8688ea3b01f1d37db4fb1187f Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 27 Apr 2021 10:18:19 +0300 Subject: [PATCH 3/8] Removed reading of port precision (#5397) --- inference-engine/src/readers/ir_reader/ie_ir_parser.cpp | 7 ------- inference-engine/src/readers/ir_reader/ie_ir_parser.hpp | 1 - 2 files changed, 8 deletions(-) diff --git a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp index a3daa63c9da..919ecbddfe1 100644 --- a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp +++ b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp @@ -700,13 +700,6 @@ V10Parser::V10Parser::GenericLayerParams XmlDeserializer::parseGenericParams( port.dims.push_back(dim); } - ngraph::element::Type type(ngraph::element::Type_t::undefined); - // Input port hasn't precision - if (!input) { - const std::string& preStr = GetStrAttr(parentNode, "precision"); - type = InferenceEngine::details::convertPrecision(preStr); - } - port.precision = type; std::vector names; if (getParameters(parentNode, "names", names)) { for (size_t i = 0; i < names.size(); i++) { diff --git a/inference-engine/src/readers/ir_reader/ie_ir_parser.hpp b/inference-engine/src/readers/ir_reader/ie_ir_parser.hpp index b482c9fb8b5..e8fdef8a034 100644 --- a/inference-engine/src/readers/ir_reader/ie_ir_parser.hpp +++ b/inference-engine/src/readers/ir_reader/ie_ir_parser.hpp @@ -67,7 +67,6 @@ public: struct GenericLayerParams { struct LayerPortData { size_t portId; - ngraph::element::Type_t precision; SizeVector dims; std::unordered_set names; }; From 3028c785943cfd5ab471dd2b10214689cfed733d Mon Sep 17 00:00:00 2001 From: Svetlana Dolinina Date: Tue, 27 Apr 2021 13:37:02 +0300 Subject: [PATCH 4/8] fix typo + test (#5392) --- .../mo/front/kaldi/loader/loader.py | 4 +-- .../mo/front/kaldi/loader/loader_test.py | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/model-optimizer/mo/front/kaldi/loader/loader.py b/model-optimizer/mo/front/kaldi/loader/loader.py index 3d60677e412..999207287cc 100644 --- a/model-optimizer/mo/front/kaldi/loader/loader.py +++ b/model-optimizer/mo/front/kaldi/loader/loader.py @@ -337,7 +337,7 @@ def read_node(file_descr, graph, component_layer_map, layer_node_map): in_port = len(Node(graph, node_name).in_nodes()) Node(graph, node_name).add_input_port(in_port) - Node(graph, in_node_id).add_output_port(out_port) + Node(graph, in_node_id).add_output_port(out_port, skip_if_exist=True) graph.add_edge(in_node_id, node_name, **create_edge_attrs(in_node_id, node_name, in_node_id, in_port, out_port)) elif tokens[0] == b'output-node': @@ -528,7 +528,7 @@ def parse_specifier(string, graph, layer_node_map): const_node = Const(graph, {'name': scale_const_name, 'value': float_array([scale_value])}).create_node() node = Node(graph, node_name) - graph.create_edge(const_node, scale_node, 0, 0, create_edge_attrs(const_node.id, scale_name.id, const_node.id)) + graph.create_edge(const_node, scale_node, 0, 0, create_edge_attrs(const_node.id, scale_node.id, const_node.id)) out_port = len(node.out_nodes()) graph.create_edge(node, scale_node, out_port, 1, create_edge_attrs(node_name, scale_node.id, node_name, 1, out_port)) else: diff --git a/model-optimizer/unit_tests/mo/front/kaldi/loader/loader_test.py b/model-optimizer/unit_tests/mo/front/kaldi/loader/loader_test.py index 1504017fc02..92c2d2d2e3d 100644 --- a/model-optimizer/unit_tests/mo/front/kaldi/loader/loader_test.py +++ b/model-optimizer/unit_tests/mo/front/kaldi/loader/loader_test.py @@ -203,3 +203,31 @@ class TestKaldiModelsLoading(unittest.TestCase): ) (flag, resp) = compare_graphs(graph, ref_graph, 'tdnn1.relu') self.assertTrue(flag, resp) + + def test_component_map_loading_scale(self): + test_map = "input-node name=input dim=16\n" + \ + "component-node name=lda component=lda input=Scale(0.1, input)\n" + \ + "\n" + graph = Graph(name="test_graph_component_map_loading_scale") + + test_top_map = load_topology_map(io.BytesIO(bytes(test_map, 'ascii')), graph) + + ref_map = {b"lda": ["lda"]} + self.assertEqual(test_top_map, ref_map) + self.assertTrue("input" in graph.nodes()) + self.assertListEqual(list(Node(graph, 'input')['shape']), [1, 16]) + + ref_graph = build_graph({'input': {'shape': np.array([1, 16]), 'kind': 'op', 'op': 'Parameter'}, + 'lda': {'kind': 'op'}, + 'mul': {'kind': 'op'}, + 'scale_const': {'kind': 'op', 'op': 'Const'}, + }, + [ + ('input', 'mul', {'in': 0}), + ('scale_const', 'mul', {'in': 1}), + ('mul', 'lda', {'out': 0}), + ] + ) + + (flag, resp) = compare_graphs(graph, ref_graph, 'lda') + self.assertTrue(flag, resp) From 689f8aedb6d86bc45dbd66fe0ab393decae137ee Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Tue, 27 Apr 2021 17:26:20 +0300 Subject: [PATCH 5/8] Added BackwardGraphRewrite And Input RTInfo (#5343) * Added BackwardGraphRewrite * Add RT Info to Input class * Add RTInfo tests; BackwardGraphRewrite tests --- ngraph/core/include/ngraph/node_input.hpp | 13 ++++++ .../include/ngraph/pass/graph_rewrite.hpp | 18 ++++++++ ngraph/core/src/node_input.cpp | 14 ++++++ ngraph/core/src/pass/graph_rewrite.cpp | 28 +++++++++-- ngraph/test/graph_rewrite.cpp | 46 +++++++++++++++++++ ngraph/test/op.cpp | 16 +++++++ 6 files changed, 130 insertions(+), 5 deletions(-) diff --git a/ngraph/core/include/ngraph/node_input.hpp b/ngraph/core/include/ngraph/node_input.hpp index d5bd9d44d05..d78bcf50b25 100644 --- a/ngraph/core/include/ngraph/node_input.hpp +++ b/ngraph/core/include/ngraph/node_input.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include "ngraph/descriptor/tensor.hpp" #include "ngraph/partial_shape.hpp" @@ -23,6 +24,8 @@ namespace ngraph { }; + class Variant; + /// \brief A handle for one of a node's inputs. template <> class NGRAPH_API Input @@ -58,6 +61,12 @@ namespace ngraph /// \param new_source_output A handle for the output that will replace this input's source. void replace_source_output(const Output& new_source_output) const; + using RTMap = std::map>; + /// \return The reference to runtime info map + RTMap& get_rt_info(); + /// \return The constant reference to runtime info map + const RTMap& get_rt_info() const; + bool operator==(const Input& other) const; bool operator!=(const Input& other) const; bool operator<(const Input& other) const; @@ -101,6 +110,10 @@ namespace ngraph /// \return true if this input is relevant to its node's output values; else false. bool get_is_relevant_to_values() const; + using RTMap = std::map>; + /// \return The constant reference to runtime info map + const RTMap& get_rt_info() const; + bool operator==(const Input& other) const; bool operator!=(const Input& other) const; bool operator<(const Input& other) const; diff --git a/ngraph/core/include/ngraph/pass/graph_rewrite.hpp b/ngraph/core/include/ngraph/pass/graph_rewrite.hpp index 9768e71336f..3b248d50ecb 100644 --- a/ngraph/core/include/ngraph/pass/graph_rewrite.hpp +++ b/ngraph/core/include/ngraph/pass/graph_rewrite.hpp @@ -219,11 +219,29 @@ namespace ngraph void set_pass_config(const std::shared_ptr& pass_config) override; protected: + bool apply_matcher_passes(std::shared_ptr f, + std::deque> nodes_to_run); + bool m_enable_shape_inference = false; std::vector> m_matchers; }; + class NGRAPH_API BackwardGraphRewrite : public ngraph::pass::GraphRewrite + { + public: + NGRAPH_RTTI_DECLARATION; + + BackwardGraphRewrite() = default; + + explicit BackwardGraphRewrite(const std::shared_ptr& pass) + : GraphRewrite(pass) + { + } + + bool run_on_function(std::shared_ptr f) override; + }; + class NGRAPH_API RecurrentGraphRewrite : public ngraph::pass::FunctionPass { public: diff --git a/ngraph/core/src/node_input.cpp b/ngraph/core/src/node_input.cpp index f7f70b2ebd7..63ad00e9db3 100644 --- a/ngraph/core/src/node_input.cpp +++ b/ngraph/core/src/node_input.cpp @@ -82,6 +82,20 @@ namespace ngraph { } + using RTMap = std::map>; + + RTMap& Input::get_rt_info() { return m_node->m_outputs.at(m_index).get_rt_info(); } + + const RTMap& Input::get_rt_info() const + { + return m_node->m_outputs.at(m_index).get_rt_info(); + } + + const RTMap& Input::get_rt_info() const + { + return m_node->m_outputs.at(m_index).get_rt_info(); + } + const Node* Input::get_node() const { return m_node; } size_t Input::get_index() const { return m_index; } const element::Type& Input::get_element_type() const diff --git a/ngraph/core/src/pass/graph_rewrite.cpp b/ngraph/core/src/pass/graph_rewrite.cpp index 251636ea19f..693dd8e226c 100644 --- a/ngraph/core/src/pass/graph_rewrite.cpp +++ b/ngraph/core/src/pass/graph_rewrite.cpp @@ -54,6 +54,8 @@ using namespace ngraph; NGRAPH_RTTI_DEFINITION(ngraph::pass::GraphRewrite, "ngraph::pass::GraphRewrite", 0); +NGRAPH_RTTI_DEFINITION(ngraph::pass::BackwardGraphRewrite, "ngraph::pass::BackwardGraphRewrite", 0); + NGRAPH_RTTI_DEFINITION(ngraph::pass::MatcherPass, "ngraph::pass::MatcherPass", 0); namespace ngraph @@ -71,19 +73,35 @@ namespace ngraph } // namespace pass } // namespace ngraph -bool pass::GraphRewrite::run_on_function(shared_ptr f) +bool pass::BackwardGraphRewrite::run_on_function(std::shared_ptr f) { - OV_ITT_SCOPED_TASK(itt::domains::nGraph, "pass::GraphRewrite::run_on_function"); - - bool rewritten = false; - const auto& pass_config = get_pass_config(); + // Initialize execution queue with nodes in topological order + deque> nodes_to_run; + for (auto& node : f->get_ordered_ops()) + { + nodes_to_run.emplace_front(node); + } + return apply_matcher_passes(f, std::move(nodes_to_run)); +} +bool pass::GraphRewrite::run_on_function(std::shared_ptr f) +{ // Initialize execution queue with nodes in topological order deque> nodes_to_run; for (auto& node : f->get_ordered_ops()) { nodes_to_run.emplace_back(node); } + return apply_matcher_passes(f, std::move(nodes_to_run)); +} + +bool pass::GraphRewrite::apply_matcher_passes(shared_ptr f, + deque> nodes_to_run) +{ + OV_ITT_SCOPED_TASK(itt::domains::nGraph, "pass::GraphRewrite::run_on_function"); + + bool rewritten = false; + const auto& pass_config = get_pass_config(); // Check that all Matchers in MatcherPasses has type bases root node bool all_roots_has_type = true; diff --git a/ngraph/test/graph_rewrite.cpp b/ngraph/test/graph_rewrite.cpp index dc423c1317c..1e62b86e5a8 100644 --- a/ngraph/test/graph_rewrite.cpp +++ b/ngraph/test/graph_rewrite.cpp @@ -39,6 +39,23 @@ public: } }; +class GatherNodesPass : public ngraph::pass::MatcherPass +{ +public: + NGRAPH_RTTI_DECLARATION; + GatherNodesPass(NodeVector & order) + : MatcherPass() + { + ngraph::matcher_pass_callback callback = [&order](pattern::Matcher& m) { + order.push_back(m.get_match_root()); + return false; + }; + + auto m = std::make_shared(ngraph::pattern::any_input(), "GatherNodesPass"); + this->register_matcher(m, callback); + } +}; + class Anchor : public ngraph::pass::GraphRewrite { public: @@ -51,6 +68,7 @@ public: NGRAPH_RTTI_DEFINITION(TestPass, "TestPass", 0); NGRAPH_RTTI_DEFINITION(Anchor, "Anchor", 0); +NGRAPH_RTTI_DEFINITION(GatherNodesPass, "GatherNodesPass", 0); std::shared_ptr get_function() { @@ -77,6 +95,34 @@ ngraph::pass::param_callback get_callback() }; } +TEST(GraphRewriteOrderTest, MatcherPass) +{ + auto f = get_function(); + + NodeVector order; + ngraph::pass::Manager m; + auto pass = m.register_pass(); + pass->add_matcher(order); + m.run_passes(f); + + ASSERT_EQ(order, f->get_ordered_ops()); +} + +TEST(BackwardGraphRewriteOrderTest, MatcherPass) +{ + auto f = get_function(); + + NodeVector order; + ngraph::pass::Manager m; + auto pass = m.register_pass(); + pass->add_matcher(order); + m.run_passes(f); + + auto ref_order = f->get_ordered_ops(); + std::reverse(ref_order.begin(), ref_order.end()); + ASSERT_EQ(order, ref_order); +} + TEST(GraphRewriteTest, MatcherPassCallback) { auto f = get_function(); diff --git a/ngraph/test/op.cpp b/ngraph/test/op.cpp index 32cfcf09821..af7371db74c 100644 --- a/ngraph/test/op.cpp +++ b/ngraph/test/op.cpp @@ -124,9 +124,25 @@ TEST(op, variant) EXPECT_EQ(ship.y, 4); auto node = make_shared(element::f32, Shape{1}); + // Check Node RTInfo node->get_rt_info()["A"] = var_ship; auto node_var_ship = node->get_rt_info().at("A"); ASSERT_TRUE((is_type>(node_var_ship))); Ship& node_ship = as_type_ptr>(node_var_ship)->get(); EXPECT_EQ(&node_ship, &ship); + + // Check Node Input RTInfo + auto relu = make_shared(node); + relu->input(0).get_rt_info()["A"] = var_ship; + auto node_input_var_ship = node->get_rt_info().at("A"); + ASSERT_TRUE((is_type>(node_input_var_ship))); + Ship& node_input_ship = as_type_ptr>(node_input_var_ship)->get(); + EXPECT_EQ(&node_input_ship, &ship); + + // Check Node Input RTInfo + node->output(0).get_rt_info()["A"] = var_ship; + auto node_output_var_ship = node->get_rt_info().at("A"); + ASSERT_TRUE((is_type>(node_output_var_ship))); + Ship& node_output_ship = as_type_ptr>(node_input_var_ship)->get(); + EXPECT_EQ(&node_output_ship, &ship); } From 6c83e0f8a55aaee7c8156f9deca36006a4c21b30 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 27 Apr 2021 18:52:45 +0300 Subject: [PATCH 6/8] Small refactoring in TEMPLATE plugin (#5398) * Small refactoring in TEMPLATE plugin * Fixed compilation on Windows * Fixed code style --- .../src/template_executable_network.hpp | 1 + .../src/template_infer_request.cpp | 11 ---- .../src/template_infer_request.hpp | 13 +++-- docs/template_plugin/src/template_plugin.cpp | 51 +++---------------- .../test_utils/test_utils_api_impl.cpp | 6 +-- inference-engine/include/ie_common.h | 5 ++ inference-engine/include/ie_icnn_network.hpp | 5 -- 7 files changed, 22 insertions(+), 70 deletions(-) diff --git a/docs/template_plugin/src/template_executable_network.hpp b/docs/template_plugin/src/template_executable_network.hpp index d2fb8629000..a7332e9bab1 100644 --- a/docs/template_plugin/src/template_executable_network.hpp +++ b/docs/template_plugin/src/template_executable_network.hpp @@ -14,6 +14,7 @@ namespace TemplatePlugin { +// forward declaration class Plugin; /** diff --git a/docs/template_plugin/src/template_infer_request.cpp b/docs/template_plugin/src/template_infer_request.cpp index 58ea5fe40d7..9218c795520 100644 --- a/docs/template_plugin/src/template_infer_request.cpp +++ b/docs/template_plugin/src/template_infer_request.cpp @@ -8,17 +8,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "template/template_config.hpp" #include "template_infer_request.hpp" #include "template_executable_network.hpp" #include "template_plugin.hpp" diff --git a/docs/template_plugin/src/template_infer_request.hpp b/docs/template_plugin/src/template_infer_request.hpp index 41232f20c9c..61187df7985 100644 --- a/docs/template_plugin/src/template_infer_request.hpp +++ b/docs/template_plugin/src/template_infer_request.hpp @@ -7,22 +7,21 @@ #include #include #include +#include #include -#include +#include -#include -#include -#include #include +#include +#include + #include #include -#include "template_config.hpp" - - namespace TemplatePlugin { +// forward declaration class ExecutableNetwork; // ! [infer_request:header] diff --git a/docs/template_plugin/src/template_plugin.cpp b/docs/template_plugin/src/template_plugin.cpp index d9a8af3c8e2..93623b78068 100644 --- a/docs/template_plugin/src/template_plugin.cpp +++ b/docs/template_plugin/src/template_plugin.cpp @@ -81,50 +81,19 @@ InferenceEngine::ExecutableNetworkInternal::Ptr Plugin::LoadExeNetworkImpl(const const ConfigMap &config) { OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "Plugin::LoadExeNetworkImpl"); - auto cfg = Configuration{ config, _cfg }; - InferenceEngine::InputsDataMap networkInputs = network.getInputsInfo(); - InferenceEngine::OutputsDataMap networkOutputs = network.getOutputsInfo(); - - // TODO: check with precisions supported by Template device - - for (auto networkOutput : networkOutputs) { - auto output_precision = networkOutput.second->getPrecision(); - - if (output_precision != InferenceEngine::Precision::FP32 && - output_precision != InferenceEngine::Precision::FP16 && - output_precision != InferenceEngine::Precision::U8) { - IE_THROW() << "Template device supports only U8, FP16 and FP32 output precision."; - } - } - - for (auto networkInput : networkInputs) { - auto input_precision = networkInput.second->getTensorDesc().getPrecision(); - - if (input_precision != InferenceEngine::Precision::FP32 && - input_precision != InferenceEngine::Precision::FP16 && - input_precision != InferenceEngine::Precision::I16 && - input_precision != InferenceEngine::Precision::U8) { - IE_THROW() << "Input image format " << input_precision << " is not supported yet.\n" - << "Supported formats are: FP32, FP16, I16 and U8."; - } - } - - auto function = network.getFunction(); - if (function == nullptr) { - IE_THROW() << "TEMPLATE plugin can compile only IR v10 networks"; - } - - return std::make_shared(function, cfg, std::static_pointer_cast(shared_from_this())); + auto fullConfig = Configuration{ config, _cfg }; + return std::make_shared(network.getFunction(), fullConfig, + std::static_pointer_cast(shared_from_this())); } // ! [plugin:load_exe_network_impl] // ! [plugin:import_network_impl] InferenceEngine::ExecutableNetworkInternal::Ptr -Plugin::ImportNetworkImpl(std::istream& model, const std::map& config) { +Plugin::ImportNetworkImpl(std::istream& modelStream, const std::map& config) { OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "Plugin::ImportNetworkImpl"); - Configuration cfg(config); - return std::make_shared(model, cfg, + auto fullConfig = Configuration{ config, _cfg }; + return std::make_shared(modelStream, fullConfig, std::static_pointer_cast(shared_from_this())); } // ! [plugin:import_network_impl] @@ -133,13 +102,8 @@ Plugin::ImportNetworkImpl(std::istream& model, const std::map originalOps; @@ -207,6 +171,7 @@ InferenceEngine::QueryNetworkResult Plugin::QueryNetwork(const InferenceEngine:: } // 7. Produce the result + InferenceEngine::QueryNetworkResult res; for (auto&& layerName : supported) { res.supportedLayersMap.emplace(layerName, GetName()); } diff --git a/inference-engine/ie_bridges/python/src/openvino/test_utils/test_utils_api_impl.cpp b/inference-engine/ie_bridges/python/src/openvino/test_utils/test_utils_api_impl.cpp index 48cba8526f7..86c74cb3207 100644 --- a/inference-engine/ie_bridges/python/src/openvino/test_utils/test_utils_api_impl.cpp +++ b/inference-engine/ie_bridges/python/src/openvino/test_utils/test_utils_api_impl.cpp @@ -4,11 +4,9 @@ #include "test_utils_api_impl.hpp" +#include #include -#include - -std::pair InferenceEnginePython::CompareNetworks(InferenceEnginePython::IENetwork lhs, - InferenceEnginePython::IENetwork rhs) { +std::pair InferenceEnginePython::CompareNetworks(InferenceEnginePython::IENetwork lhs, InferenceEnginePython::IENetwork rhs) { return compare_functions(lhs.actual->getFunction(), rhs.actual->getFunction(), true, true, false, true); } diff --git a/inference-engine/include/ie_common.h b/inference-engine/include/ie_common.h index d14f26e70e6..efae34f4d3f 100644 --- a/inference-engine/include/ie_common.h +++ b/inference-engine/include/ie_common.h @@ -286,6 +286,11 @@ struct QueryNetworkResult { */ using ConstOutputsDataMap = std::map; +/** + * @brief A collection that contains string as key, and Data smart pointer as value + */ +using OutputsDataMap = std::map; + namespace details { struct INFERENCE_ENGINE_DEPRECATED("Use InferRequest::Exception") INFERENCE_ENGINE_API_CLASS(InferenceEngineException) : public std::runtime_error { diff --git a/inference-engine/include/ie_icnn_network.hpp b/inference-engine/include/ie_icnn_network.hpp index 25ee2715167..432f43c6da3 100644 --- a/inference-engine/include/ie_icnn_network.hpp +++ b/inference-engine/include/ie_icnn_network.hpp @@ -34,11 +34,6 @@ class Function; namespace InferenceEngine { -/** - * @brief A collection that contains string as key, and Data smart pointer as value - */ -using OutputsDataMap = std::map; - /** * @deprecated Use InferenceEngine::CNNNetwork wrapper instead * @interface ICNNNetwork From 6d28be7411ced950d364d988ff09f3ba3c5725e2 Mon Sep 17 00:00:00 2001 From: Sergey Lyubimtsev Date: Tue, 27 Apr 2021 18:53:55 +0300 Subject: [PATCH 7/8] Enable CPack for Python samples (#5406) * Enable Python samples for CI & CPack * remove external dependency for CMakeLists file --- inference-engine/CMakeLists.txt | 10 ---------- inference-engine/ie_bridges/python/CMakeLists.txt | 10 +++++++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt index 59c2b219541..36a71d7cfe9 100644 --- a/inference-engine/CMakeLists.txt +++ b/inference-engine/CMakeLists.txt @@ -114,16 +114,6 @@ install(FILES samples/CMakeLists.txt DESTINATION ${IE_CPACK_IE_DIR}/samples/c COMPONENT c_samples) -# install Python samples - -if(ENABLE_PYTHON) - ie_cpack_add_component(python_samples DEPENDS core) - - install(DIRECTORY ${ie_python_api_SOURCE_DIR}/sample/ - DESTINATION ${IE_CPACK_IE_DIR}/samples/python - COMPONENT python_samples) -endif() - # install speech demo files if(SPEECH_LIBS_AND_DEMOS) diff --git a/inference-engine/ie_bridges/python/CMakeLists.txt b/inference-engine/ie_bridges/python/CMakeLists.txt index 24d16ca77e0..669c0cb75a1 100644 --- a/inference-engine/ie_bridges/python/CMakeLists.txt +++ b/inference-engine/ie_bridges/python/CMakeLists.txt @@ -90,4 +90,12 @@ install(PROGRAMS src/openvino/__init__.py DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino COMPONENT ${PYTHON_VERSION}) -ie_cpack(${PYTHON_VERSION}) +# install Python samples + +ie_cpack_add_component(python_samples) + +install(DIRECTORY sample/ + DESTINATION ${IE_CPACK_IE_DIR}/samples/python + COMPONENT python_samples) + +ie_cpack(${PYTHON_VERSION} python_samples) From 1ae1757a5a957025caf71702385907c9750551e0 Mon Sep 17 00:00:00 2001 From: Alina Kladieva Date: Tue, 27 Apr 2021 18:54:25 +0300 Subject: [PATCH 8/8] [inference-engine|tests|functional|gpu] Exclude sporadic (54436) (#5428) --- .../plugin/gpu/shared_tests_instances/skip_tests_config.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 2732f24d3e3..01ffef7fe45 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -57,5 +57,7 @@ std::vector disabledTestPatterns() { R"(.*(LPT/StridedSliceTransformation).*)", // TODO: Issue: 48106 R"(.*ConstantResultSubgraphTest.*inPrc=I16.*)", + // TODO: Issue: 54436 + R"(.*LSTMSequence.*CompareWithRefs.*mode=PURE_SEQ_RAND_SEQ_LEN_PARAM.*direction=bidirectional_clip=0.7_netPRC=FP32.*)", }; }