Remove ExtractImagePatchesToReorgYolo transformation (#2687)
authorAnton Chetverikov <Anton.Chetverikov@intel.com>
Fri, 23 Oct 2020 14:32:54 +0000 (17:32 +0300)
committerGitHub <noreply@github.com>
Fri, 23 Oct 2020 14:32:54 +0000 (17:32 +0300)
Co-authored-by: Anton Chetverikov <anton.chetverikov@.intel.com>
Co-authored-by: Ilya Churaev <ilya.churaev@intel.com>
inference-engine/src/cldnn_engine/cldnn_engine.cpp
inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp
inference-engine/src/transformations/include/transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp [deleted file]
inference-engine/src/transformations/src/transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.cpp [deleted file]
inference-engine/src/transformations/src/transformations/opset_conversions/convert_opset3_to_opset2.cpp
inference-engine/tests/functional/inference_engine/transformations/convert_extract_image_patches_to_reorg_yolo_test.cpp [deleted file]

index 2ba4374..445a53d 100644 (file)
@@ -130,7 +130,6 @@ InferenceEngine::ICNNNetwork::Ptr clDNNEngine::CloneAndTransformNetwork(const In
                    std::dynamic_pointer_cast<const ::ngraph::opset3::ShuffleChannels>(node) ||
                    std::dynamic_pointer_cast<const ::ngraph::opset2::BatchToSpace>(node) ||
                    std::dynamic_pointer_cast<const ::ngraph::opset2::SpaceToBatch>(node) ||
-                   std::dynamic_pointer_cast<const ::ngraph::opset3::ExtractImagePatches>(node) ||
                    std::dynamic_pointer_cast<const ::ngraph::opset5::HSigmoid>(node) ||
                    std::dynamic_pointer_cast<const ::ngraph::opset4::HSwish>(node) ||
                    std::dynamic_pointer_cast<const ::ngraph::opset4::ReduceL1>(node) ||
index cd8fd3e..6399b22 100644 (file)
@@ -39,7 +39,6 @@
 #include <transformations/op_conversions/reduce_l1_decomposition.hpp>
 #include <transformations/op_conversions/reduce_l2_decomposition.hpp>
 #include <transformations/op_conversions/convert_pad_to_group_conv.hpp>
-#include <transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp>
 #include <transformations/op_conversions/softplus_decomposition.hpp>
 #include <transformations/op_conversions/convert_space_to_batch.hpp>
 #include <transformations/op_conversions/convert_batch_to_space.hpp>
@@ -137,7 +136,6 @@ static void Transformation(ICNNNetwork::Ptr& clonedNetwork, const Config& conf)
 
     // List of enabled/disabled transformations
     pass_config->disable<ngraph::pass::ConvertGELU>();
-    pass_config->disable<ngraph::pass::ConvertExtractImagePatchesToReorgYolo>();
     pass_config->disable<ngraph::pass::HSwishDecomposition>();
     pass_config->disable<ngraph::pass::ReduceL1Decomposition>();
     pass_config->disable<ngraph::pass::ReduceL2Decomposition>();
diff --git a/inference-engine/src/transformations/include/transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp b/inference-engine/src/transformations/include/transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp
deleted file mode 100644 (file)
index 2eeb80f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2018-2020 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#pragma once
-
-#include <vector>
-#include <memory>
-
-#include <transformations_visibility.hpp>
-#include <ngraph/pass/graph_rewrite.hpp>
-
-namespace ngraph {
-namespace pass {
-
-class TRANSFORMATIONS_API ConvertExtractImagePatchesToReorgYolo;
-
-}  // namespace pass
-}  // namespace ngraph
-
-/**
- * @ingroup ie_transformation_common_api
- * @brief ConvertExtractImagePatchesToReorgYolo transformation replaces ExtractImagePatches with a ReorgYolo op.
- */
-class ngraph::pass::ConvertExtractImagePatchesToReorgYolo : public ngraph::pass::MatcherPass {
-public:
-    NGRAPH_RTTI_DECLARATION;
-    ConvertExtractImagePatchesToReorgYolo();
-};
diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.cpp
deleted file mode 100644 (file)
index 9fb6e62..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2018-2020 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#include "transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp"
-
-#include <memory>
-#include <vector>
-
-#include <ngraph/opsets/opset3.hpp>
-#include <ngraph/rt_info.hpp>
-#include <ngraph/pattern/op/wrap_type.hpp>
-
-NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertExtractImagePatchesToReorgYolo, "ConvertExtractImagePatchesToReorgYolo", 0);
-
-ngraph::pass::ConvertExtractImagePatchesToReorgYolo::ConvertExtractImagePatchesToReorgYolo() {
-    auto image = std::make_shared<ngraph::pattern::op::Label>(ngraph::element::f32, ngraph::Shape{1, 1, 1, 1});
-    auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(image, ngraph::Shape{1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 1},
-            ngraph::op::PadType::VALID);
-
-    ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) {
-        auto &pattern_to_output = m.get_pattern_value_map();
-        auto extract_image_patches =  std::dynamic_pointer_cast<ngraph::opset3::ExtractImagePatches>(m.get_match_root());
-
-        /*
-         * In this transformation we raplace ExtractImagePatches operation to ReorgYolo operation
-         * if ExtractImagePatches operation attributes obey the following conditions:
-         *
-         * EIP.sizes = EIP.strides
-         * EIP.rates = {1, 1}
-         * EIP.PadType = VALID
-         * Spatial dimensions of input tensor must be divisible by EIP.strides
-         *
-         */
-
-        if (!extract_image_patches || m_transformation_callback(extract_image_patches)) {
-            return false;
-        }
-
-        if (extract_image_patches->get_auto_pad() != ngraph::op::PadType::VALID) {
-            return false;
-        }
-
-        if (extract_image_patches->get_strides() != extract_image_patches->get_sizes()) {
-            return false;
-        }
-
-        auto p_shape_input = extract_image_patches->get_input_partial_shape(0);
-        auto sizes = extract_image_patches->get_sizes();
-        auto strides = extract_image_patches->get_strides();
-        auto rates = extract_image_patches->get_rates();
-
-        // Check that ExtractImagePatches input have static shape and rank == 4
-        if (!p_shape_input.rank().is_static() || p_shape_input.rank().get_length() != 4) {
-            return false;
-        }
-
-        // Check that ExtractImagePatches input spatial dimensions are not dynamic
-        if (p_shape_input[2].is_dynamic() || p_shape_input[3].is_dynamic()) {
-            return false;
-        }
-
-        // Check that ExtractImagePatches input spatial dimensions are divisible by EIP.strides
-        if (p_shape_input[2].get_length() % strides[0] != 0 || p_shape_input[3].get_length() % strides[1] != 0) {
-            return false;
-        }
-
-        // Check that EIP.sizes = EIP.strides
-        if (sizes[0] != strides[0] || sizes[1] != strides[1]) {
-            return false;
-        }
-
-        // Check that EIP.rates = {1, 1}
-        if (rates[0] != 1 || rates[1] != 1) {
-            return false;
-        }
-
-        auto reorg_yolo = std::make_shared<ngraph::opset3::ReorgYolo>(extract_image_patches->input(0).get_source_output(),
-            ngraph::Strides{extract_image_patches->get_strides()});
-
-        reorg_yolo->set_friendly_name(extract_image_patches->get_friendly_name());
-        ngraph::copy_runtime_info(extract_image_patches, reorg_yolo);
-        ngraph::replace_node(extract_image_patches, reorg_yolo);
-        return true;
-    };
-
-    auto m = std::make_shared<ngraph::pattern::Matcher>(eip, "ConvertExtractImagePatchesToReorgYolo");
-    register_matcher(m, callback);
-}
index 02c45bd..cedbb5b 100644 (file)
@@ -9,7 +9,6 @@
 #include "transformations/op_conversions/convert_shapeof3.hpp"
 #include "transformations/op_conversions/convert_shuffle_channels3.hpp"
 #include "transformations/op_conversions/convert_topk3.hpp"
-#include "transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp"
 #include "transformations/op_conversions/softplus_decomposition.hpp"
 #include "transformations/itt.hpp"
 
@@ -30,7 +29,6 @@ bool ngraph::pass::ConvertOpSet3ToOpSet2::run_on_function(std::shared_ptr<ngraph
     manager.register_pass<ngraph::pass::ConvertShapeOf3>();
     manager.register_pass<ngraph::pass::ConvertShuffleChannels3>();
     manager.register_pass<ngraph::pass::ConvertTopK3>();
-    manager.register_pass<ngraph::pass::ConvertExtractImagePatchesToReorgYolo>();
     manager.register_pass<ngraph::pass::SoftPlusDecomposition>();
 
     manager.set_pass_config(get_pass_config());
diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_extract_image_patches_to_reorg_yolo_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_extract_image_patches_to_reorg_yolo_test.cpp
deleted file mode 100644 (file)
index 062de2a..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright (C) 2020 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#include <gtest/gtest.h>
-
-#include <string>
-#include <memory>
-
-#include <ngraph/function.hpp>
-#include <ngraph/opsets/opset1.hpp>
-#include <ngraph/opsets/opset3.hpp>
-#include <ngraph/pass/manager.hpp>
-#include <transformations/op_conversions/convert_extract_image_patches_to_reorg_yolo.hpp>
-#include <transformations/init_node_info.hpp>
-#include <transformations/utils/utils.hpp>
-
-#include "common_test_utils/ngraph_test_utils.hpp"
-
-using namespace testing;
-
-// TODO: bug 39971, remove ConvertExtractImagePatchesToReorgYolo transformation
-
-TEST(TransformationTests, ConvertExtractImagePatchesToReorgYoloTestsNegative1) {
-    std::shared_ptr<ngraph::Function> f(nullptr), f_ref(nullptr);
-    {
-        auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32,
-            ngraph::PartialShape{1, 3, ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()});
-
-        auto sizes = ngraph::Shape{5, 5};
-        auto strides = ngraph::Strides{5, 5};
-        auto rates = ngraph::Shape{1, 1};
-        ngraph::op::PadType auto_pad = ngraph::op::PadType::VALID;
-
-        auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(input, sizes, strides, rates, auto_pad);
-
-        f = std::make_shared<ngraph::Function>(ngraph::NodeVector{eip}, ngraph::ParameterVector{input});
-        ngraph::pass::Manager manager;
-        manager.register_pass<ngraph::pass::InitNodeInfo>();
-        manager.register_pass<ngraph::pass::ConvertExtractImagePatchesToReorgYolo>();
-        manager.run_passes(f);
-        ASSERT_NO_THROW(check_rt_info(f));
-    }
-
-    {
-        auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32,
-            ngraph::PartialShape{1, 3, ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()});
-
-        auto sizes = ngraph::Shape{5, 5};
-        auto strides = ngraph::Strides{5, 5};
-        auto rates = ngraph::Shape{1, 1};
-        ngraph::op::PadType auto_pad = ngraph::op::PadType::VALID;
-
-        auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(input, sizes, strides, rates, auto_pad);
-
-        f_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{eip}, ngraph::ParameterVector{input});
-    }
-
-    auto res = compare_functions(f, f_ref);
-    ASSERT_TRUE(res.first) << res.second;
-}
-
-TEST(TransformationTests, ConvertExtractImagePatchesToReorgYoloTestsNegative2) {
-    std::shared_ptr<ngraph::Function> f(nullptr), f_ref(nullptr);
-    {
-        auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32, ngraph::Shape{1, 3, 10, 10});
-
-        auto sizes = ngraph::Shape{5, 5};
-        auto strides = ngraph::Strides{5, 5};
-        auto rates = ngraph::Shape{1, 1};
-        ngraph::op::PadType auto_pad = ngraph::op::PadType::SAME_LOWER;
-
-        auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(input, sizes, strides, rates, auto_pad);
-
-        f = std::make_shared<ngraph::Function>(ngraph::NodeVector{eip}, ngraph::ParameterVector{input});
-
-        ngraph::pass::Manager manager;
-        manager.register_pass<ngraph::pass::InitNodeInfo>();
-        manager.register_pass<ngraph::pass::ConvertExtractImagePatchesToReorgYolo>();
-        manager.run_passes(f);
-        ASSERT_NO_THROW(check_rt_info(f));
-    }
-
-    {
-        auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32, ngraph::Shape{1, 3, 10, 10});
-
-        auto sizes = ngraph::Shape{5, 5};
-        auto strides = ngraph::Strides{5, 5};
-        auto rates = ngraph::Shape{1, 1};
-        ngraph::op::PadType auto_pad = ngraph::op::PadType::SAME_LOWER;
-
-        auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(input, sizes, strides, rates, auto_pad);
-
-        f_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{eip}, ngraph::ParameterVector{input});
-    }
-
-    auto res = compare_functions(f, f_ref);
-    ASSERT_TRUE(res.first) << res.second;
-}
-
-TEST(TransformationTests, ConvertExtractImagePatchesToReorgYoloTestsNegative3) {
-    std::shared_ptr<ngraph::Function> f(nullptr), f_ref(nullptr);
-    {
-        auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32, ngraph::Shape{1, 3, 10, 10});
-
-        auto sizes = ngraph::Shape{3, 3};
-        auto strides = ngraph::Strides{5, 5};
-        auto rates = ngraph::Shape{1, 1};
-        ngraph::op::PadType auto_pad = ngraph::op::PadType::VALID;
-
-        auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(input, sizes, strides, rates, auto_pad);
-
-        f = std::make_shared<ngraph::Function>(ngraph::NodeVector{eip}, ngraph::ParameterVector{input});
-
-        ngraph::pass::Manager manager;
-        manager.register_pass<ngraph::pass::InitNodeInfo>();
-        manager.register_pass<ngraph::pass::ConvertExtractImagePatchesToReorgYolo>();
-        manager.run_passes(f);
-        ASSERT_NO_THROW(check_rt_info(f));
-    }
-
-    {
-        auto input = std::make_shared<ngraph::opset1::Parameter>(ngraph::element::f32, ngraph::Shape{1, 3, 10, 10});
-
-        auto sizes = ngraph::Shape{3, 3};
-        auto strides = ngraph::Strides{5, 5};
-        auto rates = ngraph::Shape{1, 1};
-        ngraph::op::PadType auto_pad = ngraph::op::PadType::VALID;
-
-        auto eip = std::make_shared<ngraph::opset3::ExtractImagePatches>(input, sizes, strides, rates, auto_pad);
-
-        f_ref = std::make_shared<ngraph::Function>(ngraph::NodeVector{eip}, ngraph::ParameterVector{input});
-    }
-
-    auto res = compare_functions(f, f_ref);
-    ASSERT_TRUE(res.first) << res.second;
-}