blob: 5cdece4f661ec6cdcefbdc58806fd95f701e5fd0 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +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_DATASET_POOLING_LAYER_DATASET_H__
25#define __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__
26
27#include "TypePrinter.h"
28
29#include "arm_compute/core/TensorShape.h"
30#include "arm_compute/core/Types.h"
31#include "dataset/GenericDataset.h"
32
33#include <type_traits>
34
35#ifdef BOOST
36#include "boost_wrapper.h"
Anthony Barbierac69aa12017-07-03 17:39:37 +010037#endif /* BOOST */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
39namespace arm_compute
40{
41namespace test
42{
43class PoolingLayerDataObject
44{
45public:
46 operator std::string() const
47 {
48 std::stringstream ss;
49 ss << "PoolingLayer";
50 ss << "_I" << src_shape;
51 ss << "_S_" << info.pool_size();
52 ss << "_F_" << info.pool_type();
53 ss << "_PS" << info.pad_stride_info();
54 return ss.str();
55 }
56
57 friend std::ostream &operator<<(std::ostream &s, const PoolingLayerDataObject &obj)
58 {
59 s << static_cast<std::string>(obj);
60 return s;
61 }
62
63public:
64 TensorShape src_shape;
65 TensorShape dst_shape;
66 PoolingLayerInfo info;
67};
68
69template <unsigned int Size>
70using PoolingLayerDataset = GenericDataset<PoolingLayerDataObject, Size>;
71
72class AlexNetPoolingLayerDataset final : public PoolingLayerDataset<3>
73{
74public:
75 AlexNetPoolingLayerDataset()
76 : GenericDataset
77 {
78 PoolingLayerDataObject{ TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) },
79 PoolingLayerDataObject{ TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) },
80 PoolingLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) },
81 }
82 {
83 }
84
85 ~AlexNetPoolingLayerDataset() = default;
86};
87
88class LeNet5PoolingLayerDataset final : public PoolingLayerDataset<2>
89{
90public:
91 LeNet5PoolingLayerDataset()
92 : GenericDataset
93 {
94 PoolingLayerDataObject{ TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) },
95 PoolingLayerDataObject{ TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) },
96 }
97 {
98 }
99
100 ~LeNet5PoolingLayerDataset() = default;
101};
102
103class GoogLeNetPoolingLayerDataset final : public PoolingLayerDataset<10>
104{
105public:
106 GoogLeNetPoolingLayerDataset()
107 : GenericDataset
108 {
109 // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1
110 // pool1/3x3_s2
111 PoolingLayerDataObject{ TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) },
112 // pool2/3x3_s2
113 PoolingLayerDataObject{ TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) },
114 // inception_3a/pool
115 PoolingLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) },
116 // inception_3b/pool
117 PoolingLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) },
118 // pool3/3x3_s2
119 PoolingLayerDataObject{ TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) },
120 // inception_4a/pool
121 PoolingLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) },
122 // inception_4b/pool, inception_4c/pool, inception_4d/pool
123 PoolingLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) },
124 // inception_4e/pool
125 PoolingLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) },
126 // pool4/3x3_s2
127 PoolingLayerDataObject{ TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) },
128 // inception_5a/pool, inception_5b/pool
129 PoolingLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) },
130 }
131 {
132 }
133
134 ~GoogLeNetPoolingLayerDataset() = default;
135};
136
137class RandomPoolingLayerDataset final : public PoolingLayerDataset<8>
138{
139public:
140 RandomPoolingLayerDataset()
141 : GenericDataset
142 {
143 PoolingLayerDataObject{ TensorShape(27U, 27U, 16U), TensorShape(13U, 13U, 16U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) },
144 PoolingLayerDataObject{ TensorShape(13U, 13U, 32U), TensorShape(6U, 6U, 32U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) },
145 PoolingLayerDataObject{ TensorShape(24U, 24U, 10U), TensorShape(12U, 12U, 10U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) },
146 PoolingLayerDataObject{ TensorShape(8U, 8U, 30U), TensorShape(4U, 4U, 30U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) },
147 PoolingLayerDataObject{ TensorShape(27U, 27U, 16U), TensorShape(13U, 13U, 16U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(2, 2, 0, 0)) },
148 PoolingLayerDataObject{ TensorShape(13U, 13U, 32U), TensorShape(6U, 6U, 32U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(2, 2, 0, 0)) },
149 PoolingLayerDataObject{ TensorShape(24U, 24U, 10U), TensorShape(12U, 12U, 10U), PoolingLayerInfo(PoolingType::AVG, 2, PadStrideInfo(2, 2, 0, 0)) },
150 PoolingLayerDataObject{ TensorShape(8U, 8U, 30U), TensorShape(4U, 4U, 30U), PoolingLayerInfo(PoolingType::AVG, 2, PadStrideInfo(2, 2, 0, 0)) },
151 }
152 {
153 }
154
155 ~RandomPoolingLayerDataset() = default;
156};
157} // namespace test
158} // namespace arm_compute
159#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__