blob: cbe63645dea2dcc5ce0a9ac128c75b50e24dd132 [file] [log] [blame]
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef ARM_COMPUTE_TEST_WINOGRAD_INPUT_TRANSFORM_DATASET
25#define ARM_COMPUTE_TEST_WINOGRAD_INPUT_TRANSFORM_DATASET
26
27#include "utils/TypePrinter.h"
28
29#include "arm_compute/core/Types.h"
30
31namespace arm_compute
32{
33namespace test
34{
35namespace datasets
36{
37class WinogradInputTransformDataset
38{
39public:
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000040 using type = std::tuple<TensorShape, WinogradInfo>;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000041
42 struct iterator
43 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000044 iterator(std::vector<TensorShape>::const_iterator in_it, std::vector<WinogradInfo>::const_iterator info_it)
45 : _in_it{ std::move(in_it) }, _info_it{ std::move(info_it) }
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000046 {
47 }
48
49 std::string description() const
50 {
51 std::stringstream description;
52 description << "In=" << *_in_it << ":";
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000053 description << "WinogradInfo=" << *_info_it;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000054 return description.str();
55 }
56
57 WinogradInputTransformDataset::type operator*() const
58 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000059 return std::make_tuple(*_in_it, *_info_it);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000060 }
61
62 iterator &operator++()
63 {
64 ++_in_it;
65 ++_info_it;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000066
67 return *this;
68 }
69
70 private:
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000071 std::vector<TensorShape>::const_iterator _in_it;
72 std::vector<WinogradInfo>::const_iterator _info_it;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000073 };
74
75 iterator begin() const
76 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000077 return iterator(_in_shapes.begin(), _infos.begin());
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000078 }
79
80 int size() const
81 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000082 return std::min(_in_shapes.size(), _infos.size());
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000083 }
84
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000085 void add_config(TensorShape in, WinogradInfo info)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000086 {
87 _in_shapes.emplace_back(std::move(in));
88 _infos.emplace_back(std::move(info));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000089 }
90
91protected:
92 WinogradInputTransformDataset() = default;
93 WinogradInputTransformDataset(WinogradInputTransformDataset &&) = default;
94
95private:
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000096 std::vector<TensorShape> _in_shapes{};
97 std::vector<WinogradInfo> _infos{};
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000098};
99
100class SmallWinogradInputTransformDataset final : public WinogradInputTransformDataset
101{
102public:
103 SmallWinogradInputTransformDataset()
104 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000105 add_config(TensorShape(9U, 9U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(9U, 9U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
106 add_config(TensorShape(27U, 13U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(27U, 13U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
107 add_config(TensorShape(128U, 64U, 1U, 3U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(128U, 64U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
108 add_config(TensorShape(9U, 9U, 3U, 4U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
109 add_config(TensorShape(27U, 13U, 2U, 4U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(27U, 13U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
110 add_config(TensorShape(9U, 9U, 3U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
111 add_config(TensorShape(14U, 14U, 512U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
Giorgio Arenafe5ef382018-04-17 10:14:10 +0100112 add_config(TensorShape(9U, 9U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(9U, 9U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
113 add_config(TensorShape(27U, 13U, 2U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(27U, 13U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
114 add_config(TensorShape(128U, 64U, 1U, 3U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(128U, 64U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
115 add_config(TensorShape(9U, 9U, 3U, 4U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
116 add_config(TensorShape(27U, 13U, 2U, 4U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(27U, 13U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
117 add_config(TensorShape(9U, 9U, 3U, 5U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
118 add_config(TensorShape(14U, 14U, 512U, 2U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000119 }
120};
121
122class LargeWinogradInputTransformDataset final : public WinogradInputTransformDataset
123{
124public:
125 LargeWinogradInputTransformDataset()
126 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000127 add_config(TensorShape(42U, 37U, 8U, 15U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(42U, 37U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
128 add_config(TensorShape(57U, 60U, 13U, 8U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(57U, 60U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
129 add_config(TensorShape(128U, 64U, 21U, 13U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(128U, 64U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
130 add_config(TensorShape(83U, 72U, 14U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(83U, 72U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
Giorgio Arenafe5ef382018-04-17 10:14:10 +0100131 add_config(TensorShape(42U, 37U, 8U, 15U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(42U, 37U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
132 add_config(TensorShape(57U, 60U, 13U, 8U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(57U, 60U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
133 add_config(TensorShape(128U, 64U, 21U, 13U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(128U, 64U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
134 add_config(TensorShape(83U, 72U, 14U, 5U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(83U, 72U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000135 }
136};
137} // namespace datasets
138} // namespace test
139} // namespace arm_compute
140#endif /* ARM_COMPUTE_TEST_WINOGRAD_INPUT_TRANSFORM_DATASET */