blob: ff68ecf4811d1a3c3975f4dc9f6ea6568c5188ee [file] [log] [blame]
Georgios Pinitasdc460f12017-08-24 19:02:44 +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#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
Georgios Pinitasdc460f12017-08-24 19:02:44 +010028#include "tests/NEON/Accessor.h"
29#include "tests/PaddingCalculator.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010030#include "tests/datasets/PoolingTypesDataset.h"
31#include "tests/datasets/ShapeDatasets.h"
32#include "tests/framework/Asserts.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
36#include "tests/validation/fixtures/PoolingLayerFixture.h"
Georgios Pinitasdc460f12017-08-24 19:02:44 +010037
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44namespace
45{
46/** Input data set for float data types */
Gian Marco Iodice16824302017-09-28 15:41:37 +010047const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7, 9 })),
Georgios Pinitasdc460f12017-08-24 19:02:44 +010048 framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) }));
49
50/** Input data set for quantized data types */
Georgios Pinitascdf51452017-08-31 14:21:36 +010051const auto PoolingLayerDatasetQS = combine(combine(framework::dataset::make("PoolingType", { PoolingType::MAX, PoolingType::AVG }), framework::dataset::make("PoolingSize", { 2, 3 })),
Georgios Pinitasdc460f12017-08-24 19:02:44 +010052 framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) }));
53
54constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */
55#ifdef ARM_COMPUTE_ENABLE_FP16
56constexpr AbsoluteTolerance<float> tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */
57#endif /* ARM_COMPUTE_ENABLE_FP16 */
58constexpr AbsoluteTolerance<float> tolerance_qs8(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */
59constexpr AbsoluteTolerance<float> tolerance_qs16(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */
60} // namespace
61
62TEST_SUITE(NEON)
63TEST_SUITE(PoolingLayer)
64
65//TODO(COMPMID-415): Configuration tests?
66
67template <typename T>
68using NEPoolingLayerFixture = PoolingLayerValidationFixture<Tensor, Accessor, NEPoolingLayer, T>;
69
70TEST_SUITE(Float)
71TEST_SUITE(FP32)
72FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType",
73 DataType::F32))))
74{
75 // Validate output
76 validate(Accessor(_target), _reference, tolerance_f32);
77}
78FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType",
79 DataType::F32))))
80{
81 // Validate output
82 validate(Accessor(_target), _reference, tolerance_f32);
83}
84TEST_SUITE_END()
85
86#ifdef ARM_COMPUTE_ENABLE_FP16
87TEST_SUITE(FP16)
Georgios Pinitas583137c2017-08-31 18:12:42 +010088FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture<half>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP,
89 framework::dataset::make("DataType", DataType::F16))))
Georgios Pinitasdc460f12017-08-24 19:02:44 +010090{
91 // Validate output
92 validate(Accessor(_target), _reference, tolerance_f16);
93}
Georgios Pinitas583137c2017-08-31 18:12:42 +010094FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP,
95 framework::dataset::make("DataType", DataType::F16))))
Georgios Pinitasdc460f12017-08-24 19:02:44 +010096{
97 // Validate output
98 validate(Accessor(_target), _reference, tolerance_f16);
99}
100TEST_SUITE_END()
101#endif /* ARM_COMPUTE_ENABLE_FP16 */
102TEST_SUITE_END()
103
104template <typename T>
105using NEPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture<Tensor, Accessor, NEPoolingLayer, T>;
106
107TEST_SUITE(Quantized)
108TEST_SUITE(QS8)
109FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS,
110 framework::dataset::make("DataType", DataType::QS8))),
111 framework::dataset::make("FractionalBits", 1, 5)))
112{
113 // Validate output
114 validate(Accessor(_target), _reference, tolerance_qs8);
115}
116FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS,
117 framework::dataset::make("DataType", DataType::QS8))),
118 framework::dataset::make("FractionalBits", 1, 5)))
119{
120 // Validate output
121 validate(Accessor(_target), _reference, tolerance_qs8);
122}
123TEST_SUITE_END()
124
125TEST_SUITE(QS16)
126FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS,
127 framework::dataset::make("DataType", DataType::QS16))),
128 framework::dataset::make("FractionalBits", 1, 13)))
129{
130 // Validate output
131 validate(Accessor(_target), _reference, tolerance_qs16);
132}
133FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS,
134 framework::dataset::make("DataType", DataType::QS16))),
135 framework::dataset::make("FractionalBits", 1, 13)))
136{
137 // Validate output
138 validate(Accessor(_target), _reference, tolerance_qs16);
139}
140TEST_SUITE_END()
141TEST_SUITE_END()
142
143TEST_SUITE_END()
144TEST_SUITE_END()
145} // namespace validation
146} // namespace test
147} // namespace arm_compute