Georgios Pinitas | 5ee66ea | 2017-09-07 17:29:16 +0100 | [diff] [blame] | 1 | /* |
Georgios Pinitas | f78625b | 2018-02-22 12:00:22 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Georgios Pinitas | 5ee66ea | 2017-09-07 17:29:16 +0100 | [diff] [blame] | 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_RESHAPE_LAYER_DATASET |
| 25 | #define ARM_COMPUTE_TEST_RESHAPE_LAYER_DATASET |
| 26 | |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 27 | #include "utils/TypePrinter.h" |
Georgios Pinitas | 5ee66ea | 2017-09-07 17:29:16 +0100 | [diff] [blame] | 28 | |
| 29 | #include "arm_compute/core/TensorShape.h" |
| 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | namespace test |
| 34 | { |
| 35 | namespace datasets |
| 36 | { |
| 37 | class ReshapeLayerDataset |
| 38 | { |
| 39 | public: |
| 40 | using type = std::tuple<TensorShape, TensorShape>; |
| 41 | |
| 42 | struct iterator |
| 43 | { |
| 44 | iterator(std::vector<TensorShape>::const_iterator in_it, std::vector<TensorShape>::const_iterator out_it) |
| 45 | : _in_it{ std::move(in_it) }, _out_it{ std::move(out_it) } |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | std::string description() const |
| 50 | { |
| 51 | std::stringstream description; |
| 52 | description << "In=" << *_in_it << ":"; |
| 53 | description << "Out=" << *_out_it; |
| 54 | return description.str(); |
| 55 | } |
| 56 | |
| 57 | ReshapeLayerDataset::type operator*() const |
| 58 | { |
| 59 | return std::make_tuple(*_in_it, *_out_it); |
| 60 | } |
| 61 | |
| 62 | iterator &operator++() |
| 63 | { |
| 64 | ++_in_it; |
| 65 | ++_out_it; |
| 66 | |
| 67 | return *this; |
| 68 | } |
| 69 | |
| 70 | private: |
| 71 | std::vector<TensorShape>::const_iterator _in_it; |
| 72 | std::vector<TensorShape>::const_iterator _out_it; |
| 73 | }; |
| 74 | |
| 75 | iterator begin() const |
| 76 | { |
| 77 | return iterator(_in_shapes.begin(), _out_shapes.begin()); |
| 78 | } |
| 79 | |
| 80 | int size() const |
| 81 | { |
| 82 | return std::min(_in_shapes.size(), _out_shapes.size()); |
| 83 | } |
| 84 | |
| 85 | void add_config(TensorShape in, TensorShape out) |
| 86 | { |
| 87 | _in_shapes.emplace_back(std::move(in)); |
| 88 | _out_shapes.emplace_back(std::move(out)); |
| 89 | } |
| 90 | |
| 91 | protected: |
| 92 | ReshapeLayerDataset() = default; |
| 93 | ReshapeLayerDataset(ReshapeLayerDataset &&) = default; |
| 94 | |
| 95 | private: |
| 96 | std::vector<TensorShape> _in_shapes{}; |
| 97 | std::vector<TensorShape> _out_shapes{}; |
| 98 | }; |
| 99 | |
| 100 | class SmallReshapeLayerDataset final : public ReshapeLayerDataset |
| 101 | { |
| 102 | public: |
| 103 | SmallReshapeLayerDataset() |
| 104 | { |
Georgios Pinitas | f78625b | 2018-02-22 12:00:22 +0000 | [diff] [blame] | 105 | add_config(TensorShape(3U), TensorShape(1U, 1U, 3U)); |
Georgios Pinitas | 5ee66ea | 2017-09-07 17:29:16 +0100 | [diff] [blame] | 106 | add_config(TensorShape(16U), TensorShape(4U, 2U, 2U)); |
| 107 | add_config(TensorShape(2U, 2U, 8U), TensorShape(4U, 8U)); |
| 108 | add_config(TensorShape(3U, 3U, 16U), TensorShape(144U)); |
| 109 | add_config(TensorShape(17U, 3U, 12U), TensorShape(1U, 1U, 612U)); |
| 110 | add_config(TensorShape(26U, 26U, 32U), TensorShape(13U, 13U, 128U)); |
| 111 | add_config(TensorShape(31U, 23U, 4U, 7U), TensorShape(2U, 14U, 713U)); |
| 112 | } |
| 113 | }; |
| 114 | } // namespace datasets |
| 115 | } // namespace test |
| 116 | } // namespace arm_compute |
| 117 | #endif /* ARM_COMPUTE_TEST_RESHAPE_LAYER_DATASET */ |