blob: efc0cbd27ec9fa8c7516244edb96f824230a04db [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_SEPARABLE_CONVOLUTION_LAYER_DATASET
25#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_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{
38class DepthwiseSeparableConvolutionLayerDataset
39{
40public:
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010041 using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, PadStrideInfo, 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 filter_it,
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010047 std::vector<TensorShape>::const_iterator filter_biases_it,
Giorgio Arena93a690e2017-08-01 16:09:33 +010048 std::vector<TensorShape>::const_iterator depthwise_out_it,
49 std::vector<TensorShape>::const_iterator weights_it,
50 std::vector<TensorShape>::const_iterator biases_it,
51 std::vector<TensorShape>::const_iterator dst_it,
52 std::vector<PadStrideInfo>::const_iterator depthwise_infos_it,
53 std::vector<PadStrideInfo>::const_iterator pointwise_infos_it)
54 : _src_it{ std::move(src_it) },
55 _filter_it{ std::move(filter_it) },
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010056 _filter_biases_it{ std::move(filter_biases_it) },
Giorgio Arena93a690e2017-08-01 16:09:33 +010057 _depthwise_out_it{ std::move(depthwise_out_it) },
58 _weights_it{ std::move(weights_it) },
59 _biases_it{ std::move(biases_it) },
60 _dst_it{ std::move(dst_it) },
61 _depthwise_infos_it{ std::move(depthwise_infos_it) },
62 _pointwise_infos_it{ std::move(pointwise_infos_it) }
63 {
64 }
65
66 std::string description() const
67 {
68 std::stringstream description;
69 description << "In=" << *_src_it << ":";
70 description << "Filter=" << *_filter_it << ":";
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010071 description << "FilterBiases=" << *_filter_biases_it << ":";
Anthony Barbierde12af42017-08-30 16:13:58 +010072 description << "DepthwiseOut=" << *_depthwise_out_it << ":";
Giorgio Arena93a690e2017-08-01 16:09:33 +010073 description << "Weights=" << *_weights_it << ":";
74 description << "Biases=" << *_biases_it << ":";
75 description << "Out=" << *_dst_it << ":";
Anthony Barbierde12af42017-08-30 16:13:58 +010076 description << "DepthwiseInfo=" << *_depthwise_infos_it << ":";
77 description << "PointwiseInfo=" << *_pointwise_infos_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +010078 return description.str();
79 }
80
81 DepthwiseSeparableConvolutionLayerDataset::type operator*() const
82 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010083 return std::make_tuple(*_src_it, *_filter_it, *_filter_biases_it, *_depthwise_out_it, *_weights_it, *_biases_it, *_dst_it, *_depthwise_infos_it, *_pointwise_infos_it);
Giorgio Arena93a690e2017-08-01 16:09:33 +010084 }
85
86 iterator &operator++()
87 {
88 ++_src_it;
89 ++_filter_it;
Georgios Pinitas81a26ad2017-10-23 20:29:30 +010090 ++_filter_biases_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +010091 ++_depthwise_out_it;
92 ++_weights_it;
93 ++_biases_it;
94 ++_dst_it;
95 ++_depthwise_infos_it;
96 ++_pointwise_infos_it;
97
98 return *this;
99 }
100
101 private:
102 std::vector<TensorShape>::const_iterator _src_it;
103 std::vector<TensorShape>::const_iterator _filter_it;
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100104 std::vector<TensorShape>::const_iterator _filter_biases_it;
Giorgio Arena93a690e2017-08-01 16:09:33 +0100105 std::vector<TensorShape>::const_iterator _depthwise_out_it;
106 std::vector<TensorShape>::const_iterator _weights_it;
107 std::vector<TensorShape>::const_iterator _biases_it;
108 std::vector<TensorShape>::const_iterator _dst_it;
109 std::vector<PadStrideInfo>::const_iterator _depthwise_infos_it;
110 std::vector<PadStrideInfo>::const_iterator _pointwise_infos_it;
111 };
112
113 iterator begin() const
114 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100115 return iterator(_src_shapes.begin(), _filter_shapes.begin(), _filter_biases_shapes.begin(), _depthwise_out_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(),
116 _depthwise_infos.begin(),
Giorgio Arena93a690e2017-08-01 16:09:33 +0100117 _pointwise_infos.begin());
118 }
119
120 int size() const
121 {
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100122 return std::min(_src_shapes.size(), std::min(_filter_shapes.size(), std::min(_filter_biases_shapes.size(), std::min(_depthwise_out_shapes.size(), std::min(_weight_shapes.size(),
123 std::min(_bias_shapes.size(), std::min(_dst_shapes.size(),
124 std::min(_depthwise_infos.size(), _pointwise_infos.size()))))))));
Giorgio Arena93a690e2017-08-01 16:09:33 +0100125 }
126
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100127 void add_config(TensorShape src, TensorShape filter, TensorShape filter_bias, TensorShape depthwise_out, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo depthwise_info,
128 PadStrideInfo pointwise_info)
Giorgio Arena93a690e2017-08-01 16:09:33 +0100129 {
130 _src_shapes.emplace_back(std::move(src));
131 _filter_shapes.emplace_back(std::move(filter));
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100132 _filter_biases_shapes.emplace_back(std::move(filter_bias));
Giorgio Arena93a690e2017-08-01 16:09:33 +0100133 _depthwise_out_shapes.emplace_back(std::move(depthwise_out));
134 _weight_shapes.emplace_back(std::move(weights));
135 _bias_shapes.emplace_back(std::move(biases));
136 _dst_shapes.emplace_back(std::move(dst));
137 _depthwise_infos.emplace_back(std::move(depthwise_info));
138 _pointwise_infos.emplace_back(std::move(pointwise_info));
139 }
140
141protected:
142 DepthwiseSeparableConvolutionLayerDataset() = default;
143 DepthwiseSeparableConvolutionLayerDataset(DepthwiseSeparableConvolutionLayerDataset &&) = default;
144
145private:
146 std::vector<TensorShape> _src_shapes{};
147 std::vector<TensorShape> _filter_shapes{};
Georgios Pinitas81a26ad2017-10-23 20:29:30 +0100148 std::vector<TensorShape> _filter_biases_shapes{};
Giorgio Arena93a690e2017-08-01 16:09:33 +0100149 std::vector<TensorShape> _depthwise_out_shapes{};
150 std::vector<TensorShape> _weight_shapes{};
151 std::vector<TensorShape> _bias_shapes{};
152 std::vector<TensorShape> _dst_shapes{};
153 std::vector<PadStrideInfo> _depthwise_infos{};
154 std::vector<PadStrideInfo> _pointwise_infos{};
155};
156} // namespace datasets
157} // namespace test
158} // namespace arm_compute
159#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET */