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 | |
| 27 | #include "tests/TypePrinter.h" |
| 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: |
| 41 | using type = std::tuple<TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, TensorShape, PadStrideInfo, PadStrideInfo>; |
| 42 | |
| 43 | struct iterator |
| 44 | { |
| 45 | iterator(std::vector<TensorShape>::const_iterator src_it, |
| 46 | std::vector<TensorShape>::const_iterator filter_it, |
| 47 | std::vector<TensorShape>::const_iterator depthwise_out_it, |
| 48 | std::vector<TensorShape>::const_iterator weights_it, |
| 49 | std::vector<TensorShape>::const_iterator biases_it, |
| 50 | std::vector<TensorShape>::const_iterator dst_it, |
| 51 | std::vector<PadStrideInfo>::const_iterator depthwise_infos_it, |
| 52 | std::vector<PadStrideInfo>::const_iterator pointwise_infos_it) |
| 53 | : _src_it{ std::move(src_it) }, |
| 54 | _filter_it{ std::move(filter_it) }, |
| 55 | _depthwise_out_it{ std::move(depthwise_out_it) }, |
| 56 | _weights_it{ std::move(weights_it) }, |
| 57 | _biases_it{ std::move(biases_it) }, |
| 58 | _dst_it{ std::move(dst_it) }, |
| 59 | _depthwise_infos_it{ std::move(depthwise_infos_it) }, |
| 60 | _pointwise_infos_it{ std::move(pointwise_infos_it) } |
| 61 | { |
| 62 | } |
| 63 | |
| 64 | std::string description() const |
| 65 | { |
| 66 | std::stringstream description; |
| 67 | description << "In=" << *_src_it << ":"; |
| 68 | description << "Filter=" << *_filter_it << ":"; |
| 69 | description << "Depthwise Out=" << *_depthwise_out_it << ":"; |
| 70 | description << "Weights=" << *_weights_it << ":"; |
| 71 | description << "Biases=" << *_biases_it << ":"; |
| 72 | description << "Out=" << *_dst_it << ":"; |
| 73 | description << "Depthwise Info=" << *_depthwise_infos_it; |
| 74 | description << "Pointwise Info=" << *_pointwise_infos_it; |
| 75 | return description.str(); |
| 76 | } |
| 77 | |
| 78 | DepthwiseSeparableConvolutionLayerDataset::type operator*() const |
| 79 | { |
| 80 | return std::make_tuple(*_src_it, *_filter_it, *_depthwise_out_it, *_weights_it, *_biases_it, *_dst_it, *_depthwise_infos_it, *_pointwise_infos_it); |
| 81 | } |
| 82 | |
| 83 | iterator &operator++() |
| 84 | { |
| 85 | ++_src_it; |
| 86 | ++_filter_it; |
| 87 | ++_depthwise_out_it; |
| 88 | ++_weights_it; |
| 89 | ++_biases_it; |
| 90 | ++_dst_it; |
| 91 | ++_depthwise_infos_it; |
| 92 | ++_pointwise_infos_it; |
| 93 | |
| 94 | return *this; |
| 95 | } |
| 96 | |
| 97 | private: |
| 98 | std::vector<TensorShape>::const_iterator _src_it; |
| 99 | std::vector<TensorShape>::const_iterator _filter_it; |
| 100 | std::vector<TensorShape>::const_iterator _depthwise_out_it; |
| 101 | std::vector<TensorShape>::const_iterator _weights_it; |
| 102 | std::vector<TensorShape>::const_iterator _biases_it; |
| 103 | std::vector<TensorShape>::const_iterator _dst_it; |
| 104 | std::vector<PadStrideInfo>::const_iterator _depthwise_infos_it; |
| 105 | std::vector<PadStrideInfo>::const_iterator _pointwise_infos_it; |
| 106 | }; |
| 107 | |
| 108 | iterator begin() const |
| 109 | { |
| 110 | return iterator(_src_shapes.begin(), _filter_shapes.begin(), _depthwise_out_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(), _depthwise_infos.begin(), |
| 111 | _pointwise_infos.begin()); |
| 112 | } |
| 113 | |
| 114 | int size() const |
| 115 | { |
| 116 | return std::min(_src_shapes.size(), std::min(_filter_shapes.size(), std::min(_depthwise_out_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), std::min(_dst_shapes.size(), |
| 117 | std::min(_depthwise_infos.size(), _pointwise_infos.size()))))))); |
| 118 | } |
| 119 | |
| 120 | void add_config(TensorShape src, TensorShape filter, TensorShape depthwise_out, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo depthwise_info, PadStrideInfo pointwise_info) |
| 121 | { |
| 122 | _src_shapes.emplace_back(std::move(src)); |
| 123 | _filter_shapes.emplace_back(std::move(filter)); |
| 124 | _depthwise_out_shapes.emplace_back(std::move(depthwise_out)); |
| 125 | _weight_shapes.emplace_back(std::move(weights)); |
| 126 | _bias_shapes.emplace_back(std::move(biases)); |
| 127 | _dst_shapes.emplace_back(std::move(dst)); |
| 128 | _depthwise_infos.emplace_back(std::move(depthwise_info)); |
| 129 | _pointwise_infos.emplace_back(std::move(pointwise_info)); |
| 130 | } |
| 131 | |
| 132 | protected: |
| 133 | DepthwiseSeparableConvolutionLayerDataset() = default; |
| 134 | DepthwiseSeparableConvolutionLayerDataset(DepthwiseSeparableConvolutionLayerDataset &&) = default; |
| 135 | |
| 136 | private: |
| 137 | std::vector<TensorShape> _src_shapes{}; |
| 138 | std::vector<TensorShape> _filter_shapes{}; |
| 139 | std::vector<TensorShape> _depthwise_out_shapes{}; |
| 140 | std::vector<TensorShape> _weight_shapes{}; |
| 141 | std::vector<TensorShape> _bias_shapes{}; |
| 142 | std::vector<TensorShape> _dst_shapes{}; |
| 143 | std::vector<PadStrideInfo> _depthwise_infos{}; |
| 144 | std::vector<PadStrideInfo> _pointwise_infos{}; |
| 145 | }; |
| 146 | } // namespace datasets |
| 147 | } // namespace test |
| 148 | } // namespace arm_compute |
| 149 | #endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET */ |