blob: 8a1f3b6f39ec6917ed83d4c1cc00ea80d3f1e7f6 [file] [log] [blame]
Giorgio Arena93a690e2017-08-01 16:09:33 +01001/*
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +00002 * Copyright (c) 2017-2019 ARM Limited.
Giorgio Arena93a690e2017-08-01 16:09:33 +01003 *
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_DEPTHWISE_CONVOLUTION_DATASET
25#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET
26
Anthony Barbier2a07e182017-08-04 18:20:27 +010027#include "utils/TypePrinter.h"
Giorgio Arena93a690e2017-08-01 16:09:33 +010028
29#include "arm_compute/core/TensorShape.h"
30#include "arm_compute/core/Types.h"
31
32namespace arm_compute
33{
34namespace test
35{
36namespace datasets
37{
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000038class DepthwiseConvolutionLayerDataset
Giorgio Arena93a690e2017-08-01 16:09:33 +010039{
40public:
Giorgio Arena76572242018-04-04 17:44:26 +010041 using type = std::tuple<TensorShape, Size2D, PadStrideInfo>;
Giorgio Arena93a690e2017-08-01 16:09:33 +010042
43 struct iterator
44 {
45 iterator(std::vector<TensorShape>::const_iterator src_it,
Giorgio Arena76572242018-04-04 17:44:26 +010046 std::vector<Size2D>::const_iterator weights_it,
Giorgio Arena93a690e2017-08-01 16:09:33 +010047 std::vector<PadStrideInfo>::const_iterator infos_it)
48 : _src_it{ std::move(src_it) },
49 _weights_it{ std::move(weights_it) },
Giorgio Arena93a690e2017-08-01 16:09:33 +010050 _infos_it{ std::move(infos_it) }
51 {
52 }
53
54 std::string description() const
55 {
56 std::stringstream description;
57 description << "In=" << *_src_it << ":";
58 description << "Weights=" << *_weights_it << ":";
Giorgio Arena93a690e2017-08-01 16:09:33 +010059 description << "Info=" << *_infos_it;
60 return description.str();
61 }
62
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000063 DepthwiseConvolutionLayerDataset::type operator*() const
Giorgio Arena93a690e2017-08-01 16:09:33 +010064 {
Giorgio Arena76572242018-04-04 17:44:26 +010065 return std::make_tuple(*_src_it, *_weights_it, *_infos_it);
Giorgio Arena93a690e2017-08-01 16:09:33 +010066 }
67
68 iterator &operator++()
69 {
70 ++_src_it;
71 ++_weights_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +010072 ++_infos_it;
73
74 return *this;
75 }
76
77 private:
78 std::vector<TensorShape>::const_iterator _src_it;
Giorgio Arena76572242018-04-04 17:44:26 +010079 std::vector<Size2D>::const_iterator _weights_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +010080 std::vector<PadStrideInfo>::const_iterator _infos_it;
81 };
82
83 iterator begin() const
84 {
Giorgio Arena76572242018-04-04 17:44:26 +010085 return iterator(_src_shapes.begin(), _weight_shapes.begin(), _infos.begin());
Giorgio Arena93a690e2017-08-01 16:09:33 +010086 }
87
88 int size() const
89 {
Giorgio Arena76572242018-04-04 17:44:26 +010090 return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), _infos.size()));
Giorgio Arena93a690e2017-08-01 16:09:33 +010091 }
92
Giorgio Arena76572242018-04-04 17:44:26 +010093 void add_config(TensorShape src, Size2D weights, PadStrideInfo info)
Giorgio Arena93a690e2017-08-01 16:09:33 +010094 {
95 _src_shapes.emplace_back(std::move(src));
96 _weight_shapes.emplace_back(std::move(weights));
Giorgio Arena93a690e2017-08-01 16:09:33 +010097 _infos.emplace_back(std::move(info));
98 }
99
100protected:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000101 DepthwiseConvolutionLayerDataset() = default;
102 DepthwiseConvolutionLayerDataset(DepthwiseConvolutionLayerDataset &&) = default;
Giorgio Arena93a690e2017-08-01 16:09:33 +0100103
104private:
105 std::vector<TensorShape> _src_shapes{};
Giorgio Arena76572242018-04-04 17:44:26 +0100106 std::vector<Size2D> _weight_shapes{};
Giorgio Arena93a690e2017-08-01 16:09:33 +0100107 std::vector<PadStrideInfo> _infos{};
108};
Alex Gildayc357c472018-03-21 13:54:09 +0000109
110/** Dataset containing small, generic depthwise convolution shapes. */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000111class SmallDepthwiseConvolutionLayerDataset final : public DepthwiseConvolutionLayerDataset
Giorgio Arena9fe41442017-08-23 16:36:24 +0100112{
113public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000114 SmallDepthwiseConvolutionLayerDataset()
Giorgio Arena9fe41442017-08-23 16:36:24 +0100115 {
Giorgio Arena76572242018-04-04 17:44:26 +0100116 add_config(TensorShape(7U, 7U, 1U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 0));
117 add_config(TensorShape(23U, 27U, 5U), Size2D(3U, 5U), PadStrideInfo(2, 1, 0, 0));
118 add_config(TensorShape(33U, 27U, 7U), Size2D(7U, 3U), PadStrideInfo(3, 2, 1, 0));
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100119 // Asymmetric padding
Giorgio Arena76572242018-04-04 17:44:26 +0100120 add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 1, 2, 0, DimensionRoundingType::FLOOR));
121 add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 1, 0, 2, DimensionRoundingType::FLOOR));
Giorgio Arena9fe41442017-08-23 16:36:24 +0100122 }
123};
124
Alex Gildayc357c472018-03-21 13:54:09 +0000125/** Dataset containing large, generic depthwise convolution shapes. */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000126class LargeDepthwiseConvolutionLayerDataset final : public DepthwiseConvolutionLayerDataset
Giorgio Arena9fe41442017-08-23 16:36:24 +0100127{
128public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000129 LargeDepthwiseConvolutionLayerDataset()
Giorgio Arena9fe41442017-08-23 16:36:24 +0100130 {
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000131 add_config(TensorShape(33U, 27U, 11U), Size2D(3U, 3U), PadStrideInfo(1, 2, 0, 1));
132 add_config(TensorShape(17U, 31U, 2U), Size2D(5U, 9U), PadStrideInfo(1, 2, 1, 1));
133 add_config(TensorShape(23U, 27U, 5U), Size2D(11U, 3U), PadStrideInfo(1, 2, 0, 0));
134 add_config(TensorShape(17U, 31U, 2U, 3U), Size2D(5U, 9U), PadStrideInfo(1, 2, 1, 1));
Giorgio Arena76572242018-04-04 17:44:26 +0100135 add_config(TensorShape(233U, 277U, 55U), Size2D(3U, 3U), PadStrideInfo(2, 1, 0, 0));
136 add_config(TensorShape(333U, 277U, 77U), Size2D(3U, 3U), PadStrideInfo(3, 2, 1, 0));
137 add_config(TensorShape(177U, 311U, 22U), Size2D(3U, 3U), PadStrideInfo(1, 2, 1, 1));
138 add_config(TensorShape(233U, 277U, 55U), Size2D(3U, 3U), PadStrideInfo(1, 2, 0, 0));
139 add_config(TensorShape(333U, 277U, 77U), Size2D(3U, 3U), PadStrideInfo(2, 3, 0, 1));
140 add_config(TensorShape(177U, 311U, 22U), Size2D(3U, 3U), PadStrideInfo(2, 1, 1, 1));
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000141 // Asymmetric padding
142 add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 2, 1, 2, 0, DimensionRoundingType::FLOOR));
143 add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 3, 0, 2, DimensionRoundingType::FLOOR));
144 add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 1, 0, 1, 0, DimensionRoundingType::FLOOR));
145 add_config(TensorShape(33U, 27U, 7U), Size2D(5U, 7U), PadStrideInfo(3, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
Giorgio Arena9fe41442017-08-23 16:36:24 +0100146 }
147};
148
Alex Gildayc357c472018-03-21 13:54:09 +0000149/** Dataset containing small, 3x3 depthwise convolution shapes. */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000150class SmallDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100151{
152public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000153 SmallDepthwiseConvolutionLayerDataset3x3()
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100154 {
Giorgio Arena76572242018-04-04 17:44:26 +0100155 add_config(TensorShape(3U, 3U, 2U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 0));
156 add_config(TensorShape(7U, 7U, 3U, 2U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 0));
Giorgio Arenad051e972018-06-20 11:46:42 +0100157 add_config(TensorShape(21U, 31U, 9U, 4U), Size2D(3U, 3U), PadStrideInfo(1, 1, 1, 0));
Georgios Pinitas15997872018-02-19 13:58:22 +0000158 // Asymmetric padding
Giorgio Arena76572242018-04-04 17:44:26 +0100159 add_config(TensorShape(33U, 27U, 11U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000160 }
161};
162
163class SmallDepthwiseConvolutionLayerDataset3x3NCHW final : public DepthwiseConvolutionLayerDataset
164{
165public:
166 SmallDepthwiseConvolutionLayerDataset3x3NCHW()
167 {
Giorgio Arena76572242018-04-04 17:44:26 +0100168 add_config(TensorShape(33U, 27U, 11U), Size2D(3U, 3U), PadStrideInfo(3, 2, 1, 1));
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000169 // Asymmetric padding
Giorgio Arena76572242018-04-04 17:44:26 +0100170 add_config(TensorShape(33U, 27U, 11U), Size2D(3U, 3U), PadStrideInfo(2, 2, 3, 1, 2, 1, DimensionRoundingType::FLOOR));
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100171 }
172};
173
Alex Gildayc357c472018-03-21 13:54:09 +0000174/** Dataset containing large, 3x3 depthwise convolution shapes. */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000175class LargeDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100176{
177public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000178 LargeDepthwiseConvolutionLayerDataset3x3()
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100179 {
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000180 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 1));
181 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(1, 1, 1, 1));
182 add_config(TensorShape(21U, 31U, 9U, 4U), Size2D(3U, 3U), PadStrideInfo(1, 2, 1, 0));
183 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(1, 2, 0, 1));
184 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(1, 2, 1, 1));
185 add_config(TensorShape(21U, 31U, 9U, 4U), Size2D(3U, 3U), PadStrideInfo(2, 1, 1, 0));
186 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(2, 1, 0, 1));
187 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(2, 1, 1, 1));
188 add_config(TensorShape(21U, 31U, 9U, 4U), Size2D(3U, 3U), PadStrideInfo(2, 2, 1, 0));
189 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 1));
190 add_config(TensorShape(33U, 27U, 11U, 3U), Size2D(3U, 3U), PadStrideInfo(2, 2, 1, 1));
Giorgio Arena76572242018-04-04 17:44:26 +0100191 add_config(TensorShape(233U, 277U, 55U, 3U), Size2D(3U, 3U), PadStrideInfo(2, 1, 0, 0));
192 add_config(TensorShape(177U, 311U, 22U), Size2D(3U, 3U), PadStrideInfo(1, 2, 1, 1));
193 add_config(TensorShape(233U, 277U, 55U), Size2D(3U, 3U), PadStrideInfo(1, 2, 0, 0));
194 add_config(TensorShape(333U, 277U, 77U, 5U), Size2D(3U, 3U), PadStrideInfo(2, 3, 0, 1));
195 add_config(TensorShape(177U, 311U, 22U), Size2D(3U, 3U), PadStrideInfo(2, 1, 1, 1));
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100196 }
197};
Alex Gildayc357c472018-03-21 13:54:09 +0000198
199/** Dataset containing optimized, 3x3 depthwise convolution shapes. */
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000200class SmallOptimizedDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset
Georgios Pinitas4074c992018-01-30 18:13:46 +0000201{
202public:
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000203 SmallOptimizedDepthwiseConvolutionLayerDataset3x3()
Georgios Pinitas4074c992018-01-30 18:13:46 +0000204 {
205 // Stride 1
Giorgio Arena76572242018-04-04 17:44:26 +0100206 add_config(TensorShape(7U, 7U, 16U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL));
207 add_config(TensorShape(7U, 7U, 16U), Size2D(3U, 3U), PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL));
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000208 // Stride 2
209 add_config(TensorShape(7U, 7U, 32U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL));
210 add_config(TensorShape(7U, 7U, 32U), Size2D(3U, 3U), PadStrideInfo(2, 2, 1, 1, 1, 1, DimensionRoundingType::CEIL));
211 }
212};
213/** Dataset containing optimized, 3x3 depthwise convolution shapes. */
214class LargeOptimizedDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset
215{
216public:
217 LargeOptimizedDepthwiseConvolutionLayerDataset3x3()
218 {
219 // Stride 1
220 add_config(TensorShape(233U, 277U, 16U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL));
221 add_config(TensorShape(233U, 7U, 16U), Size2D(3U, 3U), PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL));
Georgios Pinitasa799ce02018-09-12 20:11:34 +0100222 add_config(TensorShape(7U, 7U, 21U), Size2D(3U, 3U), PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL));
Giorgio Arena76572242018-04-04 17:44:26 +0100223 add_config(TensorShape(28U, 28U, 16U), Size2D(3U, 3U), PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL));
224 add_config(TensorShape(28U, 28U, 16U), Size2D(3U, 3U), PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL));
Georgios Pinitas4074c992018-01-30 18:13:46 +0000225 // Stride 2
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000226 add_config(TensorShape(233U, 277U, 32U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL));
227 add_config(TensorShape(233U, 277U, 32U), Size2D(3U, 3U), PadStrideInfo(2, 2, 1, 1, 1, 1, DimensionRoundingType::CEIL));
Giorgio Arena76572242018-04-04 17:44:26 +0100228 add_config(TensorShape(8U, 8U, 32U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::FLOOR));
229 add_config(TensorShape(8U, 8U, 32U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL));
Georgios Pinitasa799ce02018-09-12 20:11:34 +0100230 add_config(TensorShape(8U, 8U, 33U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL));
Giorgio Arena76572242018-04-04 17:44:26 +0100231 add_config(TensorShape(64U, 64U, 128U), Size2D(3U, 3U), PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::CEIL));
Georgios Pinitas4074c992018-01-30 18:13:46 +0000232 }
233};
Giorgio Arena93a690e2017-08-01 16:09:33 +0100234} // namespace datasets
235} // namespace test
236} // namespace arm_compute
237#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET */