blob: db7b0b3e5743d08734c6c0d42d371c214006450a [file] [log] [blame]
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +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_RESHAPE_LAYER_DATASET
25#define ARM_COMPUTE_TEST_RESHAPE_LAYER_DATASET
26
27#include "tests/TypePrinter.h"
28
29#include "arm_compute/core/TensorShape.h"
30
31namespace arm_compute
32{
33namespace test
34{
35namespace datasets
36{
37class ReshapeLayerDataset
38{
39public:
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
91protected:
92 ReshapeLayerDataset() = default;
93 ReshapeLayerDataset(ReshapeLayerDataset &&) = default;
94
95private:
96 std::vector<TensorShape> _in_shapes{};
97 std::vector<TensorShape> _out_shapes{};
98};
99
100class SmallReshapeLayerDataset final : public ReshapeLayerDataset
101{
102public:
103 SmallReshapeLayerDataset()
104 {
105 add_config(TensorShape(16U), TensorShape(4U, 2U, 2U));
106 add_config(TensorShape(2U, 2U, 8U), TensorShape(4U, 8U));
107 add_config(TensorShape(3U, 3U, 16U), TensorShape(144U));
108 add_config(TensorShape(17U, 3U, 12U), TensorShape(1U, 1U, 612U));
109 add_config(TensorShape(26U, 26U, 32U), TensorShape(13U, 13U, 128U));
110 add_config(TensorShape(31U, 23U, 4U, 7U), TensorShape(2U, 14U, 713U));
111 }
112};
113} // namespace datasets
114} // namespace test
115} // namespace arm_compute
116#endif /* ARM_COMPUTE_TEST_RESHAPE_LAYER_DATASET */