-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEST] Keep assign node in exec_graph_info
Signed-off-by: Alexander Peskov <[email protected]>
- Loading branch information
1 parent
fd47625
commit 034c883
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
.../tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/keep_assign.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
14 changes: 14 additions & 0 deletions
14
...rence-engine/tests/functional/plugin/shared/include/execution_graph_tests/keep_assing.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<std::string> { | ||
public: | ||
static std::string getTestCaseName(testing::TestParamInfo<std::string> obj); | ||
}; | ||
|
||
} // namespace LayerTestsDefinitions |
66 changes: 66 additions & 0 deletions
66
inference-engine/tests/functional/plugin/shared/src/execution_graph_tests/keep_assing.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "execution_graph_tests/keep_assing.hpp" | ||
|
||
#include <ngraph/ngraph.hpp> | ||
#include <inference_engine.hpp> | ||
|
||
namespace LayerTestsDefinitions { | ||
|
||
std::string ExecGraphKeepAssignNode::getTestCaseName(testing::TestParamInfo<std::string> 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<Parameter>(type, shape); // | \ / // | ||
auto mem_i = make_shared<Constant>(type, shape, 0); // | mul // | ||
auto mem_r = make_shared<ReadValue>(mem_i, "id"); // | / \ // | ||
auto mul = make_shared<Multiply>(mem_r, input); // sum assign // | ||
auto mem_w = make_shared<Assign>(mul, "id"); // | // | ||
auto sum = make_shared<Add>(mul, input); // out // | ||
|
||
mem_w->add_control_dependency(mem_r); | ||
sum->add_control_dependency(mem_w); | ||
|
||
auto function = std::make_shared<ngraph::Function>( | ||
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<ngraph::VariantImpl<std::string>>(var); | ||
|
||
if (s_val->get() == "MemoryOutput") { | ||
assign_node_found = true; | ||
break; | ||
} | ||
} | ||
ASSERT_TRUE(assign_node_found); | ||
} | ||
|
||
} // namespace LayerTestsDefinitions |