[TEST] One more trivival loop test
authorAlexander Peskov <alexander.peskov@intel.com>
Wed, 28 Oct 2020 22:34:18 +0000 (01:34 +0300)
committerAlexander Peskov <alexander.peskov@intel.com>
Mon, 2 Nov 2020 09:37:48 +0000 (12:37 +0300)
Signed-off-by: Alexander Peskov <alexander.peskov@intel.com>
inference-engine/tests/functional/plugin/shared/src/single_layer_tests/loop.cpp

index 68db20c..d519cef 100644 (file)
@@ -293,7 +293,7 @@ namespace LayerTestsDefinitions {
         Run();
     }
 
-    TEST_P(TrivialLoopTest, CheckLoad) {
+    TEST_P(TrivialLoopTest, PassThroughBody) {
         SKIP_IF_CURRENT_TEST_IS_DISABLED()
         InferenceEngine::Precision iePrc;
         InferenceEngine::SizeVector ieShape;
@@ -337,4 +337,47 @@ namespace LayerTestsDefinitions {
         Run();
     }
 
+    TEST_P(TrivialLoopTest, UnusedInputBody) {
+        SKIP_IF_CURRENT_TEST_IS_DISABLED()
+        InferenceEngine::Precision iePrc;
+        InferenceEngine::SizeVector ieShape;
+        std::tie(iePrc, ieShape, targetDevice) = GetParam();
+
+        const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iePrc);
+        const auto shape = ngraph::Shape{ieShape};
+        const auto scalarShape = ngraph::Shape{};
+
+        auto start = std::make_shared<ngraph::op::Parameter>(prc, shape);
+        auto count = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, scalarShape, 5);
+        auto icond = std::make_shared<ngraph::op::Constant>(ngraph::element::boolean, scalarShape, true);
+
+        // Loop body
+        auto b_data = std::make_shared<ngraph::op::Parameter>(prc, shape);
+        auto b_cond = std::make_shared<ngraph::op::Constant>(ngraph::element::boolean, scalarShape, true);
+        auto b_iter = std::make_shared<ngraph::op::Parameter>(ngraph::element::i64, scalarShape);
+
+        auto body = std::make_shared<ngraph::Function>(
+                ngraph::OutputVector    {b_cond, b_data},
+                ngraph::ParameterVector {b_data, b_iter});
+
+        auto loop = std::make_shared<ngraph::opset5::Loop>(count, icond);
+        loop->set_function(body);
+        loop->set_special_body_ports({1, 0});
+        loop->set_invariant_input(b_data, start);
+        loop->get_iter_value(b_data, -1);
+
+        function = std::make_shared<ngraph::Function>(
+                ngraph::OutputVector    {loop},
+                ngraph::ParameterVector {start});
+
+        // Precalculated ref blobs
+        auto blob = make_blob_with_precision({iePrc, ieShape, InferenceEngine::TensorDesc::getLayoutByDims(ieShape)});
+        blob->allocate();
+        CommonTestUtils::fill_data_with_broadcast(blob, 0, {10});
+
+        inputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; };
+        outputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; };
+
+        Run();
+    }
 }  // namespace LayerTestsDefinitions