Compute Library
 22.11
DepthwiseConvolutionLayer.cpp
Go to the documentation of this file.
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"
28 #include "tests/CL/CLAccessor.h"
30 #include "tests/datasets/DepthwiseConvolutionLayerDataset.h"
31 #include "tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h"
33 #include "tests/framework/Macros.h"
36 #include "tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h"
37 
38 namespace arm_compute
39 {
40 namespace test
41 {
42 namespace validation
43 {
44 namespace
45 {
46 RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.01)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */
47 constexpr RelativeTolerance<float> tolerance_f32(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
48 constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(0); /**< Tolerance value for comparing reference's output against implementation's output for DataType::QASYMM8 */
49 constexpr float tolerance_num = 0.05f; /**< Tolerance number */
50 
51 const auto depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 4 });
52 const auto large_depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 2, 5, 8 });
53 
54 //Activation Functions
55 const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
56 {
57  ActivationLayerInfo(),
58  ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.f, 0.f)
59 });
60 } // namespace
61 
62 TEST_SUITE(CL)
63 TEST_SUITE(DepthwiseConvolutionLayer)
64 
65 // *INDENT-OFF*
66 // clang-format off
67 DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
68  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/weights
69  TensorInfo(TensorShape(27U, 13U, 3U), 1, DataType::F32), // Mismatching input feature maps
70  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching depth multiplier
71  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases size
72  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases dimensions
73  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid output size
74  TensorInfo(TensorShape(27U, 13U, 8U), 1, DataType::F32), // patch size bigger than input width
75  TensorInfo(TensorShape(27U, 13U, 8U), 1, DataType::F32), // dilation < 1
76  TensorInfo(TensorShape(27U, 13U, 8U), 1, DataType::F32),
78  }),
79  framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U), 1, DataType::F16),
89  })),
100  })),
101  framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
102  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
103  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
104  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
105  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
106  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
107  TensorInfo(TensorShape(25U, 11U, 16U), 1, DataType::F32),
108  TensorInfo(TensorShape(25U, 11U, 16U), 1, DataType::F32),
109  TensorInfo(TensorShape(25U, 11U, 16U), 1, DataType::F32),
111  })),
112  framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0),
113  PadStrideInfo(1, 1, 0, 0),
114  PadStrideInfo(1, 1, 0, 0),
115  PadStrideInfo(1, 1, 0, 0),
116  PadStrideInfo(1, 1, 0, 0),
117  PadStrideInfo(1, 1, 0, 0),
118  PadStrideInfo(1, 1, 0, 0),
119  PadStrideInfo(1, 1, 0, 0),
120  PadStrideInfo(1, 1, 0, 0),
121  PadStrideInfo(1, 1, 1, 0),
122  })),
123  framework::dataset::make("DepthMultiplier", { 1,
124  1,
125  3,
126  1,
127  1,
128  1,
129  2,
130  2,
131  2,
132  3,
133  })),
134  framework::dataset::make("Dilation", { Size2D(1U, 1U),
135  Size2D(1U, 1U),
136  Size2D(1U, 1U),
137  Size2D(1U, 1U),
138  Size2D(1U, 1U),
139  Size2D(1U, 1U),
140  Size2D(20U, 1U),
141  Size2D(0U, 1U),
142  Size2D(1U, 1U),
143  Size2D(1U, 1U),
144  })),
145  framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, true, true })),
146  input_info, weights_info, biases_info, output_info, conv_info, depth_multiplier, dilation, expected)
147 {
148  bool is_valid = bool(CLDepthwiseConvolutionLayer::validate(&input_info.clone()->set_is_resizable(true), &weights_info.clone()->set_is_resizable(true), &biases_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), conv_info, depth_multiplier,ActivationLayerInfo(), dilation));
150 }
151 // clang-format on
152 // *INDENT-ON*
153 
154 template <typename T>
155 using CLDepthwiseConvolutionLayerFixture = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
156 template <typename T>
157 using CLDepthwiseConvolutionLayerMixedDataLayoutFixture = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, true>;
158 template <typename T>
159 using CLDepthwiseConvolutionLayerInPlaceFixture = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, false, true>;
160 
161 TEST_SUITE(Float)
162 TEST_SUITE(FP16)
163 TEST_SUITE(W3x3)
164 TEST_SUITE(NCHW)
166  combine(combine(combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
167  datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()),
168  depth_multipliers),
169  framework::dataset::make("DataType",
170  DataType::F16)),
171  framework::dataset::make("DataLayout", DataLayout::NCHW)),
172  ActivationFunctionsDataset))
173 {
174  validate(CLAccessor(_target), _reference, tolerance_f16);
175 }
177  large_depth_multipliers),
178  framework::dataset::make("DataType",
179  DataType::F16)),
181  ActivationFunctionsDataset))
182 {
183  validate(CLAccessor(_target), _reference, tolerance_f16);
184 }
185 TEST_SUITE(Dilation)
186 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
187  depth_multipliers),
188  framework::dataset::make("DataType",
189  DataType::F16)),
190  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
191  ActivationFunctionsDataset))
192 {
193  validate(CLAccessor(_target), _reference, tolerance_f16);
194 }
196  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
197  large_depth_multipliers),
198  framework::dataset::make("DataType",
199  DataType::F16)),
200  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
201  ActivationFunctionsDataset))
202 {
203  validate(CLAccessor(_target), _reference, tolerance_f16);
204 }
205 TEST_SUITE_END() // Dilation
206 TEST_SUITE_END() // NCHW
207 
210  combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
211  depth_multipliers),
212  framework::dataset::make("DataType",
213  DataType::F16)),
214  framework::dataset::make("DataLayout", DataLayout::NHWC)),
215  ActivationFunctionsDataset))
216 {
217  validate(CLAccessor(_target), _reference, tolerance_f16);
218 }
220  large_depth_multipliers),
221  framework::dataset::make("DataType",
222  DataType::F16)),
224  ActivationFunctionsDataset))
225 {
226  validate(CLAccessor(_target), _reference, tolerance_f16);
227 }
228 TEST_SUITE(Dilation)
229 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
230  depth_multipliers),
231  framework::dataset::make("DataType",
232  DataType::F16)),
233  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
234  ActivationFunctionsDataset))
235 {
236  validate(CLAccessor(_target), _reference, tolerance_f16);
237 }
239  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
240  large_depth_multipliers),
241  framework::dataset::make("DataType",
242  DataType::F16)),
243  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
244  ActivationFunctionsDataset))
245 {
246  validate(CLAccessor(_target), _reference, tolerance_f16);
247 }
248 TEST_SUITE_END() // Dilation
249 TEST_SUITE_END() // NHWC
250 TEST_SUITE_END() // W3x3
251 
252 TEST_SUITE(Generic)
253 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
254  depth_multipliers),
255  framework::dataset::make("DataType",
256  DataType::F16)),
257  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
258  ActivationFunctionsDataset))
259 {
260  validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
261 }
263  large_depth_multipliers),
264  framework::dataset::make("DataType",
265  DataType::F16)),
267  ActivationFunctionsDataset))
268 {
269  validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
270 }
271 
272 TEST_SUITE(Dilation)
273 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
274  depth_multipliers),
275  framework::dataset::make("DataType",
276  DataType::F16)),
277  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
278  ActivationFunctionsDataset))
279 {
280  validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
281 }
283  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
284  large_depth_multipliers),
285  framework::dataset::make("DataType",
286  DataType::F16)),
288  ActivationFunctionsDataset))
289 {
290  validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
291 }
292 TEST_SUITE_END() // Dilation
293 TEST_SUITE_END() // Generic
294 
295 TEST_SUITE(InPlace)
297  combine(combine(combine(combine(datasets::SmallInPlaceDepthwiseConvolutionLayerDataset(),
298  framework::dataset::make("DepthMultiplier", { 1 })),
299  framework::dataset::make("DataType",
300  DataType::F16)),
301  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
302  ActivationFunctionsDataset))
303 {
304  validate(CLAccessor(_src), _reference, tolerance_f16, tolerance_num);
305 }
306 TEST_SUITE_END() // InPlace
307 TEST_SUITE_END() // FP16
308 
309 TEST_SUITE(FP32)
310 TEST_SUITE(W3x3)
313  combine(combine(combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
314  datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()),
315  depth_multipliers),
316  framework::dataset::make("DataType",
317  DataType::F32)),
318  framework::dataset::make("DataLayout", DataLayout::NCHW)),
319  ActivationFunctionsDataset))
320 {
321  validate(CLAccessor(_target), _reference, tolerance_f32);
322 }
324  large_depth_multipliers),
325  framework::dataset::make("DataType",
326  DataType::F32)),
328  ActivationFunctionsDataset))
329 {
330  validate(CLAccessor(_target), _reference, tolerance_f32);
331 }
332 TEST_SUITE(Dilation)
334  combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(), depth_multipliers),
335  framework::dataset::make("DataType",
336  DataType::F32)),
337  framework::dataset::make("DataLayout", DataLayout::NCHW)),
338  ActivationFunctionsDataset))
339 {
340  validate(CLAccessor(_target), _reference, tolerance_f32);
341 }
343  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
344  large_depth_multipliers),
345  framework::dataset::make("DataType",
346  DataType::F32)),
348  ActivationFunctionsDataset))
349 {
350  validate(CLAccessor(_target), _reference, tolerance_f32);
351 }
352 
353 TEST_SUITE_END() // Dilation
354 TEST_SUITE_END() // NCHW
357  combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
358  depth_multipliers),
359  framework::dataset::make("DataType",
360  DataType::F32)),
362  ActivationFunctionsDataset))
363 {
364  validate(CLAccessor(_target), _reference, tolerance_f32);
365 }
367  combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
368  framework::dataset::make("DepthMultiplier", { 2 })),
369  framework::dataset::make("DataType",
370  DataType::F32)),
372  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
373 {
374  validate(CLAccessor(_target), _reference, tolerance_f32);
375 }
377  large_depth_multipliers),
378  framework::dataset::make("DataType",
379  DataType::F32)),
381  ActivationFunctionsDataset))
382 {
383  validate(CLAccessor(_target), _reference, tolerance_f32);
384 }
385 
386 TEST_SUITE(Dilation)
387 
389  combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
390  depth_multipliers),
391  framework::dataset::make("DataType",
392  DataType::F32)),
393  framework::dataset::make("DataLayout", DataLayout::NHWC)),
394  ActivationFunctionsDataset))
395 {
396  validate(CLAccessor(_target), _reference, tolerance_f32);
397 }
399  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
400  large_depth_multipliers),
401  framework::dataset::make("DataType",
402  DataType::F32)),
404  ActivationFunctionsDataset))
405 {
406  validate(CLAccessor(_target), _reference, tolerance_f32);
407 }
408 TEST_SUITE_END() // Dilation
409 TEST_SUITE_END() // NHWC
410 TEST_SUITE_END() // W3x3
411 
412 TEST_SUITE(Generic)
413 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
414  depth_multipliers),
415  framework::dataset::make("DataType",
416  DataType::F32)),
417  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
418  ActivationFunctionsDataset))
419 {
420  validate(CLAccessor(_target), _reference, tolerance_f32);
421 }
422 
424  large_depth_multipliers),
425  framework::dataset::make("DataType",
426  DataType::F32)),
428  ActivationFunctionsDataset))
429 {
430  validate(CLAccessor(_target), _reference, tolerance_f32);
431 }
432 
434  combine(combine(combine(combine(datasets::LargeKernelSizeDepthwiseConvolutionLayerNHWCDataset(),
435  framework::dataset::make("DepthMultiplier", { 1 })),
436  framework::dataset::make("DataType",
437  DataType::F32)),
438  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
439  ActivationFunctionsDataset))
440 {
441  validate(CLAccessor(_target), _reference, tolerance_f32);
442 }
443 
444 TEST_SUITE(Dilation)
445 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
446  depth_multipliers),
447  framework::dataset::make("DataType",
448  DataType::F32)),
449  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
450  ActivationFunctionsDataset))
451 {
452  validate(CLAccessor(_target), _reference, tolerance_f32);
453 }
455  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
456  large_depth_multipliers),
457  framework::dataset::make("DataType",
458  DataType::F32)),
460  ActivationFunctionsDataset))
461 {
462  validate(CLAccessor(_target), _reference, tolerance_f32);
463 }
464 TEST_SUITE_END() // Dilation
465 TEST_SUITE_END() // Generic
466 
467 TEST_SUITE(InPlace)
469  combine(combine(combine(combine(datasets::SmallInPlaceDepthwiseConvolutionLayerDataset(),
470  framework::dataset::make("DepthMultiplier", { 1 })),
471  framework::dataset::make("DataType",
472  DataType::F32)),
473  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
474  ActivationFunctionsDataset))
475 {
476  validate(CLAccessor(_src), _reference, tolerance_f32);
477 }
478 TEST_SUITE_END() // InPlace
479 TEST_SUITE_END() // FP32
480 TEST_SUITE_END() // Float
481 
482 template <typename T>
483 using CLDepthwiseConvolutionLayerQuantizedFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
484 template <typename T>
485 using CLDepthwiseConvolutionLayerQuantizedMixedDataLayoutFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, true>;
486 template <typename T>
487 using CLDepthwiseConvolutionLayerQuantizedPerChannelFixture = DepthwiseConvolutionLayerValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, int8_t>;
488 
489 TEST_SUITE(Quantized)
490 TEST_SUITE(QASYMM8)
491 TEST_SUITE(Generic)
492 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
493  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
494  depth_multipliers),
495  framework::dataset::make("DataType", DataType::QASYMM8)),
496  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 128), QuantizationInfo(2.2f, 10) })),
497  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(1.f, 128) })),
498  framework::dataset::make("DataLayout", { DataLayout::NHWC })), // NCHW is tested with int8
499  ActivationFunctionsDataset))
500 {
501  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
502 }
504  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
505  large_depth_multipliers),
507  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
508  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.7f, 2) })),
510  ActivationFunctionsDataset))
511 {
512  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
513 }
514 TEST_SUITE(Dilation)
515 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
516  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
517  depth_multipliers),
518  framework::dataset::make("DataType", DataType::QASYMM8)),
519  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
520  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.8, 1) })),
521  framework::dataset::make("DataLayout", { DataLayout::NHWC })), // NCHW is tested with int8
522  ActivationFunctionsDataset))
523 {
524  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
525 }
527  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
528  large_depth_multipliers),
530  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(1.3f, 10) })),
531  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.9f, 11) })),
533  ActivationFunctionsDataset))
534 {
535  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
536 }
537 TEST_SUITE_END() // Dilation
538 TEST_SUITE_END() // Generic
539 TEST_SUITE(W3x3)
540 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
541  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
542  depth_multipliers),
543  framework::dataset::make("DataType", DataType::QASYMM8)),
544  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.3f, 10), QuantizationInfo(2.2f, 10) })),
545  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
547  ActivationFunctionsDataset))
548 {
549  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
550 }
552  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
553  large_depth_multipliers),
555  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
556  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
558  ActivationFunctionsDataset))
559 {
560  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
561 }
562 TEST_SUITE(Dilation)
563 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
564  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
565  depth_multipliers),
566  framework::dataset::make("DataType", DataType::QASYMM8)),
567  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
568  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
570  ActivationFunctionsDataset))
571 {
572  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
573 }
575  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
576  framework::dataset::make("DepthMultiplier", { 2 })),
578  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
579  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
581  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
582 {
583  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
584 }
586  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
587  large_depth_multipliers),
589  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
590  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
592  ActivationFunctionsDataset))
593 {
594  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
595 }
596 TEST_SUITE_END() // Dilation
597 TEST_SUITE_END() // W3x3
598 TEST_SUITE_END() // QASYMM8
599 
601 TEST_SUITE(Generic)
602 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
603  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
604  depth_multipliers),
605  framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
606  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.3f, 10), QuantizationInfo(2.2f, 10) })),
607  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
608  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
609  ActivationFunctionsDataset))
610 {
611  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
612 }
614  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
615  framework::dataset::make("DepthMultiplier", { 2 })),
617  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.3f, 10), QuantizationInfo(2.2f, 10) })),
618  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
619  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
620  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
621 {
622  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
623 }
624 TEST_SUITE(Dilation)
625 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
626  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
627  depth_multipliers),
628  framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
629  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10), QuantizationInfo(2.2f, 10) })),
630  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.8, 1) })),
631  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
632  ActivationFunctionsDataset))
633 {
634  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
635 }
636 TEST_SUITE_END() // Dilation
637 TEST_SUITE_END() // Generic
638 TEST_SUITE_END() // QASYMM8_SIGNED
639 
641 TEST_SUITE(Generic)
643  combine(combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
644  depth_multipliers),
645  framework::dataset::make("SrcDataType", DataType::QASYMM8)),
646  framework::dataset::make("WeightsDataType", DataType::QSYMM8_PER_CHANNEL)),
647  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.3f, 10) })),
648  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
650  ActivationFunctionsDataset))
651 {
652  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
653 }
655  combine(combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
656  large_depth_multipliers),
659  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
660  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.7f, 2) })),
662  ActivationFunctionsDataset))
663 {
664  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
665 }
666 TEST_SUITE(Dilation)
668  combine(combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
669  depth_multipliers),
670  framework::dataset::make("SrcDataType", DataType::QASYMM8)),
671  framework::dataset::make("WeightsDataType", DataType::QSYMM8_PER_CHANNEL)),
672  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
673  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.8, 1) })),
675  ActivationFunctionsDataset))
676 {
677  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
678 }
680  combine(combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
681  large_depth_multipliers),
684  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
685  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.9f, 11) })),
687  ActivationFunctionsDataset))
688 {
689  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
690 }
691 TEST_SUITE_END() // Dilation
692 TEST_SUITE_END() // Generic
693 TEST_SUITE(W3x3)
695  combine(combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
696  depth_multipliers),
699  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.3f, 10) })),
700  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
702  ActivationFunctionsDataset))
703 {
704  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
705 }
707  combine(combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
708  large_depth_multipliers),
711  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
712  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
714  ActivationFunctionsDataset))
715 {
716  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
717 }
718 TEST_SUITE(Dilation)
720  combine(combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
721  depth_multipliers),
722  framework::dataset::make("SrcDataType", DataType::QASYMM8)),
723  framework::dataset::make("WeightsDataType", DataType::QSYMM8_PER_CHANNEL)),
724  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
725  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
727  ActivationFunctionsDataset))
728 {
729  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
730 }
732  combine(combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
733  large_depth_multipliers),
736  framework::dataset::make("SrcQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
737  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
739  ActivationFunctionsDataset))
740 {
741  validate(CLAccessor(_target), _reference, tolerance_qasymm8);
742 }
743 TEST_SUITE_END() // Dilation
744 TEST_SUITE_END() // W3x3
745 TEST_SUITE_END() // QSYMM8_PER_CHANNEL
746 TEST_SUITE_END() // Quantized
747 
748 TEST_SUITE_END() // DepthwiseConvolutionLayer
749 TEST_SUITE_END() // CL
750 } // namespace validation
751 } // namespace test
752 } // namespace arm_compute
DepthwiseConvolutionLayerValidationQuantizedFixture< CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, true > CLDepthwiseConvolutionLayerQuantizedMixedDataLayoutFixture
Shape of a tensor.
Definition: TensorShape.h:39
half_float::half half
16-bit floating point type
Definition: Types.h:48
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Activation Layer Information class.
Definition: Types.h:1639
DepthwiseConvolutionLayerValidationFixture< CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, false, true > CLDepthwiseConvolutionLayerInPlaceFixture
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
DepthwiseConvolutionLayerValidationQuantizedPerChannelFixture< CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, int8_t > CLDepthwiseConvolutionLayerQuantizedPerChannelFixture
1 channel, 1 S32 per channel
RelativeTolerance< half_float::half > tolerance_f16(half_float::half(0.1))
Tolerance value for comparing reference&#39;s output against implementation&#39;s output for DataType::F16...
Quantization information.
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
quantized, asymmetric fixed-point 8-bit number unsigned
Accessor implementation for CLTensor objects.
Definition: CLAccessor.h:36
RelativeTolerance< float > tolerance_f32(0.01f)
Tolerance value for comparing reference&#39;s output against implementation&#39;s output for DataType::F32...
Padding and stride information class.
Definition: Types.h:669
validate(CLAccessor(output_state), expected_output)
Num samples, channels, height, width.
constexpr float tolerance_num
Tolerance number.
DepthwiseConvolutionLayerValidationFixture< CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T, true > CLDepthwiseConvolutionLayerMixedDataLayoutFixture
quantized, symmetric per channel fixed-point 8-bit number
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
Num samples, height, width, channels.
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:43
JoinDataset< T, U > concat(T &&dataset1, U &&dataset2)
Helper function to create a JoinDataset.
Definition: JoinDataset.h:160
quantized, asymmetric fixed-point 8-bit number signed
DepthwiseConvolutionLayerValidationFixture< CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T > CLDepthwiseConvolutionLayerFixture
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
DataType
Available data types.
Definition: Types.h:79
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier=1, ActivationLayerInfo act_info=ActivationLayerInfo(), const Size2D &dilation=Size2D(1U, 1U))
Static function to check if given info will lead to a valid configuration of CLDepthwiseConvolutionLa...
FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerFixture< half >, framework::DatasetMode::ALL, combine(combine(combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(), datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()), depth_multipliers), framework::dataset::make("DataType", DataType::F16)), framework::dataset::make("DataLayout", DataLayout::NCHW)), ActivationFunctionsDataset))