diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/AddConverToReorder.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/AddConverToReorder.cpp index 42c72d872ae2e9..d00b872988c004 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/AddConverToReorder.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/AddConverToReorder.cpp @@ -38,41 +38,13 @@ class AddConvertToReorderTest : virtual public LayerTestsUtils::LayerTestsCommon } std::vector> CalculateRefs() override { // Convert the second input constant precision to i64 to run the reference function - switch (secondConstantType) { - case ngraph::element::Type_t::i8: - ngraph::pass::ConvertPrecision().run_on_function(function); - break; - case ngraph::element::Type_t::bf16: - ngraph::pass::ConvertPrecision().run_on_function(function); - break; - default: - // pass - break; + if (ngraph::element::Type_t::i8 == secondConstantType) { + ngraph::pass::ConvertPrecision().run_on_function(function); + } else if (ngraph::element::Type_t::bf16 == secondConstantType) { + ngraph::pass::ConvertPrecision().run_on_function(function); } - return LayerTestsUtils::LayerTestsCommon::CalculateRefs(); } - void CheckElementOfTypeCount(std::string typeName, size_t expectedCount) { - InferenceEngine::CNNNetwork execGraphInfo = executableNetwork.GetExecGraphInfo(); - auto function = execGraphInfo.getFunction(); - ASSERT_NE(nullptr, function); - size_t actualPermuteCount = 0; - for (const auto &node : function->get_ops()) { - const auto & rtInfo = node->get_rt_info(); - auto getExecValue = [&rtInfo](const std::string & paramName) -> std::string { - auto it = rtInfo.find(paramName); - IE_ASSERT(rtInfo.end() != it); - auto value = std::dynamic_pointer_cast>(it->second); - IE_ASSERT(nullptr != value); - return value->get(); - }; - if (getExecValue(ExecGraphInfoSerialization::LAYER_TYPE) == typeName) { - actualPermuteCount++; - } - } - - ASSERT_EQ(expectedCount, actualPermuteCount) << "Unexpected count of the element type '" << typeName << "' "; - } private: ngraph::element::Type secondConstantType; @@ -84,7 +56,7 @@ namespace { Parameter[FP32] Constant[BF16] \ / \ / - \ Convert[I32] (Is inserted by the MKLDNNGraphOptimizer) + \ Convert[I32] (Is inserted by the MKLDNNGraph) \ / Gather[FP32] | @@ -95,8 +67,8 @@ namespace { TEST_F(AddConvertToReorderTest, smoke_TestAddConvert_CPU) { BuildGraph(ngraph::element::bf16); Run(); - CheckElementOfTypeCount("Convert", 1); - CheckElementOfTypeCount("Reorder", 0); + CheckNodeOfTypeCount(executableNetwork, "Convert", 1); + CheckNodeOfTypeCount(executableNetwork, "Reorder", 0); } /* Test insertion of the Reorder layer if there is one. @@ -104,7 +76,7 @@ TEST_F(AddConvertToReorderTest, smoke_TestAddConvert_CPU) { Parameter[FP32] Constant[I8] \ / \ / - \ Reorder[I32] (Is inserted by the MKLDNNGraphOptimizer) + \ Reorder[I32] (Is inserted by the MKLDNNGraph) \ / Gather[FP32] | @@ -114,8 +86,8 @@ TEST_F(AddConvertToReorderTest, smoke_TestAddConvert_CPU) { TEST_F(AddConvertToReorderTest, smoke_TestAddReorder_CPU) { BuildGraph(ngraph::element::i8); Run(); - CheckElementOfTypeCount("Convert", 0); - CheckElementOfTypeCount("Reorder", 1); + CheckNodeOfTypeCount(executableNetwork, "Convert", 0); + CheckNodeOfTypeCount(executableNetwork, "Reorder", 1); } } // namespace } // namespace LayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.cpp b/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.cpp index fb99ff842e1e87..61f9108e5c99ff 100644 --- a/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.cpp +++ b/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.cpp @@ -190,4 +190,25 @@ std::vector filterCPUSpecificParams(std::vectorget_ops()) { + const auto & rtInfo = node->get_rt_info(); + auto getExecValue = [&rtInfo](const std::string & paramName) -> std::string { + auto it = rtInfo.find(paramName); + IE_ASSERT(rtInfo.end() != it); + auto value = std::dynamic_pointer_cast>(it->second); + IE_ASSERT(nullptr != value); + return value->get(); + }; + if (getExecValue(ExecGraphInfoSerialization::LAYER_TYPE) == nodeType) { + actualNodeCount++; + } + } + + ASSERT_EQ(expectedCount, actualNodeCount) << "Unexpected count of the node type '" << nodeType << "' "; +} } // namespace CPUTestUtils diff --git a/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.hpp b/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.hpp index c43505e78b06ed..e7beedc8edf51a 100644 --- a/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.hpp +++ b/inference-engine/tests/functional/plugin/cpu/test_utils/cpu_test_utils.hpp @@ -86,5 +86,6 @@ const auto conv_avx512_2D_1x1 = CPUSpecificParams{{nChw16c}, {nChw16c}, {"jit_av // utility functions std::vector filterCPUSpecificParams(std::vector& paramsVector); +void CheckNodeOfTypeCount(InferenceEngine::ExecutableNetwork &execNet, std::string nodeType, size_t expectedCount); } // namespace CPUTestUtils