Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 1 | /* |
| 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 Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 27 | #include "utils/TypePrinter.h" |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 28 | |
| 29 | #include "arm_compute/core/TensorShape.h" |
| 30 | #include "arm_compute/core/Types.h" |
| 31 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | namespace test |
| 35 | { |
| 36 | namespace datasets |
| 37 | { |
| 38 | class DepthwiseSeparableConvolutionLayerDataset |
| 39 | { |
| 40 | public: |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 41 | using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, PadStrideInfo, PadStrideInfo>; |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 42 | |
| 43 | struct iterator |
| 44 | { |
| 45 | iterator(std::vector<TensorShape>::const_iterator src_it, |
| 46 | std::vector<TensorShape>::const_iterator filter_it, |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 47 | std::vector<TensorShape>::const_iterator filter_biases_it, |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 48 | 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 Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 56 | _filter_biases_it{ std::move(filter_biases_it) }, |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 57 | _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 Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 71 | description << "FilterBiases=" << *_filter_biases_it << ":"; |
Anthony Barbier | de12af4 | 2017-08-30 16:13:58 +0100 | [diff] [blame] | 72 | description << "DepthwiseOut=" << *_depthwise_out_it << ":"; |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 73 | description << "Weights=" << *_weights_it << ":"; |
| 74 | description << "Biases=" << *_biases_it << ":"; |
| 75 | description << "Out=" << *_dst_it << ":"; |
Anthony Barbier | de12af4 | 2017-08-30 16:13:58 +0100 | [diff] [blame] | 76 | description << "DepthwiseInfo=" << *_depthwise_infos_it << ":"; |
| 77 | description << "PointwiseInfo=" << *_pointwise_infos_it; |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 78 | return description.str(); |
| 79 | } |
| 80 | |
| 81 | DepthwiseSeparableConvolutionLayerDataset::type operator*() const |
| 82 | { |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 83 | 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 Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | iterator &operator++() |
| 87 | { |
| 88 | ++_src_it; |
| 89 | ++_filter_it; |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 90 | ++_filter_biases_it; |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 91 | ++_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 Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 104 | std::vector<TensorShape>::const_iterator _filter_biases_it; |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 105 | 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 Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 115 | 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 Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 117 | _pointwise_infos.begin()); |
| 118 | } |
| 119 | |
| 120 | int size() const |
| 121 | { |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 122 | 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 Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 125 | } |
| 126 | |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 127 | 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 Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 129 | { |
| 130 | _src_shapes.emplace_back(std::move(src)); |
| 131 | _filter_shapes.emplace_back(std::move(filter)); |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 132 | _filter_biases_shapes.emplace_back(std::move(filter_bias)); |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 133 | _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 | |
| 141 | protected: |
| 142 | DepthwiseSeparableConvolutionLayerDataset() = default; |
| 143 | DepthwiseSeparableConvolutionLayerDataset(DepthwiseSeparableConvolutionLayerDataset &&) = default; |
| 144 | |
| 145 | private: |
| 146 | std::vector<TensorShape> _src_shapes{}; |
| 147 | std::vector<TensorShape> _filter_shapes{}; |
Georgios Pinitas | 81a26ad | 2017-10-23 20:29:30 +0100 | [diff] [blame] | 148 | std::vector<TensorShape> _filter_biases_shapes{}; |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 149 | 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 */ |