blob: 3a6cacc0ba93c04daf75705224b609a46884fcb5 [file] [log] [blame]
Moritz Pflanzerb3d25792017-07-26 11:49:37 +01001/*
Gian Marco Iodice0841ca02021-02-01 14:37:02 +00002 * Copyright (c) 2017-2021 Arm Limited.
Moritz Pflanzerb3d25792017-07-26 11:49:37 +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 */
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/CLDirectConvolutionLayer.h"
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010028#include "tests/CL/CLAccessor.h"
29#include "tests/PaddingCalculator.h"
Jaroslaw Rzepecki2ecbada2017-11-29 13:51:34 +000030#include "tests/datasets/DirectConvolutionLayerDataset.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010031#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/DirectConvolutionLayerFixture.h"
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010037
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44namespace
45{
Manuel Bottinidc125192020-08-11 13:18:29 +010046RelativeTolerance<half> tolerance_fp16(half(0.2)); /**< Tolerance for floating point tests */
47RelativeTolerance<float> tolerance_fp32(0.05f); /**< Tolerance for floating point tests */
48AbsoluteTolerance<float> tolerance_fp32_abs(0.0003f); /**< Absolute Tolerance for floating point tests */
49constexpr float tolerance_num = 0.07f; /**< Tolerance number */
50constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance for quantized tests */
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010051
Michalis Spyrou45091732019-05-13 17:41:01 +010052const auto data_strides = combine(framework::dataset::make("StrideX", 1, 3), framework::dataset::make("StrideY", 1, 3));
53const auto data_strides_small = combine(framework::dataset::make("StrideX", 1), framework::dataset::make("StrideY", 1));
54const auto data_ksize_one = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 1)));
55const auto data_ksize_one_small = combine(framework::dataset::make("PadX", 0), combine(framework::dataset::make("PadY", 0), framework::dataset::make("KernelSize", 1)));
56const auto data_ksize_three = combine(framework::dataset::make("PadX", 0, 2), combine(framework::dataset::make("PadY", 0, 2), framework::dataset::make("KernelSize", 3)));
57const auto data_ksize_five = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 5)));
58const auto data_ksize_nine = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 9)));
59const auto data_ksize_nine_small = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 9)));
Michalis Spyroudef665a2017-08-14 11:26:37 +010060
Michalis Spyrou45091732019-05-13 17:41:01 +010061const auto data_all_kernels = concat(concat(data_ksize_one, data_ksize_three), data_ksize_five);
62
63const auto data = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_all_kernels));
64const auto data9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_ksize_nine));
65const auto data_small = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_one_small));
66const auto data_small9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_nine_small));
Michalis Spyrou064add62018-11-01 18:14:27 +000067
68/** Direct convolution nightly data set. */
Michele Di Giorgioba2cc1a2020-07-15 17:39:30 +010069const auto data_nightly = combine(data, framework::dataset::make("NumKernels", { 1, 4 }));
70const auto data_nightly_9x9 = combine(data9x9, framework::dataset::make("NumKernels", { 1, 4 }));
71const auto data_nightly_usecase = combine(framework::dataset::make("InputShape", { TensorShape{ 3U, 800U, 800U } }),
72 combine(framework::dataset::make("StrideX", { 1 }),
73 combine(framework::dataset::make("StrideY", { 1 }),
74 combine(framework::dataset::make("PadX", { 4 }),
75 combine(framework::dataset::make("PadY", { 4 }),
76 combine(framework::dataset::make("KernelSize", 9),
77 framework::dataset::make("NumKernels", { 16 })))))));
78
Michalis Spyrou064add62018-11-01 18:14:27 +000079/** Direct convolution precommit data set. */
Michalis Spyrou45091732019-05-13 17:41:01 +010080const auto data_precommit = combine(data_small, framework::dataset::make("NumKernels", { 1 }));
81const auto data_precommit_9x9 = combine(data_small9x9, framework::dataset::make("NumKernels", { 1 }));
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010082
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000083/** Activation function Dataset*/
84const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
Michalis Spyrou5ce99a22019-01-25 14:17:49 +000085{ ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) });
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010086} // namespace
87
88TEST_SUITE(CL)
89TEST_SUITE(DirectConvolutionLayer)
90
Georgios Pinitas30902ed2017-11-14 15:32:57 +000091// *INDENT-OFF*
92// clang-format off
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000093DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010094 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/weights
95 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching input feature maps
96 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Unsupported kernel width
97 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Non-rectangular weights dimensions
98 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid weights dimensions
99 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid stride
100 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases size
101 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases dimensions
102 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid output size
103 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Window shrink
104 TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32),
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000105 }),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100106 framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F16),
107 TensorInfo(TensorShape(3U, 3U, 3U, 4U), 1, DataType::F32),
Michalis Spyrou45091732019-05-13 17:41:01 +0100108 TensorInfo(TensorShape(11U, 11U, 2U, 4U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100109 TensorInfo(TensorShape(5U, 3U, 2U, 4U), 1, DataType::F32),
110 TensorInfo(TensorShape(3U, 3U, 2U, 4U, 3U), 1, DataType::F32),
111 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
112 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
113 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
114 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
115 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
116 TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32),
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000117 })),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100118 framework::dataset::make("BiasesInfo",{ TensorInfo(TensorShape(4U), 1, DataType::F32),
119 TensorInfo(TensorShape(4U), 1, DataType::F32),
120 TensorInfo(TensorShape(4U), 1, DataType::F32),
121 TensorInfo(TensorShape(4U), 1, DataType::F32),
122 TensorInfo(TensorShape(4U), 1, DataType::F32),
123 TensorInfo(TensorShape(4U), 1, DataType::F32),
124 TensorInfo(TensorShape(3U), 1, DataType::F32),
125 TensorInfo(TensorShape(4U, 2U), 1, DataType::F32),
126 TensorInfo(TensorShape(4U), 1, DataType::F32),
127 TensorInfo(TensorShape(4U), 1, DataType::F32),
128 TensorInfo(TensorShape(4U), 1, DataType::F32),
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000129 })),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100130 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
131 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
132 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
133 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
134 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
135 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
136 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
137 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
138 TensorInfo(TensorShape(26U, 11U, 4U), 1, DataType::F32),
139 TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
140 TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32),
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000141 })),
142 framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0),
143 PadStrideInfo(1, 1, 0, 0),
144 PadStrideInfo(1, 1, 0, 0),
145 PadStrideInfo(1, 1, 0, 0),
146 PadStrideInfo(1, 1, 0, 0),
147 PadStrideInfo(3, 3, 0, 0),
148 PadStrideInfo(1, 1, 0, 0),
149 PadStrideInfo(1, 1, 0, 0),
150 PadStrideInfo(1, 1, 0, 0),
151 PadStrideInfo(1, 1, 0, 0),
Giorgio Arena59486342017-12-01 10:42:47 +0000152 PadStrideInfo(1, 1, 0, 0),
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000153 })),
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000154 framework::dataset::make("ActivationInfo",
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000155{
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000156 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)
157})),
158 framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, false, false, true })),
159 input_info, weights_info, biases_info, output_info, conv_info, act_info, expected)
160{
161 bool is_valid = bool(CLDirectConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, act_info));
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000162 ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000163}
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000164
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100165template <typename T>
166using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
Jaroslaw Rzepecki2ecbada2017-11-29 13:51:34 +0000167template <typename T>
168using CLDirectConvolutionValidationWithTensorShapesFixture = DirectConvolutionValidationWithTensorShapesFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000169template <typename T>
170using CLDirectConvolutionLayerQuantizedFixture = DirectConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
171template <typename T>
172using CLDirectConvolutionValidationWithTensorShapesQuantizedFixture = DirectConvolutionValidationWithTensorShapesQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100173
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000174TEST_SUITE(NHWC)
175TEST_SUITE(FP16)
176FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT,
177 combine(combine(combine(zip(zip(zip(zip(zip(zip(
178 framework::dataset::make("InputShape", { TensorShape(27U, 13U, 2U),
179 TensorShape(9U, 5U, 6U, 4U),
180 TensorShape(3U, 5U, 7U, 2U),
181 TensorShape(32U, 37U, 3U) } ),
182 framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
183 framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
184 framework::dataset::make("PadX", { 1, 3, 0, 4 })),
185 framework::dataset::make("PadY", { 1, 3, 0, 4 })),
186 framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
187 framework::dataset::make("NumKernels", { 7, 3, 1, 3 })),
188 framework::dataset::make("DataType", DataType::F16)),
189 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
190 framework::dataset::make("DataLayout", DataLayout::NHWC)))
191{
192 validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
193}
194
195FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY,
196 combine(combine(combine(zip(zip(zip(zip(zip(zip(
197 framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
198 framework::dataset::make("StrideX", { 1 })),
199 framework::dataset::make("StrideY", { 1 })),
200 framework::dataset::make("PadX", { 1 })),
201 framework::dataset::make("PadY", { 1 })),
202 framework::dataset::make("KernelSize", { 9 })),
203 framework::dataset::make("NumKernels", { 3 })),
204 framework::dataset::make("DataType", DataType::F16)),
205 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::IDENTITY) )),
206 framework::dataset::make("DataLayout", DataLayout::NHWC)))
207{
208 validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
209}
210
211TEST_SUITE_END() // FP16
212
213TEST_SUITE(FP32)
214FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT,
215 combine(combine(combine(zip(zip(zip(zip(zip(zip(
216 framework::dataset::make("InputShape", { TensorShape(27U, 13U, 2U),
217 TensorShape(9U, 5U, 6U, 4U),
218 TensorShape(3U, 5U, 7U, 2U),
219 TensorShape(32U, 37U, 3U) } ),
220 framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
221 framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
222 framework::dataset::make("PadX", { 1, 3, 0, 4 })),
223 framework::dataset::make("PadY", { 1, 3, 0, 4 })),
224 framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
225 framework::dataset::make("NumKernels", { 7, 3, 1, 3 })),
226 framework::dataset::make("DataType", DataType::F32)),
227 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
228 framework::dataset::make("DataLayout", DataLayout::NHWC)))
229{
230 validate(CLAccessor(_target), _reference, tolerance_fp32);
231}
232
233FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY,
234 combine(combine(combine(zip(zip(zip(zip(zip(zip(
235 framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
236 framework::dataset::make("StrideX", { 1 })),
237 framework::dataset::make("StrideY", { 1 })),
238 framework::dataset::make("PadX", { 1 })),
239 framework::dataset::make("PadY", { 1 })),
240 framework::dataset::make("KernelSize", { 9 })),
241 framework::dataset::make("NumKernels", { 3 })),
242 framework::dataset::make("DataType", DataType::F32)),
243 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::IDENTITY) )),
244 framework::dataset::make("DataLayout", DataLayout::NHWC)))
245{
246 validate(CLAccessor(_target), _reference, tolerance_fp32);
247}
248
249TEST_SUITE_END() // FP32
250
251TEST_SUITE(Quantized)
252TEST_SUITE(QASYMM8)
253FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
254 combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
255 framework::dataset::make("InputShape", { TensorShape(27U, 13U, 2U),
256 TensorShape(9U, 5U, 6U, 4U),
257 TensorShape(3U, 5U, 7U, 2U),
258 TensorShape(32U, 37U, 3U) } ),
259 framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
260 framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
261 framework::dataset::make("PadX", { 1, 3, 0, 4 })),
262 framework::dataset::make("PadY", { 1, 3, 0, 4 })),
263 framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
264 framework::dataset::make("NumKernels", { 7, 3, 1, 3 })),
265 framework::dataset::make("DataType", DataType::QASYMM8)),
266 framework::dataset::make("QuantizationInfo", QuantizationInfo(1.1f / 255, 10))),
267 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
268 framework::dataset::make("DataLayout", DataLayout::NHWC)))
269{
270 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
271}
272
273FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
274 combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
275 framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
276 framework::dataset::make("StrideX", { 1 })),
277 framework::dataset::make("StrideY", { 1 })),
278 framework::dataset::make("PadX", { 1 })),
279 framework::dataset::make("PadY", { 1 })),
280 framework::dataset::make("KernelSize", { 9 })),
281 framework::dataset::make("NumKernels", { 3 })),
282 framework::dataset::make("DataType", DataType::QASYMM8)),
283 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
284 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
285 framework::dataset::make("DataLayout", DataLayout::NHWC)))
286{
287 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
288}
289
290TEST_SUITE_END() // QASYMM8
291//
292TEST_SUITE(QASYMM8_SIGNED)
293FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
294 combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
295 framework::dataset::make("InputShape", { TensorShape(27U, 13U, 2U),
296 TensorShape(9U, 5U, 6U, 4U),
297 TensorShape(3U, 5U, 7U, 2U),
298 TensorShape(32U, 37U, 3U) } ),
299 framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
300 framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
301 framework::dataset::make("PadX", { 1, 3, 0, 4 })),
302 framework::dataset::make("PadY", { 1, 3, 0, 4 })),
303 framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
304 framework::dataset::make("NumKernels", { 7, 3, 1, 3 })),
305 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
306 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
307 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
308 framework::dataset::make("DataLayout", DataLayout::NHWC)))
309{
310 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
311}
312
313FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY,
314 combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
315 framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
316 framework::dataset::make("StrideX", { 1 })),
317 framework::dataset::make("StrideY", { 1 })),
318 framework::dataset::make("PadX", { 1 })),
319 framework::dataset::make("PadY", { 1 })),
320 framework::dataset::make("KernelSize", { 9 })),
321 framework::dataset::make("NumKernels", { 3 })),
322 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
323 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
324 framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
325 framework::dataset::make("DataLayout", DataLayout::NHWC)))
326{
327 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
328}
329TEST_SUITE_END() // QASYMM8_SIGNED
330TEST_SUITE_END() // Quantized
331TEST_SUITE_END() // NHWC
332
333// clang-format on
334// *INDENT-ON*
335TEST_SUITE(NCHW)
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100336TEST_SUITE(Float)
337TEST_SUITE(FP16)
Michalis Spyrou064add62018-11-01 18:14:27 +0000338FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType", DataType::F16)),
339 ActivationFunctionsDataset),
340 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100341{
342 // Validate output
steniu013e05e4e2017-08-25 17:18:01 +0100343 validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100344}
Michalis Spyrou064add62018-11-01 18:14:27 +0000345FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F16)),
346 ActivationFunctionsDataset),
347 framework::dataset::make("DataLayout", DataLayout::NCHW)))
348{
349 // Validate output
350 validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
351}
352TEST_SUITE_END() // FP16
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100353
354TEST_SUITE(FP32)
Michalis Spyrou064add62018-11-01 18:14:27 +0000355FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType",
356 DataType::F32)),
357 ActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000358 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100359{
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100360 validate(CLAccessor(_target), _reference, tolerance_fp32);
361}
Michalis Spyrou064add62018-11-01 18:14:27 +0000362FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F32)),
363 ActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000364 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Michalis Spyrou064add62018-11-01 18:14:27 +0000365{
366 validate(CLAccessor(_target), _reference, tolerance_fp32);
367}
368TEST_SUITE_END() // FP32
Jaroslaw Rzepecki2ecbada2017-11-29 13:51:34 +0000369
370TEST_SUITE(FP32_CustomDataset)
Michalis Spyrou80943252019-01-10 17:19:50 +0000371FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::DirectConvolutionLayerDataset(),
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000372 framework::dataset::make("DataType", DataType::F32)),
373 ActivationFunctionsDataset))
Jaroslaw Rzepecki2ecbada2017-11-29 13:51:34 +0000374{
375 // Validate output
376 validate(CLAccessor(_target), _reference, tolerance_fp32);
377}
Michalis Spyrou064add62018-11-01 18:14:27 +0000378TEST_SUITE_END() // FP32_CustomDataset
379TEST_SUITE_END() // Float
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100380
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000381const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
382{
383 ActivationLayerInfo(),
384 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
385 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f)
386});
Chunosovd621bca2017-11-03 17:33:15 +0700387TEST_SUITE(Quantized)
388TEST_SUITE(QASYMM8)
Giorgio Arenae620a832020-02-17 16:33:20 +0000389FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit,
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100390 framework::dataset::make("DataType",
391 DataType::QASYMM8)),
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100392 framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })),
Giorgio Arenae620a832020-02-17 16:33:20 +0000393 QuantizedActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000394 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100395{
396 // Validate output
397 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
398}
Giorgio Arenae620a832020-02-17 16:33:20 +0000399FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit_9x9,
400 framework::dataset::make("DataType",
401 DataType::QASYMM8)),
Manuel Bottini136174a2020-11-24 13:04:19 +0000402 framework::dataset::make("QuantizationInfo", { QuantizationInfo(3.f / 255, 10), QuantizationInfo(1.1f, 10) })),
Giorgio Arenae620a832020-02-17 16:33:20 +0000403 QuantizedActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000404 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Michalis Spyrou064add62018-11-01 18:14:27 +0000405{
406 // Validate output
407 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
408}
Giorgio Arenae620a832020-02-17 16:33:20 +0000409FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly, framework::dataset::make("DataType",
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100410 DataType::QASYMM8)),
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100411 framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })),
Giorgio Arenae620a832020-02-17 16:33:20 +0000412 QuantizedActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000413 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Giorgio Arenae620a832020-02-17 16:33:20 +0000414{
415 // Validate output
416 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
417}
418FIXTURE_DATA_TEST_CASE(RunLarge9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly_9x9,
419 framework::dataset::make("DataType",
420 DataType::QASYMM8)),
Manuel Bottini136174a2020-11-24 13:04:19 +0000421 framework::dataset::make("QuantizationInfo", { QuantizationInfo(3.f / 255, 10), QuantizationInfo(1.1f, 10) })),
Giorgio Arenae620a832020-02-17 16:33:20 +0000422 QuantizedActivationFunctionsDataset),
423 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100424{
425 // Validate output
426 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
427}
428
Michalis Spyrou064add62018-11-01 18:14:27 +0000429TEST_SUITE_END() // QASYMM8
Jaroslaw Rzepecki2ecbada2017-11-29 13:51:34 +0000430
431TEST_SUITE(QASYMM8_CustomDataset)
Giorgio Arenae620a832020-02-17 16:33:20 +0000432FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
433 combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(),
434 framework::dataset::make("DataType", DataType::QASYMM8)),
435 framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })),
436 QuantizedActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000437 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Jaroslaw Rzepecki2ecbada2017-11-29 13:51:34 +0000438{
439 // Validate output
440 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
441}
Michalis Spyrou064add62018-11-01 18:14:27 +0000442TEST_SUITE_END() // QASYMM8_CustomDataset
Sheri Zhang681f2d42020-02-20 11:23:08 +0000443
444TEST_SUITE(QASYMM8_SIGNED)
445
Giorgio Arenae620a832020-02-17 16:33:20 +0000446FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit, framework::dataset::make("DataType",
Sheri Zhang681f2d42020-02-20 11:23:08 +0000447 DataType::QASYMM8_SIGNED)),
448 framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, -10) })),
Giorgio Arenae620a832020-02-17 16:33:20 +0000449 QuantizedActivationFunctionsDataset),
450 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
Sheri Zhang681f2d42020-02-20 11:23:08 +0000451{
452 // Validate output
453 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
454}
455
Giorgio Arenae620a832020-02-17 16:33:20 +0000456FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit_9x9,
Sheri Zhang681f2d42020-02-20 11:23:08 +0000457 framework::dataset::make("DataType",
458 DataType::QASYMM8_SIGNED)),
459 framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })),
Giorgio Arenae620a832020-02-17 16:33:20 +0000460 QuantizedActivationFunctionsDataset),
461 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Sheri Zhang681f2d42020-02-20 11:23:08 +0000462{
463 // Validate output
464 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
465}
466
467FIXTURE_DATA_TEST_CASE(RunCustomDataset, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY,
Giorgio Arenae620a832020-02-17 16:33:20 +0000468 combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(),
469 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
470 framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })),
471 QuantizedActivationFunctionsDataset),
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000472 framework::dataset::make("DataLayout", { DataLayout::NCHW })))
Sheri Zhang681f2d42020-02-20 11:23:08 +0000473{
474 // Validate output
475 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
476}
477
478TEST_SUITE_END() // QASYMM8_SIGNED
Michalis Spyrou064add62018-11-01 18:14:27 +0000479TEST_SUITE_END() // Quantized
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000480TEST_SUITE_END() // NCHW
Michalis Spyrou064add62018-11-01 18:14:27 +0000481TEST_SUITE_END() // DirectConvolutionLayer
Gian Marco Iodice0841ca02021-02-01 14:37:02 +0000482TEST_SUITE_END() // CL
483
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100484} // namespace validation
485} // namespace test
Anthony Barbier1c0d0ff2018-01-31 13:05:09 +0000486} // namespace arm_compute