blob: 015f9157aad6a29477501b73ba175948b24a850b [file] [log] [blame]
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +01001/*
Anitha Rajb566b6e2023-08-23 11:40:06 +01002 * Copyright (c) 2017-2018, 2023 Arm Limited.
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +01003 *
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 */
Anitha Rajb566b6e2023-08-23 11:40:06 +010024#ifndef ACL_TESTS_DATASETS_RESHAPELAYERDATASET_H
25#define ACL_TESTS_DATASETS_RESHAPELAYERDATASET_H
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +010026
Anthony Barbier2a07e182017-08-04 18:20:27 +010027#include "utils/TypePrinter.h"
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +010028
29#include "arm_compute/core/TensorShape.h"
30
31namespace arm_compute
32{
33namespace test
34{
35namespace datasets
36{
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +000037/** [ReshapeLayer datasets] **/
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +010038class ReshapeLayerDataset
39{
40public:
41 using type = std::tuple<TensorShape, TensorShape>;
42
43 struct iterator
44 {
45 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
50 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
76 iterator begin() const
77 {
78 return iterator(_in_shapes.begin(), _out_shapes.begin());
79 }
80
81 int size() const
82 {
83 return std::min(_in_shapes.size(), _out_shapes.size());
84 }
85
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
92protected:
93 ReshapeLayerDataset() = default;
94 ReshapeLayerDataset(ReshapeLayerDataset &&) = default;
95
96private:
97 std::vector<TensorShape> _in_shapes{};
98 std::vector<TensorShape> _out_shapes{};
99};
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000100/** [ReshapeLayer datasets] **/
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100101
102class SmallReshapeLayerDataset final : public ReshapeLayerDataset
103{
104public:
105 SmallReshapeLayerDataset()
106 {
Georgios Pinitasf78625b2018-02-22 12:00:22 +0000107 add_config(TensorShape(3U), TensorShape(1U, 1U, 3U));
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100108 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));
Anitha Rajb566b6e2023-08-23 11:40:06 +0100114 add_config(TensorShape(8U, 8U, 8U), TensorShape(8U, 64U));
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100115 }
116};
117} // namespace datasets
118} // namespace test
119} // namespace arm_compute
Anitha Rajb566b6e2023-08-23 11:40:06 +0100120#endif // ACL_TESTS_DATASETS_RESHAPELAYERDATASET_H