blob: 44617f624c0b299e40305b805043c3fd49264c7e [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/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTensorAllocator.h"
27#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h"
Georgios Pinitasdc460f12017-08-24 19:02:44 +010028#include "tests/CL/CLAccessor.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 Iodicebf179552017-09-05 13:51:21 +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 */
55constexpr AbsoluteTolerance<float> tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */
56constexpr AbsoluteTolerance<float> tolerance_qs8(3); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */
57constexpr AbsoluteTolerance<float> tolerance_qs16(6); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */
58} // namespace
59
60TEST_SUITE(CL)
61TEST_SUITE(PoolingLayer)
62
63template <typename T>
64using CLPoolingLayerFixture = PoolingLayerValidationFixture<CLTensor, CLAccessor, CLPoolingLayer, T>;
65
66TEST_SUITE(Float)
67TEST_SUITE(FP32)
68FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType",
69 DataType::F32))))
70{
71 // Validate output
72 validate(CLAccessor(_target), _reference, tolerance_f32);
73}
74FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType",
75 DataType::F32))))
76{
77 // Validate output
78 validate(CLAccessor(_target), _reference, tolerance_f32);
79}
80TEST_SUITE_END()
81
82TEST_SUITE(FP16)
Georgios Pinitas583137c2017-08-31 18:12:42 +010083FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture<half>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP,
84 framework::dataset::make("DataType", DataType::F16))))
Georgios Pinitasdc460f12017-08-24 19:02:44 +010085{
86 // Validate output
87 validate(CLAccessor(_target), _reference, tolerance_f16);
88}
Georgios Pinitas583137c2017-08-31 18:12:42 +010089FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP,
90 framework::dataset::make("DataType", DataType::F16))))
Georgios Pinitasdc460f12017-08-24 19:02:44 +010091{
92 // Validate output
93 validate(CLAccessor(_target), _reference, tolerance_f16);
94}
95TEST_SUITE_END()
96TEST_SUITE_END()
97
98template <typename T>
99using CLPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture<CLTensor, CLAccessor, CLPoolingLayer, T>;
100
101TEST_SUITE(Quantized)
102TEST_SUITE(QS8)
103FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS,
104 framework::dataset::make("DataType", DataType::QS8))),
105 framework::dataset::make("FractionalBits", 1, 4)))
106{
107 // Validate output
108 validate(CLAccessor(_target), _reference, tolerance_qs8);
109}
110FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS,
111 framework::dataset::make("DataType", DataType::QS8))),
112 framework::dataset::make("FractionalBits", 1, 4)))
113{
114 // Validate output
115 validate(CLAccessor(_target), _reference, tolerance_qs8);
116}
117TEST_SUITE_END()
118
119TEST_SUITE(QS16)
120FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS,
121 framework::dataset::make("DataType", DataType::QS16))),
122 framework::dataset::make("FractionalBits", 1, 12)))
123{
124 // Validate output
125 validate(CLAccessor(_target), _reference, tolerance_qs16);
126}
127FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS,
128 framework::dataset::make("DataType", DataType::QS16))),
129 framework::dataset::make("FractionalBits", 1, 12)))
130{
131 // Validate output
132 validate(CLAccessor(_target), _reference, tolerance_qs16);
133}
134TEST_SUITE_END()
135TEST_SUITE_END()
136
137TEST_SUITE_END()
138TEST_SUITE_END()
139} // namespace validation
140} // namespace test
141} // namespace arm_compute