1 /*
2 * Copyright (c) 2017-2022 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/core/utils/misc/ShapeCalculator.h"
26 #include "arm_compute/runtime/CL/CLTensor.h"
27 #include "arm_compute/runtime/CL/CLTensorAllocator.h"
28 #include "arm_compute/runtime/CL/functions/CLDeconvolutionLayer.h"
29 #include "tests/CL/CLAccessor.h"
30 #include "tests/PaddingCalculator.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/DeconvolutionLayerFixture.h"
37
38 namespace arm_compute
39 {
40 namespace test
41 {
42 namespace validation
43 {
44 namespace
45 {
46 constexpr AbsoluteTolerance<float> tolerance_fp32(0.001f); /**< Tolerance for floating point tests */
47 RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.2)); /**< Tolerance value for comparing reference's for DataType::F16 */
48 constexpr AbsoluteTolerance<float> tolerance_qasymm8(1.0); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */
49 constexpr float tolerance_num = 0.07f; /**< Tolerance number */
50
51 const auto data9x9_small_asymm = framework::dataset::make("InputShape", TensorShape{ 10U, 10U, 1U, 1U }) *framework::dataset::make("StrideX", 2) *framework::dataset::make("StrideY",
52 2)
53 *framework::dataset::make("PadLeft", 3)
54 *framework::dataset::make("PadRight", 4) *framework::dataset::make("PadTop", 3) *framework::dataset::make("PadBottom", 4) *framework::dataset::make("NumKernels", { 1 });
55
56 const auto data9x9_large_asymm = framework::dataset::make("InputShape", TensorShape{ 640U, 360U, 56U, 1U }) *framework::dataset::make("StrideX", 2) *framework::dataset::make("StrideY",
57 2)
58 *framework::dataset::make("PadLeft", 3)
59 *framework::dataset::make("PadRight", 4) *framework::dataset::make("PadTop", 3) *framework::dataset::make("PadBottom", 4) *framework::dataset::make("NumKernels", { 1 });
60
61 const auto data4x4 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 3)
62 * framework::dataset::make("PadY", 0, 3) * framework::dataset::make("NumKernels", { 3 });
63
64 const auto data3x3 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 2)
65 * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("NumKernels", { 3 });
66
67 const auto data3x3_asymm = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 2) * framework::dataset::make("StrideY", 1, 2) * framework::dataset::make("PadLeft", 0, 1)
68 * framework::dataset::make("PadRight", 0, 1) * framework::dataset::make("PadTop", 0, 1) * framework::dataset::make("PadBottom", 0, 1) * framework::dataset::make("NumKernels", { 3 });
69
70 const auto data3x3_precommit = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 2) * framework::dataset::make("StrideY", 1, 2) * framework::dataset::make("PadX", 0, 2)
71 * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("NumKernels", { 3 });
72
73 const auto data3x3_precommit_large_channels = datasets::SmallDeconvolutionShapesWithLargerChannels() * framework::dataset::make("StrideX", 2) * framework::dataset::make("StrideY",
74 2)
75 * framework::dataset::make("PadX", 1)
76 * framework::dataset::make("PadY", 2) * framework::dataset::make("NumKernels", { 5 });
77
78 const auto data2x2_precommit = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 2) * framework::dataset::make("StrideY", 2) * framework::dataset::make("PadX", 1)
79 * framework::dataset::make("PadY", 1) * framework::dataset::make("NumKernels", { 3 });
80
81 const auto data1x1 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 1)
82 * framework::dataset::make("PadY", 0, 1) * framework::dataset::make("NumKernels", { 3 });
83
84 const auto data_layouts_dataset = framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC });
85
86 const auto add_bias_dataset = framework::dataset::make("AddBias", { true, false });
87 } // namespace
88
89 TEST_SUITE(CL)
TEST_SUITE(DeconvolutionLayer)90 TEST_SUITE(DeconvolutionLayer)
91
92 // *INDENT-OFF*
93 // clang-format off
94 DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
95 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type
96 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid weights shape
97 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), // Non supported data type
98 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid bias shape
99 TensorInfo(TensorShape(13U, 11U, 4U, 3U), 1, DataType::F32), // Window shrink
100 TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32),
101 TensorInfo(TensorShape(2U, 13U, 27U), 1, DataType::F32, DataLayout::NHWC), // Mismatching data type
102 TensorInfo(TensorShape(2U, 13U, 27U), 1, DataType::F32, DataLayout::NHWC), // Invalid weights shape
103 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16, DataLayout::NHWC), // Non supported data type
104 TensorInfo(TensorShape(2U, 13U, 27U), 1, DataType::F32, DataLayout::NHWC), // Invalid bias shape
105 TensorInfo(TensorShape(4U, 11U, 13U, 3U), 1, DataType::F32, DataLayout::NHWC), // Window shrink
106 TensorInfo(TensorShape(2U, 16U, 32U), 1, DataType::F32, DataLayout::NHWC),
107 }),
108 framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16),
109 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
110 TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16),
111 TensorInfo(TensorShape(3U, 2U, 2U, 2U), 1, DataType::F32),
112 TensorInfo(TensorShape(3U, 3U, 4U), 1, DataType::F32),
113 TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32),
114 TensorInfo(TensorShape(2U, 3U, 3U, 2U), 1, DataType::F16, DataLayout::NHWC),
115 TensorInfo(TensorShape(2U, 3U, 3U, 4U), 1, DataType::F32, DataLayout::NHWC),
116 TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16, DataLayout::NHWC),
117 TensorInfo(TensorShape(2U, 2U, 3U, 2U), 1, DataType::F32, DataLayout::NHWC),
118 TensorInfo(TensorShape(4U, 3U, 3U), 1, DataType::F32, DataLayout::NHWC),
119 TensorInfo(TensorShape(2U, 2U, 2U, 4U), 1, DataType::F32, DataLayout::NHWC),
120 })),
121 framework::dataset::make("BiasInfo", { TensorInfo(TensorShape(1U), 1, DataType::F16),
122 TensorInfo(TensorShape(1U), 1, DataType::F32),
123 TensorInfo(TensorShape(1U), 1, DataType::F32),
124 TensorInfo(TensorShape(25U, 11U), 1, DataType::F32),
125 TensorInfo(TensorShape(1U), 1, DataType::F32),
126 TensorInfo(TensorShape(4U), 1, DataType::F32),
127 TensorInfo(TensorShape(1U), 1, DataType::F16, DataLayout::NHWC),
128 TensorInfo(TensorShape(1U), 1, DataType::F32, DataLayout::NHWC),
129 TensorInfo(TensorShape(1U), 1, DataType::F32, DataLayout::NHWC),
130 TensorInfo(TensorShape(25U, 11U), 1, DataType::F32, DataLayout::NHWC),
131 TensorInfo(TensorShape(1U), 1, DataType::F32, DataLayout::NHWC),
132 TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NHWC),
133 })),
134 framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F16),
135 TensorInfo(TensorShape(25U, 10U, 2U), 1, DataType::F32),
136 TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
137 TensorInfo(TensorShape(13U, 13U, 2U), 1, DataType::F32),
138 TensorInfo(TensorShape(11U, 9U, 1U, 3U), 1, DataType::F32),
139 TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32),
140 TensorInfo(TensorShape(2U, 11U, 25U), 1, DataType::F16, DataLayout::NHWC),
141 TensorInfo(TensorShape(2U, 10U, 25U), 1, DataType::F32, DataLayout::NHWC),
142 TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32, DataLayout::NHWC),
143 TensorInfo(TensorShape(2U, 13U, 13U), 1, DataType::F32, DataLayout::NHWC),
144 TensorInfo(TensorShape(1U, 9U, 11U, 3U), 1, DataType::F32, DataLayout::NHWC),
145 TensorInfo(TensorShape(4U, 43U, 91U), 1, DataType::F32, DataLayout::NHWC),
146 })),
147 framework::dataset::make("PadStrideInfo", { PadStrideInfo(1, 1, 0, 0),
148 PadStrideInfo(1, 1, 0, 0),
149 PadStrideInfo(1, 1, 0, 0),
150 PadStrideInfo(1, 1, 0, 0),
151 PadStrideInfo(1, 1, 1, 1),
152 PadStrideInfo(1, 1, 0, 0),
153 PadStrideInfo(1, 1, 0, 0),
154 PadStrideInfo(1, 1, 0, 0),
155 PadStrideInfo(1, 1, 0, 0),
156 PadStrideInfo(1, 1, 0, 0),
157 PadStrideInfo(1, 1, 1, 1),
158 PadStrideInfo(3, 3, 2, 2),
159 })),
160 framework::dataset::make("Expected", { false, false, false, false, false, true, // NCHW
161 false, false, false, false, false, true })), // NHWC
162 input_info, weights_info, bias_info, output_info, pad_info, expected)
163 {
164 bool is_valid = bool(CLDeconvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), pad_info));
165 ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
166 }
167 // clang-format on
168 // *INDENT-ON*
169
170 template <typename T>
171 using CLDeconvolutionLayerFixture4x4 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 4, 4>;
172
173 template <typename T>
174 using CLDeconvolutionLayerFixture3x3 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
175
176 template <typename T>
177 using CLDeconvolutionLayerAsymmFixture3x3 = DeconvolutionValidationAsymmFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
178
179 template <typename T>
180 using CLDeconvolutionLayerFixture2x2 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 2, 2>;
181
182 template <typename T>
183 using CLDeconvolutionLayerFixture1x1 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 1, 1>;
184
185 template <typename T>
186 using CLDeconvolutionLayerAsymmFixture9x9 = DeconvolutionValidationAsymmFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 9, 9>;
187
188 TEST_SUITE(Float)
TEST_SUITE(FP32)189 TEST_SUITE(FP32)
190
191 TEST_SUITE(W4x4)
192 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture4x4<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data4x4, framework::dataset::make("DataType", DataType::F32)),
193 data_layouts_dataset),
194 add_bias_dataset))
195 {
196 // Validate output
197 validate(CLAccessor(_target), _reference, tolerance_fp32);
198 }
199 TEST_SUITE_END() // W4x4
200
TEST_SUITE(W3x3)201 TEST_SUITE(W3x3)
202 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data3x3_precommit, framework::dataset::make("DataType",
203 DataType::F32)),
204 data_layouts_dataset),
205 add_bias_dataset))
206 {
207 // Validate output
208 validate(CLAccessor(_target), _reference, tolerance_fp32);
209 }
210
211 FIXTURE_DATA_TEST_CASE(RunSmallWithLargeChannels, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data3x3_precommit_large_channels,
212 framework::dataset::make("DataType",
213 DataType::F32)),
214 data_layouts_dataset),
215 framework::dataset::make("AddBias", { true })))
216 {
217 // Validate output
218 validate(CLAccessor(_target), _reference, tolerance_fp32);
219 }
220
221 FIXTURE_DATA_TEST_CASE(RunAsymm, CLDeconvolutionLayerAsymmFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data3x3_asymm, framework::dataset::make("DataType",
222 DataType::F32)),
223 data_layouts_dataset),
224 add_bias_dataset))
225 {
226 // Validate output
227 validate(CLAccessor(_target), _reference, tolerance_fp32);
228 }
229 FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data3x3, framework::dataset::make("DataType", DataType::F32)),
230 data_layouts_dataset),
231 add_bias_dataset))
232 {
233 // Validate output
234 validate(CLAccessor(_target), _reference, tolerance_fp32);
235 }
236 TEST_SUITE_END() // W3x3
237
TEST_SUITE(W2x2)238 TEST_SUITE(W2x2)
239 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture2x2<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data2x2_precommit, framework::dataset::make("DataType",
240 DataType::F32)),
241 data_layouts_dataset),
242 add_bias_dataset))
243 {
244 // Validate output
245 validate(CLAccessor(_target), _reference, tolerance_fp32);
246 }
247 TEST_SUITE_END() // W2x2
248
TEST_SUITE(W1x1)249 TEST_SUITE(W1x1)
250 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture1x1<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data1x1, framework::dataset::make("DataType", DataType::F32)),
251 data_layouts_dataset),
252 add_bias_dataset))
253 {
254 // Validate output
255 validate(CLAccessor(_target), _reference, tolerance_fp32);
256 }
257 TEST_SUITE_END() // W1x1
TEST_SUITE(W9x9)258 TEST_SUITE(W9x9)
259 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerAsymmFixture9x9<float>, framework::DatasetMode::ALL, combine(combine(combine(data9x9_small_asymm, framework::dataset::make("DataType",
260 DataType::F32)),
261 framework::dataset::make("DataLayout", { DataLayout::NHWC })),
262 framework::dataset::make("AddBias", { false })))
263 {
264 // Validate output
265 validate(CLAccessor(_target), _reference, tolerance_fp32);
266 }
267 TEST_SUITE_END() // W9x9
TEST_SUITE_END()268 TEST_SUITE_END() // FP32
269
270 TEST_SUITE(FP16)
271
272 TEST_SUITE(W4x4)
273 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture4x4<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data4x4, framework::dataset::make("DataType", DataType::F16)),
274 data_layouts_dataset),
275 add_bias_dataset))
276 {
277 // Validate output
278 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
279 }
280 TEST_SUITE_END() // W4x4
281
TEST_SUITE(W3x3)282 TEST_SUITE(W3x3)
283 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture3x3<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data3x3_precommit, framework::dataset::make("DataType",
284 DataType::F16)),
285 data_layouts_dataset),
286 add_bias_dataset))
287 {
288 // Validate output
289 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
290 }
291 FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data3x3, framework::dataset::make("DataType", DataType::F16)),
292 data_layouts_dataset),
293 add_bias_dataset))
294 {
295 // Validate output
296 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
297 }
298 TEST_SUITE_END() // W3x3
299
TEST_SUITE(W2x2)300 TEST_SUITE(W2x2)
301 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture2x2<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data2x2_precommit, framework::dataset::make("DataType",
302 DataType::F16)),
303 data_layouts_dataset),
304 add_bias_dataset))
305 {
306 // Validate output
307 validate(CLAccessor(_target), _reference, tolerance_f16);
308 }
309 TEST_SUITE_END() // W2x2
310
TEST_SUITE(W1x1)311 TEST_SUITE(W1x1)
312 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture1x1<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data1x1, framework::dataset::make("DataType", DataType::F16)),
313 data_layouts_dataset),
314 add_bias_dataset))
315 {
316 // Validate output
317 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
318 }
319 TEST_SUITE_END() // W1x1
320
321 TEST_SUITE_END() // FP16
322 TEST_SUITE_END() // Float
323
324 template <typename T>
325 using CLDeconvolutionLayerQuantizedFixture4x4 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 4, 4>;
326
327 template <typename T>
328 using CLDeconvolutionLayerQuantizedFixture3x3 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
329
330 template <typename T>
331 using CLDeconvolutionLayerQuantizedFixture2x2 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 2, 2>;
332
333 template <typename T>
334 using CLDeconvolutionLayerQuantizedFixture1x1 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 1, 1>;
335
336 template <typename T>
337 using CLDeconvolutionLayerQuantizedPerChannelFixture4x4 = DeconvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, int8_t, 4, 4>;
338
339 template <typename T>
340 using CLDeconvolutionLayerQuantizedPerChannelFixture3x3 = DeconvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, int8_t, 3, 3>;
341
342 template <typename T>
343 using CLDeconvolutionLayerQuantizedPerChannelFixture2x2 = DeconvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, int8_t, 2, 2>;
344
345 template <typename T>
346 using CLDeconvolutionLayerQuantizedPerChannelFixture1x1 = DeconvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, int8_t, 1, 1>;
347
348 TEST_SUITE(Quantized)
TEST_SUITE(QASYMM8)349 TEST_SUITE(QASYMM8)
350
351 TEST_SUITE(W4x4)
352 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture4x4<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(data4x4, framework::dataset::make("DataType",
353 DataType::QASYMM8)),
354 data_layouts_dataset),
355 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 10), QuantizationInfo(2.f / 255.f, 5) })),
356 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 5), QuantizationInfo(4.f / 255.f, 10) })),
357 add_bias_dataset))
358 {
359 // Validate output
360 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
361 }
362 TEST_SUITE_END() // W4x4
363
TEST_SUITE(W3x3)364 TEST_SUITE(W3x3)
365 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(data3x3_precommit,
366 framework::dataset::make("DataType",
367 DataType::QASYMM8)),
368 data_layouts_dataset),
369 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 10), QuantizationInfo(2.f / 255.f, 4) })),
370 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 10), QuantizationInfo(4.f / 255.f, 5) })),
371 add_bias_dataset))
372 {
373 // Validate output
374 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
375 }
376 FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(data3x3,
377 framework::dataset::make("DataType",
378 DataType::QASYMM8)),
379 data_layouts_dataset),
380 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 10), QuantizationInfo(2.f / 255.f, 128) })),
381 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 128), QuantizationInfo(4.f / 255.f, 128) })),
382 add_bias_dataset))
383 {
384 // Validate output
385 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
386 }
387 TEST_SUITE_END() // W3x3
388
TEST_SUITE(W2x2)389 TEST_SUITE(W2x2)
390 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedFixture2x2<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(data2x2_precommit,
391 framework::dataset::make("DataType", DataType::QASYMM8)),
392 data_layouts_dataset),
393 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 128), QuantizationInfo(2.f / 255.f, 128) })),
394 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 64), QuantizationInfo(4.f / 255.f, 128) })),
395 add_bias_dataset))
396 {
397 // Validate output
398 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
399 }
400 TEST_SUITE_END() // W2x2
401
TEST_SUITE(W1x1)402 TEST_SUITE(W1x1)
403 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture1x1<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(data1x1, framework::dataset::make("DataType",
404 DataType::QASYMM8)),
405 data_layouts_dataset),
406 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 0), QuantizationInfo(2.f / 255.f, 0) })),
407 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 0), QuantizationInfo(4.f / 255.f, 0) })),
408 add_bias_dataset))
409 {
410 // Validate output
411 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
412 }
413 TEST_SUITE_END() // W1x1
414
TEST_SUITE_END()415 TEST_SUITE_END() // QASYMM8
416
417 TEST_SUITE(QASYMM8_SIGNED)
418
419 // QASYMM8_SIGNED: zero-point in range [-128, 127]
420 // QASYMM8 : zero-point in range [0 , 255]
421
422 TEST_SUITE(W4x4)
423 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture4x4<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(data4x4, framework::dataset::make("DataType",
424 DataType::QASYMM8_SIGNED)),
425 data_layouts_dataset),
426 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 10), QuantizationInfo(2.f / 255.f, 5) })),
427 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 5), QuantizationInfo(4.f / 255.f, 10) })),
428 add_bias_dataset))
429 {
430 // Validate output
431 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
432 }
433 TEST_SUITE_END() // W4x4
434
TEST_SUITE(W3x3)435 TEST_SUITE(W3x3)
436 // DirectDeconvolution
437 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedFixture3x3<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(data3x3_precommit,
438 framework::dataset::make("DataType",
439 DataType::QASYMM8_SIGNED)),
440 data_layouts_dataset),
441 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 10), QuantizationInfo(2.f / 255.f, 4) })),
442 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 10), QuantizationInfo(4.f / 255.f, 5) })),
443 add_bias_dataset))
444 {
445 // Validate output
446 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
447 }
448
449 FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerQuantizedFixture3x3<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(data3x3,
450 framework::dataset::make("DataType",
451 DataType::QASYMM8_SIGNED)),
452 data_layouts_dataset),
453 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, -10), QuantizationInfo(2.f / 255.f, 127) })),
454 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 64), QuantizationInfo(4.f / 255.f, -128) })),
455 add_bias_dataset))
456 {
457 // Validate output
458 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
459 }
460 TEST_SUITE_END() // W3x3
461
TEST_SUITE(W2x2)462 TEST_SUITE(W2x2) // GEMMDeconvolution
463 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedFixture2x2<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(data2x2_precommit,
464 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
465 data_layouts_dataset),
466 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 127), QuantizationInfo(2.f / 255.f, -128) })),
467 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, -10), QuantizationInfo(4.f / 255.f, 64) })),
468 add_bias_dataset))
469 {
470 // Validate output
471 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
472 }
473 TEST_SUITE_END() // W2x2
474
TEST_SUITE(W1x1)475 TEST_SUITE(W1x1) // DirectDeconvolution and GEMMDeconvolution
476 FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture1x1<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(data1x1,
477 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
478 data_layouts_dataset),
479 framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 0), QuantizationInfo(2.f / 255.f, 0) })),
480 framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 0), QuantizationInfo(4.f / 255.f, 0) })),
481 add_bias_dataset))
482 {
483 // Validate output
484 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
485 }
486 TEST_SUITE_END() // W1x1
487
488 TEST_SUITE_END() // QASYMM8_SIGNED
489
490 const auto input_qinfo_dataset = framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, 10) });
491 const auto output_qinfo_dataset = framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 0) });
492 const auto input_signed_qinfo_dataset = framework::dataset::make("InputQuantizationInfo", { QuantizationInfo(1.f / 255.f, -10) });
493 const auto output_signed_qinfo_dataset = framework::dataset::make("OutputQuantizationInfo", { QuantizationInfo(3.f / 255.f, 10) });
494
495 TEST_SUITE(QSYMM8_PER_CHANNEL)
496
TEST_SUITE(W4x4)497 TEST_SUITE(W4x4)
498 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedPerChannelFixture4x4<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(data4x4,
499 framework::dataset::make("DataType", DataType::QASYMM8)),
500 data_layouts_dataset),
501 input_qinfo_dataset),
502 output_qinfo_dataset),
503 add_bias_dataset),
504 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
505 {
506 // Validate output
507 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
508 }
509 FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLDeconvolutionLayerQuantizedPerChannelFixture4x4<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(data4x4,
510 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
511 data_layouts_dataset),
512 input_signed_qinfo_dataset),
513 output_signed_qinfo_dataset),
514 add_bias_dataset),
515 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
516 {
517 // Validate output
518 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
519 }
520 TEST_SUITE_END() // W4x4
521
TEST_SUITE(W3x3)522 TEST_SUITE(W3x3)
523 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedPerChannelFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(data3x3,
524 framework::dataset::make("DataType", DataType::QASYMM8)),
525 data_layouts_dataset),
526 input_qinfo_dataset),
527 output_qinfo_dataset),
528 add_bias_dataset),
529 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
530 {
531 // Validate output
532 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
533 }
534 FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLDeconvolutionLayerQuantizedPerChannelFixture3x3<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(data3x3,
535 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
536 data_layouts_dataset),
537 input_signed_qinfo_dataset),
538 output_signed_qinfo_dataset),
539 add_bias_dataset),
540 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
541 {
542 // Validate output
543 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
544 }
545
546 FIXTURE_DATA_TEST_CASE(RunSmallSignedPrecommit, CLDeconvolutionLayerQuantizedPerChannelFixture2x2<int8_t>, framework::DatasetMode::PRECOMMIT,
547 combine(combine(combine(combine(combine(combine(data3x3_precommit,
548 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
549 data_layouts_dataset),
550 input_signed_qinfo_dataset),
551 output_signed_qinfo_dataset),
552 add_bias_dataset),
553 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
554 {
555 // Validate output
556 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
557 }
558 TEST_SUITE_END() // W3x3
559
560 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedPerChannelFixture2x2<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(data3x3_precommit,
561 framework::dataset::make("DataType", DataType::QASYMM8)),
562 data_layouts_dataset),
563 input_qinfo_dataset),
564 output_qinfo_dataset),
565 add_bias_dataset),
566 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
567 {
568 // Validate output
569 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
570 }
571
572 TEST_SUITE(W2x2)
573 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedPerChannelFixture2x2<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(data2x2_precommit,
574 framework::dataset::make("DataType", DataType::QASYMM8)),
575 data_layouts_dataset),
576 input_qinfo_dataset),
577 output_qinfo_dataset),
578 add_bias_dataset),
579 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
580 {
581 // Validate output
582 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
583 }
584 FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLDeconvolutionLayerQuantizedPerChannelFixture2x2<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(data2x2_precommit,
585 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
586 data_layouts_dataset),
587 input_signed_qinfo_dataset),
588 output_signed_qinfo_dataset),
589 add_bias_dataset),
590 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
591 {
592 // Validate output
593 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
594 }
595 TEST_SUITE_END() // W2x2
596
TEST_SUITE(W1x1)597 TEST_SUITE(W1x1)
598 FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedPerChannelFixture1x1<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(data1x1,
599 framework::dataset::make("DataType", DataType::QASYMM8)),
600 data_layouts_dataset),
601 input_qinfo_dataset),
602 output_qinfo_dataset),
603 add_bias_dataset),
604 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
605 {
606 // Validate output
607 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
608 }
609 FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLDeconvolutionLayerQuantizedPerChannelFixture1x1<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(data1x1,
610 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
611 data_layouts_dataset),
612 input_signed_qinfo_dataset),
613 output_signed_qinfo_dataset),
614 add_bias_dataset),
615 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
616 {
617 // Validate output
618 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
619 }
620 TEST_SUITE_END() // W1x1
621
622 TEST_SUITE_END() // QSYMM8_PER_CHANNEL
623
624 TEST_SUITE_END() // Quantized
625
626 TEST_SUITE_END() // DeconvolutionLayer
627 TEST_SUITE_END() // CL
628 } // namespace validation
629 } // namespace test
630 } // namespace arm_compute
631