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