COMPMID-1013 - Create WinogradInfo data structure
COMPMID-1014 - Refactoring Winograd's dataset

Change-Id: I6abdcbf9a90d663f4db666cd410afece9f1d034d
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/125899
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/tests/datasets/ShapeDatasets.h b/tests/datasets/ShapeDatasets.h
index e939a6f..928ff73 100644
--- a/tests/datasets/ShapeDatasets.h
+++ b/tests/datasets/ShapeDatasets.h
@@ -372,6 +372,38 @@
     }
 };
 
+/** Data set containing small 3x3 tensor shapes. */
+class Small3x3Shapes final : public ShapeDataset
+{
+public:
+    Small3x3Shapes()
+        : ShapeDataset("Shape",
+    {
+        TensorShape{ 3U, 3U, 7U, 4U },
+                     TensorShape{ 3U, 3U, 4U, 13U },
+                     TensorShape{ 3U, 3U, 9U, 2U },
+                     TensorShape{ 3U, 3U, 3U, 5U },
+    })
+    {
+    }
+};
+
+/** Data set containing large 3x3 tensor shapes. */
+class Large3x3Shapes final : public ShapeDataset
+{
+public:
+    Large3x3Shapes()
+        : ShapeDataset("Shape",
+    {
+        TensorShape{ 3U, 3U, 32U, 64U },
+                     TensorShape{ 3U, 3U, 51U, 13U },
+                     TensorShape{ 3U, 3U, 53U, 47U },
+                     TensorShape{ 3U, 3U, 128U, 384U },
+    })
+    {
+    }
+};
+
 /** Data set containing small tensor shapes for deconvolution. */
 class SmallDeconvolutionShapes final : public ShapeDataset
 {
diff --git a/tests/datasets/WinogradFilterTransformDataset.h b/tests/datasets/WinogradFilterTransformDataset.h
deleted file mode 100644
index 07d0283..0000000
--- a/tests/datasets/WinogradFilterTransformDataset.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2018 ARM Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef ARM_COMPUTE_TEST_WINOGRAD_FILTER_TRANSFORM_DATASET
-#define ARM_COMPUTE_TEST_WINOGRAD_FILTER_TRANSFORM_DATASET
-
-#include "utils/TypePrinter.h"
-
-#include "arm_compute/core/TensorShape.h"
-
-namespace arm_compute
-{
-namespace test
-{
-namespace datasets
-{
-class WinogradFilterTransformDataset
-{
-public:
-    using type = std::tuple<TensorShape, bool>;
-
-    struct iterator
-    {
-        iterator(std::vector<TensorShape>::const_iterator a_it,
-                 std::vector<bool>::const_iterator        is_nchw_it)
-            : _a_it{ std::move(a_it) },
-              _is_nchw_it{ std::move(is_nchw_it) }
-        {
-        }
-
-        std::string description() const
-        {
-            std::stringstream description;
-            description << "Input=" << *_a_it << ":";
-            description << "IsNCHW=" << *_is_nchw_it << ":";
-            return description.str();
-        }
-
-        WinogradFilterTransformDataset::type operator*() const
-        {
-            return std::make_tuple(*_a_it, *_is_nchw_it);
-        }
-
-        iterator &operator++()
-        {
-            ++_a_it;
-            ++_is_nchw_it;
-
-            return *this;
-        }
-
-    private:
-        std::vector<TensorShape>::const_iterator _a_it;
-        std::vector<bool>::const_iterator        _is_nchw_it;
-    };
-
-    iterator begin() const
-    {
-        return iterator(_a_shapes.begin(), _is_nchw.begin());
-    }
-
-    int size() const
-    {
-        return std::min(_a_shapes.size(), _is_nchw.size());
-    }
-
-    void add_config(TensorShape a, bool is_nchw)
-    {
-        _a_shapes.emplace_back(std::move(a));
-        _is_nchw.emplace_back(std::move(is_nchw));
-    }
-
-protected:
-    WinogradFilterTransformDataset()                                  = default;
-    WinogradFilterTransformDataset(WinogradFilterTransformDataset &&) = default;
-
-private:
-    std::vector<TensorShape> _a_shapes{};
-    std::vector<bool>        _is_nchw{};
-};
-
-class SmallWinogradFilterTransformDataset final : public WinogradFilterTransformDataset
-{
-public:
-    SmallWinogradFilterTransformDataset()
-    {
-        add_config(TensorShape(3U, 3U, 7U, 4U), true);
-        add_config(TensorShape(3U, 3U, 4U, 13U), true);
-        add_config(TensorShape(3U, 3U, 9U, 2U), true);
-        add_config(TensorShape(3U, 3U, 3U, 5U), true);
-    }
-};
-
-class LargeWinogradFilterTransformDataset final : public WinogradFilterTransformDataset
-{
-public:
-    LargeWinogradFilterTransformDataset()
-    {
-        add_config(TensorShape(3U, 3U, 32U, 64U), true);
-        add_config(TensorShape(3U, 3U, 51U, 13U), true);
-        add_config(TensorShape(3U, 3U, 53U, 47U), true);
-        add_config(TensorShape(3U, 3U, 128U, 384U), true);
-    }
-};
-} // namespace datasets
-} // namespace test
-} // namespace arm_compute
-#endif /* ARM_COMPUTE_TEST_WINOGRAD_FILTER_TRANSFORM_DATASET */
diff --git a/tests/datasets/WinogradInputTransformDataset.h b/tests/datasets/WinogradInputTransformDataset.h
index 07e41eb..625daa0 100644
--- a/tests/datasets/WinogradInputTransformDataset.h
+++ b/tests/datasets/WinogradInputTransformDataset.h
@@ -37,13 +37,12 @@
 class WinogradInputTransformDataset
 {
 public:
-    using type = std::tuple<TensorShape, PadStrideInfo, Size2D, bool>;
+    using type = std::tuple<TensorShape, WinogradInfo>;
 
     struct iterator
     {
-        iterator(std::vector<TensorShape>::const_iterator in_it, std::vector<PadStrideInfo>::const_iterator info_it, std::vector<Size2D>::const_iterator kernel_dims_it,
-                 std::vector<bool>::const_iterator format_it)
-            : _in_it{ std::move(in_it) }, _info_it{ std::move(info_it) }, _kernel_dims_it{ std::move(kernel_dims_it) }, _format_it{ std::move(format_it) }
+        iterator(std::vector<TensorShape>::const_iterator in_it, std::vector<WinogradInfo>::const_iterator info_it)
+            : _in_it{ std::move(in_it) }, _info_it{ std::move(info_it) }
         {
         }
 
@@ -51,50 +50,42 @@
         {
             std::stringstream description;
             description << "In=" << *_in_it << ":";
-            description << "Info=" << *_info_it;
-            description << "KernelDims=" << *_kernel_dims_it;
-            description << "IsNCHW=" << *_format_it;
+            description << "WinogradInfo=" << *_info_it;
             return description.str();
         }
 
         WinogradInputTransformDataset::type operator*() const
         {
-            return std::make_tuple(*_in_it, *_info_it, *_kernel_dims_it, *_format_it);
+            return std::make_tuple(*_in_it, *_info_it);
         }
 
         iterator &operator++()
         {
             ++_in_it;
             ++_info_it;
-            ++_kernel_dims_it;
-            ++_format_it;
 
             return *this;
         }
 
     private:
-        std::vector<TensorShape>::const_iterator   _in_it;
-        std::vector<PadStrideInfo>::const_iterator _info_it;
-        std::vector<Size2D>::const_iterator        _kernel_dims_it;
-        std::vector<bool>::const_iterator          _format_it;
+        std::vector<TensorShape>::const_iterator  _in_it;
+        std::vector<WinogradInfo>::const_iterator _info_it;
     };
 
     iterator begin() const
     {
-        return iterator(_in_shapes.begin(), _infos.begin(), _kernel_dims.begin(), _format.begin());
+        return iterator(_in_shapes.begin(), _infos.begin());
     }
 
     int size() const
     {
-        return std::min(_in_shapes.size(), std::min(_infos.size(), std::min(_kernel_dims.size(), _format.size())));
+        return std::min(_in_shapes.size(), _infos.size());
     }
 
-    void add_config(TensorShape in, PadStrideInfo info, Size2D kernel_dims, bool format)
+    void add_config(TensorShape in, WinogradInfo info)
     {
         _in_shapes.emplace_back(std::move(in));
         _infos.emplace_back(std::move(info));
-        _kernel_dims.emplace_back(std::move(kernel_dims));
-        _format.emplace_back(std::move(format));
     }
 
 protected:
@@ -102,10 +93,8 @@
     WinogradInputTransformDataset(WinogradInputTransformDataset &&) = default;
 
 private:
-    std::vector<TensorShape>   _in_shapes{};
-    std::vector<PadStrideInfo> _infos{};
-    std::vector<Size2D>        _kernel_dims{};
-    std::vector<bool>          _format{};
+    std::vector<TensorShape>  _in_shapes{};
+    std::vector<WinogradInfo> _infos{};
 };
 
 class SmallWinogradInputTransformDataset final : public WinogradInputTransformDataset
@@ -113,13 +102,13 @@
 public:
     SmallWinogradInputTransformDataset()
     {
-        add_config(TensorShape(9U, 9U), PadStrideInfo(1, 1, 1, 1), Size2D(3U, 3U), true);
-        add_config(TensorShape(27U, 13U, 2U), PadStrideInfo(1, 1, 0, 0), Size2D(3U, 3U), true);
-        add_config(TensorShape(128U, 64U, 1U, 3U), PadStrideInfo(1, 1, 1, 1), Size2D(3U, 3U), true);
-        add_config(TensorShape(9U, 9U, 3U, 4U), PadStrideInfo(1, 1, 0, 0), Size2D(3U, 3U), true);
-        add_config(TensorShape(27U, 13U, 2U, 4U), PadStrideInfo(1, 1, 1, 1), Size2D(3U, 3U), true);
-        add_config(TensorShape(9U, 9U, 3U, 5U), PadStrideInfo(1, 1, 0, 0), Size2D(3U, 3U), true);
-        add_config(TensorShape(14U, 14U, 512U, 2U), PadStrideInfo(1, 1, 1, 1), Size2D(3U, 3U), true);
+        add_config(TensorShape(9U, 9U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(9U, 9U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(27U, 13U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(27U, 13U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(128U, 64U, 1U, 3U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(128U, 64U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(9U, 9U, 3U, 4U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(27U, 13U, 2U, 4U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(27U, 13U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(9U, 9U, 3U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(14U, 14U, 512U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
     }
 };
 
@@ -128,10 +117,10 @@
 public:
     LargeWinogradInputTransformDataset()
     {
-        add_config(TensorShape(42U, 37U, 8U, 15U), PadStrideInfo(1, 1, 1, 1), Size2D(3U, 3U), true);
-        add_config(TensorShape(57U, 60U, 13U, 8U), PadStrideInfo(1, 1, 1, 1), Size2D(3U, 3U), true);
-        add_config(TensorShape(128U, 64U, 21U, 13U), PadStrideInfo(1, 1, 0, 0), Size2D(3U, 3U), true);
-        add_config(TensorShape(83U, 72U, 14U, 5U), PadStrideInfo(1, 1, 0, 0), Size2D(3U, 3U), true);
+        add_config(TensorShape(42U, 37U, 8U, 15U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(42U, 37U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(57U, 60U, 13U, 8U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(57U, 60U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(128U, 64U, 21U, 13U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(128U, 64U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(83U, 72U, 14U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(83U, 72U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
     }
 };
 } // namespace datasets
diff --git a/tests/datasets/WinogradOutputTransformDataset.h b/tests/datasets/WinogradOutputTransformDataset.h
index c42d6c8..35fce95 100644
--- a/tests/datasets/WinogradOutputTransformDataset.h
+++ b/tests/datasets/WinogradOutputTransformDataset.h
@@ -37,20 +37,14 @@
 class WinogradOutputTransformDataset
 {
 public:
-    using type = std::tuple<TensorShape, Size2D, Size2D, Size2D, DataLayout>;
+    using type = std::tuple<TensorShape, WinogradInfo>;
 
     struct iterator
     {
-        iterator(std::vector<TensorShape>::const_iterator a_it,
-                 std::vector<Size2D>::const_iterator      b_it,
-                 std::vector<Size2D>::const_iterator      c_it,
-                 std::vector<Size2D>::const_iterator      d_it,
-                 std::vector<DataLayout>::const_iterator  data_layout_it)
+        iterator(std::vector<TensorShape>::const_iterator  a_it,
+                 std::vector<WinogradInfo>::const_iterator info_it)
             : _a_it{ std::move(a_it) },
-              _b_it{ std::move(b_it) },
-              _c_it{ std::move(c_it) },
-              _d_it{ std::move(d_it) },
-              _data_layout_it{ std::move(data_layout_it) }
+              _info_it{ std::move(info_it) }
         {
         }
 
@@ -58,54 +52,42 @@
         {
             std::stringstream description;
             description << "Input=" << *_a_it << ":";
-            description << "KernelDims=" << *_b_it << ":";
-            description << "OutputDims=" << *_c_it << ":";
-            description << "NumTiles=" << *_d_it << ":";
-            description << "DataLayout=" << *_data_layout_it;
+            description << "WinogradInfo=" << *_info_it << ":";
             return description.str();
         }
 
         WinogradOutputTransformDataset::type operator*() const
         {
-            return std::make_tuple(*_a_it, *_b_it, *_c_it, *_d_it, *_data_layout_it);
+            return std::make_tuple(*_a_it, *_info_it);
         }
 
         iterator &operator++()
         {
             ++_a_it;
-            ++_b_it;
-            ++_c_it;
-            ++_d_it;
-            ++_data_layout_it;
+            ++_info_it;
 
             return *this;
         }
 
     private:
-        std::vector<TensorShape>::const_iterator _a_it;
-        std::vector<Size2D>::const_iterator      _b_it;
-        std::vector<Size2D>::const_iterator      _c_it;
-        std::vector<Size2D>::const_iterator      _d_it;
-        std::vector<DataLayout>::const_iterator  _data_layout_it;
+        std::vector<TensorShape>::const_iterator  _a_it;
+        std::vector<WinogradInfo>::const_iterator _info_it;
     };
 
     iterator begin() const
     {
-        return iterator(_a_shapes.begin(), _b_dims.begin(), _c_dims.begin(), _d_dims.begin(), _data_layout.begin());
+        return iterator(_a_shapes.begin(), _info.begin());
     }
 
     int size() const
     {
-        return std::min(_a_shapes.size(), std::min(_b_dims.size(), std::min(_c_dims.size(), std::min(_d_dims.size(), _data_layout.size()))));
+        return std::min(_a_shapes.size(), _info.size());
     }
 
-    void add_config(TensorShape a, Size2D b, Size2D c, Size2D d, DataLayout data_layout)
+    void add_config(TensorShape a, WinogradInfo b)
     {
         _a_shapes.emplace_back(std::move(a));
-        _b_dims.emplace_back(std::move(b));
-        _c_dims.emplace_back(std::move(c));
-        _d_dims.emplace_back(std::move(d));
-        _data_layout.emplace_back(std::move(data_layout));
+        _info.emplace_back(std::move(b));
     }
 
 protected:
@@ -113,11 +95,8 @@
     WinogradOutputTransformDataset(WinogradOutputTransformDataset &&) = default;
 
 private:
-    std::vector<TensorShape> _a_shapes{};
-    std::vector<Size2D>      _b_dims{};
-    std::vector<Size2D>      _c_dims{};
-    std::vector<Size2D>      _d_dims{};
-    std::vector<DataLayout>  _data_layout{};
+    std::vector<TensorShape>  _a_shapes{};
+    std::vector<WinogradInfo> _info{};
 };
 
 class SmallWinogradOutputTransformDataset final : public WinogradOutputTransformDataset
@@ -125,12 +104,12 @@
 public:
     SmallWinogradOutputTransformDataset()
     {
-        add_config(TensorShape(24U, 49U, 16U), Size2D(3, 3), Size2D(14U, 14U), Size2D(7U, 7U), DataLayout::NCHW);
-        add_config(TensorShape(13U, 6U, 16U), Size2D(3, 3), Size2D(5U, 4U), Size2D(3U, 2U), DataLayout::NCHW);
-        add_config(TensorShape(7U, 20U, 16U), Size2D(3, 3), Size2D(8U, 9U), Size2D(4U, 5U), DataLayout::NCHW);
-        add_config(TensorShape(24U, 49U, 16U, 3U), Size2D(3, 3), Size2D(14U, 14U), Size2D(7U, 7U), DataLayout::NCHW);
-        add_config(TensorShape(13U, 6U, 16U, 2U), Size2D(3, 3), Size2D(5U, 4U), Size2D(3U, 2U), DataLayout::NCHW);
-        add_config(TensorShape(7U, 20U, 16U, 5U), Size2D(3, 3), Size2D(8U, 9U), Size2D(4U, 5U), DataLayout::NCHW);
+        add_config(TensorShape(13U, 6U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(7U, 6U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(7U, 20U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(10U, 11U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(1U, 442U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW));
+        add_config(TensorShape(7U, 12U, 16U, 3U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
+        add_config(TensorShape(24U, 49U, 16U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(7U, 12U, 16U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
     }
 };
 
@@ -139,12 +118,12 @@
 public:
     LargeWinogradOutputTransformDataset()
     {
-        add_config(TensorShape(128U, 3136U, 16U), Size2D(3, 3), Size2D(112U, 112U), Size2D(56U, 56U), DataLayout::NCHW);
-        add_config(TensorShape(256U, 784U, 16U), Size2D(3, 3), Size2D(55U, 55U), Size2D(28U, 28U), DataLayout::NCHW);
-        add_config(TensorShape(512U, 169U, 16U), Size2D(3, 3), Size2D(26U, 26U), Size2D(13U, 13U), DataLayout::NCHW);
-        add_config(TensorShape(128U, 3136U, 16U, 3U), Size2D(3, 3), Size2D(112U, 112U), Size2D(56U, 56U), DataLayout::NCHW);
-        add_config(TensorShape(256U, 784U, 16U, 2U), Size2D(3, 3), Size2D(55U, 55U), Size2D(28U, 28U), DataLayout::NCHW);
-        add_config(TensorShape(512U, 169U, 16U, 5U), Size2D(3, 3), Size2D(26U, 26U), Size2D(13U, 13U), DataLayout::NCHW);
+        add_config(TensorShape(64U, 12544U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(224U, 224U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(32U, 3080U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(112U, 112U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW));
+        add_config(TensorShape(13U, 756U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW));
+        add_config(TensorShape(64U, 12544U, 16U, 3U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(224U, 224U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
+        add_config(TensorShape(32U, 3080U, 16U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(112U, 112U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW));
+        add_config(TensorShape(13U, 756U, 16U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW));
     }
 };
 } // namespace datasets