diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp new file mode 100644 index 00000000000000..88762483d96e14 --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "execution_graph_tests/keep_assing.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + +INSTANTIATE_TEST_CASE_P(KeepAssign, ExecGraphKeepAssignNode, + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ExecGraphKeepAssignNode::getTestCaseName); + +} // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/keep_assing.hpp b/inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/keep_assing.hpp new file mode 100644 index 00000000000000..24ee147c7d20f0 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/execution_graph_tests/keep_assing.hpp @@ -0,0 +1,14 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +namespace LayerTestsDefinitions { + +class ExecGraphKeepAssignNode : public testing::TestWithParam { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); +}; + +} // namespace LayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/keep_assing.cpp b/inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/keep_assing.cpp new file mode 100644 index 00000000000000..2a1e7524b4770e --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/keep_assing.cpp @@ -0,0 +1,66 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "execution_graph_tests/keep_assing.hpp" + +#include +#include + +namespace LayerTestsDefinitions { + +std::string ExecGraphKeepAssignNode::getTestCaseName(testing::TestParamInfo obj) { + std::string targetDevice = obj.param; + return "Dev=" + targetDevice; +} + +/** + * Assign/MemoryOutput operation node may hanging in air (leaf, has no consumer). + * So exec graph may lose it. Will check that it's present in dumped exec graph. + */ +TEST_P(ExecGraphKeepAssignNode, KeepAssignNode) { + auto device_name = this->GetParam(); + ngraph::Shape shape = {3, 2}; + ngraph::element::Type type = ngraph::element::f32; + + using std::make_shared; + using namespace ngraph::op; + + // Some simple graph with Memory(Assign) node // in read // + auto input = make_shared(type, shape); // | \ / // + auto mem_i = make_shared(type, shape, 0); // | mul // + auto mem_r = make_shared(mem_i, "id"); // | / \ // + auto mul = make_shared(mem_r, input); // sum assign // + auto mem_w = make_shared(mul, "id"); // | // + auto sum = make_shared(mul, input); // out // + + mem_w->add_control_dependency(mem_r); + sum->add_control_dependency(mem_w); + + auto function = std::make_shared( + ngraph::NodeVector {sum}, + ngraph::ParameterVector {input}, + "SimpleNet"); + + // Load into plugin and get exec graph + auto ie = InferenceEngine::Core(); + auto net = InferenceEngine::CNNNetwork(function); + auto exec_net = ie.LoadNetwork(net, device_name); + auto exec_graph = exec_net.GetExecGraphInfo(); + auto exec_ops = exec_graph.getFunction()->get_ops(); + + // Check Memory(Assign) node existence + bool assign_node_found; + for (auto &node : exec_ops) { + auto var = node->get_rt_info()["layerType"]; + auto s_val = std::dynamic_pointer_cast>(var); + + if (s_val->get() == "MemoryOutput") { + assign_node_found = true; + break; + } + } + ASSERT_TRUE(assign_node_found); +} + +} // namespace LayerTestsDefinitions