blob: a2caba9b2caede3fd6b83807e9bf23a35e0100a3 [file] [log] [blame]
Giorgio Arena93a690e2017-08-01 16:09:33 +01001/*
2 * Copyright (c) 2017 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_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:
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010041 using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape, PadStrideInfo>;
Giorgio Arena93a690e2017-08-01 16:09:33 +010042
43 struct iterator
44 {
45 iterator(std::vector<TensorShape>::const_iterator src_it,
46 std::vector<TensorShape>::const_iterator weights_it,
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010047 std::vector<TensorShape>::const_iterator biases_it,
Giorgio Arena93a690e2017-08-01 16:09:33 +010048 std::vector<TensorShape>::const_iterator dst_it,
49 std::vector<PadStrideInfo>::const_iterator infos_it)
50 : _src_it{ std::move(src_it) },
51 _weights_it{ std::move(weights_it) },
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010052 _biases_it{ std::move(biases_it) },
Giorgio Arena93a690e2017-08-01 16:09:33 +010053 _dst_it{ std::move(dst_it) },
54 _infos_it{ std::move(infos_it) }
55 {
56 }
57
58 std::string description() const
59 {
60 std::stringstream description;
61 description << "In=" << *_src_it << ":";
62 description << "Weights=" << *_weights_it << ":";
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010063 description << "Biases=" << *_biases_it << ":";
Giorgio Arena93a690e2017-08-01 16:09:33 +010064 description << "Out=" << *_dst_it << ":";
65 description << "Info=" << *_infos_it;
66 return description.str();
67 }
68
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000069 DepthwiseConvolutionLayerDataset::type operator*() const
Giorgio Arena93a690e2017-08-01 16:09:33 +010070 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010071 return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it, *_infos_it);
Giorgio Arena93a690e2017-08-01 16:09:33 +010072 }
73
74 iterator &operator++()
75 {
76 ++_src_it;
77 ++_weights_it;
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010078 ++_biases_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +010079 ++_dst_it;
80 ++_infos_it;
81
82 return *this;
83 }
84
85 private:
86 std::vector<TensorShape>::const_iterator _src_it;
87 std::vector<TensorShape>::const_iterator _weights_it;
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010088 std::vector<TensorShape>::const_iterator _biases_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +010089 std::vector<TensorShape>::const_iterator _dst_it;
90 std::vector<PadStrideInfo>::const_iterator _infos_it;
91 };
92
93 iterator begin() const
94 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010095 return iterator(_src_shapes.begin(), _weight_shapes.begin(), _biases_shapes.begin(), _dst_shapes.begin(), _infos.begin());
Giorgio Arena93a690e2017-08-01 16:09:33 +010096 }
97
98 int size() const
99 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100100 return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_biases_shapes.size(), std::min(_dst_shapes.size(), _infos.size()))));
Giorgio Arena93a690e2017-08-01 16:09:33 +0100101 }
102
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100103 void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo info)
Giorgio Arena93a690e2017-08-01 16:09:33 +0100104 {
105 _src_shapes.emplace_back(std::move(src));
106 _weight_shapes.emplace_back(std::move(weights));
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100107 _biases_shapes.emplace_back(std::move(biases));
Giorgio Arena93a690e2017-08-01 16:09:33 +0100108 _dst_shapes.emplace_back(std::move(dst));
109 _infos.emplace_back(std::move(info));
110 }
111
112protected:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000113 DepthwiseConvolutionLayerDataset() = default;
114 DepthwiseConvolutionLayerDataset(DepthwiseConvolutionLayerDataset &&) = default;
Giorgio Arena93a690e2017-08-01 16:09:33 +0100115
116private:
117 std::vector<TensorShape> _src_shapes{};
118 std::vector<TensorShape> _weight_shapes{};
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100119 std::vector<TensorShape> _biases_shapes{};
Giorgio Arena93a690e2017-08-01 16:09:33 +0100120 std::vector<TensorShape> _dst_shapes{};
121 std::vector<PadStrideInfo> _infos{};
122};
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000123class SmallDepthwiseConvolutionLayerDataset final : public DepthwiseConvolutionLayerDataset
Giorgio Arena9fe41442017-08-23 16:36:24 +0100124{
125public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000126 SmallDepthwiseConvolutionLayerDataset()
Giorgio Arena9fe41442017-08-23 16:36:24 +0100127 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100128 add_config(TensorShape(7U, 7U, 3U), TensorShape(3U, 3U, 3U), TensorShape(3U), TensorShape(5U, 5U, 3U), PadStrideInfo(1, 1, 0, 0));
129 add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 5U, 5U), TensorShape(5U), TensorShape(11U, 23U, 5U), PadStrideInfo(2, 1, 0, 0));
130 add_config(TensorShape(33U, 27U, 7U), TensorShape(7U, 3U, 7U), TensorShape(7U), TensorShape(10U, 13U, 7U), PadStrideInfo(3, 2, 1, 0));
131 add_config(TensorShape(33U, 27U, 11U), TensorShape(3U, 3U, 11U), TensorShape(11U), TensorShape(31U, 14U, 11U), PadStrideInfo(1, 2, 0, 1));
132 add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 9U, 2U), TensorShape(2U), TensorShape(15U, 13U, 2U), PadStrideInfo(1, 2, 1, 1));
133 add_config(TensorShape(23U, 27U, 5U), TensorShape(11U, 3U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(1, 2, 0, 0));
134 add_config(TensorShape(17U, 31U, 2U, 3U), TensorShape(5U, 9U, 2U), TensorShape(2U), TensorShape(15U, 13U, 2U, 3U), PadStrideInfo(1, 2, 1, 1));
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100135 // Asymmetric padding
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100136 add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U), TensorShape(7U), TensorShape(11U, 12U, 7U), PadStrideInfo(3, 2, 1, 1, 2, 0, DimensionRoundingType::FLOOR));
137 add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U), TensorShape(7U), TensorShape(11U, 12U, 7U), PadStrideInfo(3, 2, 1, 1, 0, 2, DimensionRoundingType::FLOOR));
138 add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U), TensorShape(7U), TensorShape(11U, 12U, 7U), PadStrideInfo(3, 2, 2, 1, 2, 0, DimensionRoundingType::FLOOR));
139 add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U), TensorShape(7U), TensorShape(11U, 12U, 7U), PadStrideInfo(3, 2, 1, 3, 0, 2, DimensionRoundingType::FLOOR));
140 add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U), TensorShape(7U), TensorShape(10U, 11U, 7U), PadStrideInfo(3, 2, 1, 0, 1, 0, DimensionRoundingType::FLOOR));
141 add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U), TensorShape(7U), TensorShape(10U, 11U, 7U), PadStrideInfo(3, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR));
Giorgio Arena9fe41442017-08-23 16:36:24 +0100142 }
143};
144
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000145class LargeDepthwiseConvolutionLayerDataset final : public DepthwiseConvolutionLayerDataset
Giorgio Arena9fe41442017-08-23 16:36:24 +0100146{
147public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000148 LargeDepthwiseConvolutionLayerDataset()
Giorgio Arena9fe41442017-08-23 16:36:24 +0100149 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100150 add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(55U), TensorShape(116U, 275U, 55U), PadStrideInfo(2, 1, 0, 0));
151 add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(77U), TensorShape(111U, 138U, 77U), PadStrideInfo(3, 2, 1, 0));
152 add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(22U), TensorShape(177U, 156U, 22U), PadStrideInfo(1, 2, 1, 1));
153 add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(55U), TensorShape(231U, 138U, 55U), PadStrideInfo(1, 2, 0, 0));
154 add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(77U), TensorShape(166U, 93U, 77U), PadStrideInfo(2, 3, 0, 1));
155 add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1));
Giorgio Arena9fe41442017-08-23 16:36:24 +0100156 }
157};
158
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000159class SmallDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100160{
161public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000162 SmallDepthwiseConvolutionLayerDataset3x3()
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100163 {
Georgios Pinitasb6f182d32017-11-29 10:17:56 +0000164 add_config(TensorShape(7U, 7U, 3U, 2U), TensorShape(3U, 3U, 3U), TensorShape(3U), TensorShape(5U, 5U, 3U, 2U), PadStrideInfo(1, 1, 0, 0));
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100165 add_config(TensorShape(33U, 27U, 11U), TensorShape(3U, 3U, 11U), TensorShape(11U), TensorShape(11U, 14U, 11U), PadStrideInfo(3, 2, 1, 1));
Georgios Pinitasb6f182d32017-11-29 10:17:56 +0000166 add_config(TensorShape(21U, 31U, 9U, 4U), TensorShape(3U, 3U, 9U), TensorShape(9U), TensorShape(21U, 15U, 9U, 4U), PadStrideInfo(1, 2, 1, 0));
167 add_config(TensorShape(33U, 27U, 11U, 3U), TensorShape(3U, 3U, 11U), TensorShape(11U), TensorShape(31U, 14U, 11U, 3U), PadStrideInfo(1, 2, 0, 1));
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100168 }
169};
170
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000171class LargeDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100172{
173public:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000174 LargeDepthwiseConvolutionLayerDataset3x3()
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100175 {
Georgios Pinitasb6f182d32017-11-29 10:17:56 +0000176 add_config(TensorShape(233U, 277U, 55U, 3U), TensorShape(3U, 3U, 55U), TensorShape(55U), TensorShape(116U, 275U, 55U, 3U), PadStrideInfo(2, 1, 0, 0));
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100177 add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(77U), TensorShape(111U, 138U, 77U), PadStrideInfo(3, 2, 1, 0));
178 add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(22U), TensorShape(177U, 156U, 22U), PadStrideInfo(1, 2, 1, 1));
179 add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(55U), TensorShape(231U, 138U, 55U), PadStrideInfo(1, 2, 0, 0));
Georgios Pinitasb6f182d32017-11-29 10:17:56 +0000180 add_config(TensorShape(333U, 277U, 77U, 5U), TensorShape(3U, 3U, 77U), TensorShape(77U), TensorShape(166U, 93U, 77U, 5U), PadStrideInfo(2, 3, 0, 1));
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100181 add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1));
Georgios Pinitasc26ecf82017-09-22 13:44:05 +0100182 }
183};
Giorgio Arena93a690e2017-08-01 16:09:33 +0100184} // namespace datasets
185} // namespace test
186} // namespace arm_compute
187#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET */