blob: 35fce952cd08cf2d4f10c0bfd22f10e896bcb120 [file] [log] [blame]
Gian Marco Iodiced2fab732018-03-02 11:18:12 +00001/*
2 * Copyright (c) 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_WINOGRAD_OUTPUT_TRANSFORM_DATASET
25#define ARM_COMPUTE_TEST_WINOGRAD_OUTPUT_TRANSFORM_DATASET
26
27#include "utils/TypePrinter.h"
28
29#include "arm_compute/core/TensorShape.h"
30
31namespace arm_compute
32{
33namespace test
34{
35namespace datasets
36{
37class WinogradOutputTransformDataset
38{
39public:
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000040 using type = std::tuple<TensorShape, WinogradInfo>;
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000041
42 struct iterator
43 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000044 iterator(std::vector<TensorShape>::const_iterator a_it,
45 std::vector<WinogradInfo>::const_iterator info_it)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000046 : _a_it{ std::move(a_it) },
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000047 _info_it{ std::move(info_it) }
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000048 {
49 }
50
51 std::string description() const
52 {
53 std::stringstream description;
54 description << "Input=" << *_a_it << ":";
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000055 description << "WinogradInfo=" << *_info_it << ":";
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000056 return description.str();
57 }
58
59 WinogradOutputTransformDataset::type operator*() const
60 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000061 return std::make_tuple(*_a_it, *_info_it);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000062 }
63
64 iterator &operator++()
65 {
66 ++_a_it;
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000067 ++_info_it;
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000068
69 return *this;
70 }
71
72 private:
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000073 std::vector<TensorShape>::const_iterator _a_it;
74 std::vector<WinogradInfo>::const_iterator _info_it;
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000075 };
76
77 iterator begin() const
78 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000079 return iterator(_a_shapes.begin(), _info.begin());
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000080 }
81
82 int size() const
83 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000084 return std::min(_a_shapes.size(), _info.size());
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000085 }
86
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000087 void add_config(TensorShape a, WinogradInfo b)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000088 {
89 _a_shapes.emplace_back(std::move(a));
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000090 _info.emplace_back(std::move(b));
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000091 }
92
93protected:
94 WinogradOutputTransformDataset() = default;
95 WinogradOutputTransformDataset(WinogradOutputTransformDataset &&) = default;
96
97private:
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000098 std::vector<TensorShape> _a_shapes{};
99 std::vector<WinogradInfo> _info{};
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000100};
101
102class SmallWinogradOutputTransformDataset final : public WinogradOutputTransformDataset
103{
104public:
105 SmallWinogradOutputTransformDataset()
106 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000107 add_config(TensorShape(13U, 6U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(7U, 6U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
108 add_config(TensorShape(7U, 20U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(10U, 11U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
109 add_config(TensorShape(1U, 442U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW));
110 add_config(TensorShape(7U, 12U, 16U, 3U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
111 add_config(TensorShape(24U, 49U, 16U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
112 add_config(TensorShape(7U, 12U, 16U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW));
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000113 }
114};
115
116class LargeWinogradOutputTransformDataset final : public WinogradOutputTransformDataset
117{
118public:
119 LargeWinogradOutputTransformDataset()
120 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000121 add_config(TensorShape(64U, 12544U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(224U, 224U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
122 add_config(TensorShape(32U, 3080U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(112U, 112U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW));
123 add_config(TensorShape(13U, 756U, 16U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW));
124 add_config(TensorShape(64U, 12544U, 16U, 3U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(224U, 224U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW));
125 add_config(TensorShape(32U, 3080U, 16U, 2U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(112U, 112U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW));
126 add_config(TensorShape(13U, 756U, 16U, 5U), WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW));
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000127 }
128};
129} // namespace datasets
130} // namespace test
131} // namespace arm_compute
132#endif /* ARM_COMPUTE_TEST_WINOGRAD_OUTPUT_TRANSFORM_DATASET */