Compute Library
 22.05
DepthwiseConvolutionLayer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 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"
29 #include "tests/NEON/Accessor.h"
31 #include "tests/datasets/DepthwiseConvolutionLayerDataset.h"
32 #include "tests/datasets/DilatedDepthwiseConvolutionLayerDataset.h"
34 #include "tests/framework/Macros.h"
37 #include "tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h"
38 
39 namespace arm_compute
40 {
41 namespace test
42 {
43 namespace validation
44 {
46 
47 namespace
48 {
49 constexpr RelativeTolerance<float> tolerance_f32(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
50 constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for DataType::QASYMM8 */
51 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
52 RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.02)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */
53 constexpr float tolerance_num = 0.05f; /**< Tolerance number */
54 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
55 
56 const auto depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 2, 8 });
57 const auto large_depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 2, 5, 32 });
58 
59 //Activation Functions
60 const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
61 {
62  ActivationLayerInfo(),
64 });
65 
66 const auto input_qinfo_dataset = framework::dataset::make("InputQInfo",
67 {
68  QuantizationInfo(0.3f, 10),
69  QuantizationInfo(2.2f, 10),
70 });
71 } // namespace
72 
73 TEST_SUITE(NEON)
74 TEST_SUITE(DepthwiseConvolutionLayer)
75 
76 // *INDENT-OFF*
77 // clang-format off
78 DATA_TEST_CASE(Validate3x3, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
79  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32), // Mismatching data type input/weights
80  TensorInfo(TensorShape(32U, 18U, 3U), 1, DataType::F32), // Mismatching input feature maps
81  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32), // Unsupported weights dimensions
82  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32), // Mismatching depth multiplier
83  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::QASYMM8), // Invalid stride
84  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32), // Invalid biases size
85  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32), // Invalid biases dimensions
86  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32), // Invalid output size
87  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // patch size bigger than input width
88  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // dilation < 1
89  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
90  }),
91  framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16),
92  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
93  TensorInfo(TensorShape(5U, 5U, 2U, 2U), 1, DataType::F32),
94  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
96  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
97  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
98  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
99  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
100  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
101  TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F32),
102  })),
114  })),
115  framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(30U, 16U, 2U), 1, DataType::F32),
116  TensorInfo(TensorShape(30U, 16U, 2U), 1, DataType::F32),
117  TensorInfo(TensorShape(30U, 16U, 2U), 1, DataType::F32),
118  TensorInfo(TensorShape(30U, 16U, 2U), 1, DataType::F32),
120  TensorInfo(TensorShape(30U, 16U, 2U), 1, DataType::F32),
121  TensorInfo(TensorShape(30U, 16U, 2U), 1, DataType::F32),
122  TensorInfo(TensorShape(32U, 18U, 2U), 1, DataType::F32),
123  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
124  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
125  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
126  })),
127  framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0),
128  PadStrideInfo(1, 1, 0, 0),
129  PadStrideInfo(1, 1, 0, 0),
130  PadStrideInfo(1, 1, 0, 0),
131  PadStrideInfo(4, 1, 0, 0),
132  PadStrideInfo(1, 1, 0, 0),
133  PadStrideInfo(1, 1, 0, 0),
134  PadStrideInfo(1, 1, 0, 0),
135  PadStrideInfo(1, 1, 0, 0),
136  PadStrideInfo(1, 1, 0, 0),
137  PadStrideInfo(1, 1, 0, 0),
138  })),
139  framework::dataset::make("DepthMultiplier", { 1,
140  1,
141  1,
142  3,
143  1,
144  1,
145  1,
146  1,
147  1,
148  1,
149  1,
150  })),
151  framework::dataset::make("Dilation", { Size2D(1U, 1U),
152  Size2D(1U, 1U),
153  Size2D(1U, 1U),
154  Size2D(1U, 1U),
155  Size2D(1U, 1U),
156  Size2D(1U, 1U),
157  Size2D(1U, 1U),
158  Size2D(1U, 1U),
159  Size2D(25U, 1U),
160  Size2D(0U, 1U),
161  Size2D(1U, 1U),
162  })),
163  framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, false, false, true })),
164  input_info, weights_info, biases_info, output_info, conv_info, depth_multiplier,dilation, expected)
165 {
166  bool is_valid = bool(NEDepthwiseConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false),
167  &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, depth_multiplier, ActivationLayerInfo(), dilation));
169 }
170 
172  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/weights
173  TensorInfo(TensorShape(27U, 13U, 3U), 1, DataType::F32), // Mismatching input feature maps
174  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching depth multiplier
175  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases size
176  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases dimensions
177  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid output size
178  TensorInfo(TensorShape(27U, 13U, 8U), 1, DataType::F32), // Patch size bigger than input width
179  TensorInfo(TensorShape(27U, 13U, 8U), 1, DataType::F32), // Dilation < 1
180  }),
181  framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U), 1, DataType::F16),
187  TensorInfo(TensorShape(3U, 3U, 16U), 1, DataType::F32),
188  TensorInfo(TensorShape(3U, 3U, 16U), 1, DataType::F32),
189  })),
198  })),
199  framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
200  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
201  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
202  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
203  TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F32),
204  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
205  TensorInfo(TensorShape(25U, 11U, 16U), 1, DataType::F32),
206  TensorInfo(TensorShape(25U, 11U, 16U), 1, DataType::F32),
207  })),
208  framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0),
209  PadStrideInfo(1, 1, 0, 0),
210  PadStrideInfo(1, 1, 0, 0),
211  PadStrideInfo(1, 1, 0, 0),
212  PadStrideInfo(1, 1, 0, 0),
213  PadStrideInfo(1, 1, 0, 0),
214  PadStrideInfo(1, 1, 0, 0),
215  PadStrideInfo(1, 1, 0, 0),
216  })),
217  framework::dataset::make("DepthMultiplier", { 1,
218  1,
219  3,
220  1,
221  1,
222  1,
223  2,
224  2,
225  })),
226  framework::dataset::make("Dilation", { Size2D(1U, 1U),
227  Size2D(1U, 1U),
228  Size2D(1U, 1U),
229  Size2D(1U, 1U),
230  Size2D(1U, 1U),
231  Size2D(1U, 1U),
232  Size2D(25U, 1U),
233  Size2D(0U, 1U),
234  })),
235  framework::dataset::make("Expected", { false, false, false, false, false, false, false, false})),
236  input_info, weights_info, biases_info, output_info, conv_info, depth_multiplier,dilation, expected)
237 {
238  bool is_valid = bool(NEDepthwiseConvolutionLayer::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, depth_multiplier, ActivationLayerInfo(), dilation));
240 }
241 // clang-format on
242 // *INDENT-ON*
243 template <typename T>
244 using NEDepthwiseConvolutionLayerFixture = DepthwiseConvolutionLayerValidationFixture<Tensor, Accessor, NEDepthwiseConvolutionLayer, T>;
245 template <typename T>
246 using NEDepthwiseConvolutionLayerMixedDataLayoutFixture = DepthwiseConvolutionLayerValidationFixture<Tensor, Accessor, NEDepthwiseConvolutionLayer, T, true>;
247 
248 TEST_SUITE(Float)
249 TEST_SUITE(F32)
250 TEST_SUITE(Generic)
251 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
252  depth_multipliers),
253  framework::dataset::make("DataType", DataType::F32)),
254  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
255  ActivationFunctionsDataset))
256 {
257  validate(Accessor(_target), _reference, tolerance_f32);
258 }
260  framework::dataset::make("DepthMultiplier", { 2 })),
263  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
264 {
265  validate(Accessor(_target), _reference, tolerance_f32);
266 }
268  large_depth_multipliers),
269  framework::dataset::make("DataType",
270  DataType::F32)),
272  ActivationFunctionsDataset))
273 {
274  validate(Accessor(_target), _reference, tolerance_f32);
275 }
276 
277 TEST_SUITE(Dilation)
279  combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
280  depth_multipliers),
281  framework::dataset::make("DataType",
282  DataType::F32)),
283  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
284  ActivationFunctionsDataset))
285 {
286  validate(Accessor(_target), _reference, tolerance_f32);
287 }
289  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
290  large_depth_multipliers),
291  framework::dataset::make("DataType",
292  DataType::F32)),
294  ActivationFunctionsDataset))
295 {
296  validate(Accessor(_target), _reference, tolerance_f32);
297 }
298 TEST_SUITE_END() // Dilation
299 TEST_SUITE_END() // Generic
300 
301 TEST_SUITE(W3x3)
302 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
303  depth_multipliers),
304  framework::dataset::make("DataType",
305  DataType::F32)),
306  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
307  ActivationFunctionsDataset))
308 {
309  validate(Accessor(_target), _reference, tolerance_f32);
310 }
312  combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
313  large_depth_multipliers),
314  framework::dataset::make("DataType",
315  DataType::F32)),
317  ActivationFunctionsDataset))
318 {
319  validate(Accessor(_target), _reference, tolerance_f32);
320 }
321 TEST_SUITE(Dilation)
323  combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
324  depth_multipliers),
325  framework::dataset::make("DataType",
326  DataType::F32)),
327  framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
328  ActivationFunctionsDataset))
329 {
330  validate(Accessor(_target), _reference, tolerance_f32);
331 }
333  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
334  large_depth_multipliers),
335  framework::dataset::make("DataType",
336  DataType::F32)),
338  ActivationFunctionsDataset))
339 {
340  validate(Accessor(_target), _reference, tolerance_f32);
341 }
342 
343 TEST_SUITE_END() // Dilation
344 TEST_SUITE_END() // W3x3
345 
346 TEST_SUITE(Optimized)
348  combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
349  framework::dataset::make("DepthMultiplier", 1)),
350  framework::dataset::make("DataType",
351  DataType::F32)),
353  ActivationFunctionsDataset))
354 {
355  validate(Accessor(_target), _reference, tolerance_f32);
356 }
358  combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
359  framework::dataset::make("DepthMultiplier", 1)),
362  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
363 {
364  validate(Accessor(_target), _reference, tolerance_f32);
365 }
367  combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset5x5(),
368  framework::dataset::make("DepthMultiplier", 1)),
369  framework::dataset::make("DataType",
370  DataType::F32)),
372  ActivationFunctionsDataset))
373 {
374  validate(Accessor(_target), _reference, tolerance_f32);
375 }
377  combine(combine(combine(combine(datasets::LargeOptimizedDepthwiseConvolutionLayerDataset3x3(),
378  framework::dataset::make("DepthMultiplier", 1)),
379  framework::dataset::make("DataType",
380  DataType::F32)),
382  ActivationFunctionsDataset))
383 {
384  validate(Accessor(_target), _reference, tolerance_f32);
385 }
386 TEST_SUITE_END() // Optimized
387 TEST_SUITE_END() // F32
388 
389 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
391 TEST_SUITE(Generic)
393  depth_multipliers),
394  framework::dataset::make("DataType",
395  DataType::F16)),
397  ActivationFunctionsDataset))
398 {
399  validate(Accessor(_target), _reference, tolerance_f16, tolerance_num);
400 }
402  large_depth_multipliers),
403  framework::dataset::make("DataType",
404  DataType::F16)),
406  ActivationFunctionsDataset))
407 {
408  validate(Accessor(_target), _reference, tolerance_f16, tolerance_num);
409 }
410 
411 TEST_SUITE(Dilation)
413  combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
414  depth_multipliers),
415  framework::dataset::make("DataType",
416  DataType::F16)),
418  ActivationFunctionsDataset))
419 {
420  validate(Accessor(_target), _reference, tolerance_f16, tolerance_num);
421 }
423  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
424  large_depth_multipliers),
425  framework::dataset::make("DataType",
426  DataType::F16)),
428  ActivationFunctionsDataset))
429 {
430  validate(Accessor(_target), _reference, tolerance_f16, tolerance_num);
431 }
432 TEST_SUITE_END() // Dilation
433 
434 TEST_SUITE_END() // Generic
435 template <typename T>
436 using NEDepthwiseConvolutionLayerFixture = DepthwiseConvolutionLayerValidationFixture<Tensor, Accessor, NEDepthwiseConvolutionLayer, T>;
437 TEST_SUITE(W3x3)
439  depth_multipliers),
440  framework::dataset::make("DataType",
441  DataType::F16)),
443  ActivationFunctionsDataset))
444 {
445  validate(Accessor(_target), _reference, tolerance_f16);
446 }
448  combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
449  large_depth_multipliers),
450  framework::dataset::make("DataType",
451  DataType::F16)),
453  ActivationFunctionsDataset))
454 {
455  validate(Accessor(_target), _reference, tolerance_f16);
456 }
457 
458 TEST_SUITE(Dilation)
459 
461  combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(),
462  depth_multipliers),
463  framework::dataset::make("DataType",
464  DataType::F16)),
466  ActivationFunctionsDataset))
467 {
468  validate(Accessor(_target), _reference, tolerance_f16);
469 }
471  combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
472  large_depth_multipliers),
473  framework::dataset::make("DataType",
474  DataType::F16)),
476  ActivationFunctionsDataset))
477 {
478  validate(Accessor(_target), _reference, tolerance_f16);
479 }
480 
481 TEST_SUITE_END() // Dilation
482 TEST_SUITE_END() // W3x3
483 
484 TEST_SUITE(Optimized)
486  combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
487  framework::dataset::make("DepthMultiplier", 1)),
488  framework::dataset::make("DataType",
489  DataType::F16)),
491  ActivationFunctionsDataset))
492 {
493  validate(Accessor(_target), _reference, tolerance_f16);
494 }
496  combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset5x5(),
497  framework::dataset::make("DepthMultiplier", 1)),
498  framework::dataset::make("DataType",
499  DataType::F16)),
501  ActivationFunctionsDataset))
502 {
503  validate(Accessor(_target), _reference, tolerance_f16);
504 }
506  combine(combine(combine(combine(datasets::LargeOptimizedDepthwiseConvolutionLayerDataset3x3(),
507  framework::dataset::make("DepthMultiplier", 1)),
508  framework::dataset::make("DataType",
509  DataType::F16)),
511  ActivationFunctionsDataset))
512 {
513  validate(Accessor(_target), _reference, tolerance_f16);
514 }
515 TEST_SUITE_END() // Optimized
516 TEST_SUITE_END() // FP16
517 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
518 
519 TEST_SUITE_END() // Float
520 
521 template <typename T>
522 using NEDepthwiseConvolutionLayerQuantizedFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<Tensor, Accessor, NEDepthwiseConvolutionLayer, T>;
523 template <typename T>
524 using NEDepthwiseConvolutionLayerQuantizedMixedDataLayoutFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<Tensor, Accessor, NEDepthwiseConvolutionLayer, T, true>;
525 using NEDepthwiseConvolutionLayerQuantizedSymmetricPerChannelFixture = DepthwiseConvolutionLayerValidationQuantizedPerChannelFixture<Tensor, Accessor, NEDepthwiseConvolutionLayer, uint8_t, int8_t>;
526 
527 TEST_SUITE(Quantized)
528 TEST_SUITE(QASYMM8)
529 TEST_SUITE(Generic)
530 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
531  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
532  depth_multipliers),
533  framework::dataset::make("DataType", DataType::QASYMM8)),
534  input_qinfo_dataset),
535  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
536  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
537  ActivationFunctionsDataset))
538 {
539  validate(Accessor(_target), _reference, tolerance_qasymm8);
540 }
542  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
543  framework::dataset::make("DepthMultiplier", { 2 })),
545  input_qinfo_dataset),
546  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
547  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
548  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
549 {
550  validate(Accessor(_target), _reference, tolerance_qasymm8);
551 }
552 TEST_SUITE(Dilation)
553 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
554  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
555  depth_multipliers),
556  framework::dataset::make("DataType", DataType::QASYMM8)),
557  input_qinfo_dataset),
558  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.8f, 1) })),
559  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
560  ActivationFunctionsDataset))
561 {
562  validate(Accessor(_target), _reference, tolerance_qasymm8);
563 }
565  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
566  large_depth_multipliers),
568  input_qinfo_dataset),
569  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.9f, 11) })),
570  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
571  ActivationFunctionsDataset))
572 {
573  validate(Accessor(_target), _reference, tolerance_qasymm8);
574 }
575 TEST_SUITE_END() // Dilation
576 TEST_SUITE_END() // Generic
577 TEST_SUITE(W3x3)
578 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
579  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(), depth_multipliers),
580  framework::dataset::make("DataType", DataType::QASYMM8)),
581  input_qinfo_dataset),
582  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
583  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
584  ActivationFunctionsDataset))
585 {
586  validate(Accessor(_target), _reference, tolerance_qasymm8);
587 }
589  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
590  large_depth_multipliers),
592  input_qinfo_dataset),
593  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
594  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
595  ActivationFunctionsDataset))
596 {
597  validate(Accessor(_target), _reference, tolerance_qasymm8);
598 }
599 
600 TEST_SUITE(Dilation)
601 
602 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
603  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(), depth_multipliers),
604  framework::dataset::make("DataType", DataType::QASYMM8)),
605  input_qinfo_dataset),
606  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.7f, 10) })),
607  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
608  ActivationFunctionsDataset))
609 {
610  validate(Accessor(_target), _reference, tolerance_qasymm8);
611 }
613  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
614  large_depth_multipliers),
616  input_qinfo_dataset),
617  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
618  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
619  ActivationFunctionsDataset))
620 {
621  validate(Accessor(_target), _reference, tolerance_qasymm8);
622 }
623 TEST_SUITE_END() // Dilation
624 TEST_SUITE_END() // W3x3
625 
626 TEST_SUITE(Optimized)
628  combine(combine(combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
629  framework::dataset::make("DepthMultiplier", 1)),
631  input_qinfo_dataset),
632  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
633  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
634  ActivationFunctionsDataset))
635 {
636  validate(Accessor(_target), _reference, tolerance_qasymm8);
637 }
639  combine(combine(combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
640  framework::dataset::make("DepthMultiplier", 1)),
642  input_qinfo_dataset),
643  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
644  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
645  framework::dataset::make("ActivationInfo", ActivationLayerInfo())))
646 {
647  validate(Accessor(_target), _reference, tolerance_qasymm8);
648 }
650  combine(combine(combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset5x5(),
651  framework::dataset::make("DepthMultiplier", 1)),
652  framework::dataset::make("DataType",
654  input_qinfo_dataset),
655  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
656  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
657  ActivationFunctionsDataset))
658 {
659  validate(Accessor(_target), _reference, tolerance_qasymm8);
660 }
662  combine(combine(combine(combine(combine(combine(datasets::LargeOptimizedDepthwiseConvolutionLayerDataset3x3(),
663  framework::dataset::make("DepthMultiplier", 1)),
664  framework::dataset::make("DataType",
666  input_qinfo_dataset),
667  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
668  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
669  ActivationFunctionsDataset))
670 {
671  validate(Accessor(_target), _reference, tolerance_qasymm8);
672 }
673 TEST_SUITE_END() // Optimized
674 TEST_SUITE_END() // QASYMM8
675 
677 TEST_SUITE(Generic)
678 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
679  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
680  depth_multipliers),
681  framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
682  input_qinfo_dataset),
683  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
684  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
685  ActivationFunctionsDataset))
686 {
687  validate(Accessor(_target), _reference, tolerance_qasymm8);
688 }
689 
690 TEST_SUITE(Dilation)
691 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
692  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
693  depth_multipliers),
694  framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
695  input_qinfo_dataset),
696  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.8f, 1) })),
697  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
698  ActivationFunctionsDataset))
699 {
700  validate(Accessor(_target), _reference, tolerance_qasymm8);
701 }
703  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
704  large_depth_multipliers),
706  input_qinfo_dataset),
707  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.9f, 11) })),
708  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
709  ActivationFunctionsDataset))
710 {
711  validate(Accessor(_target), _reference, tolerance_qasymm8);
712 }
713 TEST_SUITE_END() // Dilation
714 TEST_SUITE_END() // Generic
715 
716 TEST_SUITE(W3x3)
718  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(), depth_multipliers),
720  input_qinfo_dataset),
721  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
722  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
723  ActivationFunctionsDataset))
724 {
725  validate(Accessor(_target), _reference, tolerance_qasymm8);
726 }
728  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
729  large_depth_multipliers),
731  input_qinfo_dataset),
732  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
733  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
734  ActivationFunctionsDataset))
735 {
736  validate(Accessor(_target), _reference, tolerance_qasymm8);
737 }
738 
739 TEST_SUITE(Dilation)
740 FIXTURE_DATA_TEST_CASE_NEW(RunSmall, NEDepthwiseConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
741  combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset3x3(), depth_multipliers),
742  framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
743  input_qinfo_dataset),
744  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.7f, 10) })),
745  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
746  ActivationFunctionsDataset))
747 {
748  validate(Accessor(_target), _reference, tolerance_qasymm8);
749 }
751  combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset3x3(),
752  large_depth_multipliers),
754  input_qinfo_dataset),
755  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
756  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
757  ActivationFunctionsDataset))
758 {
759  validate(Accessor(_target), _reference, tolerance_qasymm8);
760 }
761 TEST_SUITE_END() // Dilation
762 TEST_SUITE_END() // W3x3
763 
764 TEST_SUITE(Optimized)
766  combine(combine(combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
767  framework::dataset::make("DepthMultiplier", 1)),
768  framework::dataset::make("DataType",
770  input_qinfo_dataset),
771  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
772  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
773  ActivationFunctionsDataset))
774 {
775  validate(Accessor(_target), _reference, tolerance_qasymm8);
776 }
778  combine(combine(combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset5x5(),
779  framework::dataset::make("DepthMultiplier", 1)),
780  framework::dataset::make("DataType",
782  input_qinfo_dataset),
783  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
784  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
785  ActivationFunctionsDataset))
786 {
787  validate(Accessor(_target), _reference, tolerance_qasymm8);
788 }
790  combine(combine(combine(combine(combine(combine(datasets::LargeOptimizedDepthwiseConvolutionLayerDataset3x3(),
791  framework::dataset::make("DepthMultiplier", 1)),
792  framework::dataset::make("DataType",
794  input_qinfo_dataset),
795  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 10) })),
796  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
797  ActivationFunctionsDataset))
798 {
799  validate(Accessor(_target), _reference, tolerance_qasymm8);
800 }
801 TEST_SUITE_END() // Optimized
802 TEST_SUITE_END() // QASYMM8_SIGNED
803 
805 TEST_SUITE(Generic)
807  combine(combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
808  depth_multipliers),
809  framework::dataset::make("InputDataType", DataType::QASYMM8)),
811  input_qinfo_dataset),
812  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
814  ActivationFunctionsDataset))
815 {
816  validate(Accessor(_target), _reference, tolerance_qasymm8);
817 }
818 
819 TEST_SUITE(Dilation)
821  combine(combine(combine(combine(combine(combine(combine(datasets::SmallDepthwiseDilatedConvolutionLayerDataset(),
822  depth_multipliers),
823  framework::dataset::make("InputDataType", DataType::QASYMM8)),
824  framework::dataset::make("WeightsDataType", DataType::QSYMM8_PER_CHANNEL)),
825  input_qinfo_dataset),
826  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
828  ActivationFunctionsDataset))
829 {
830  validate(Accessor(_target), _reference, tolerance_qasymm8);
831 }
833  combine(combine(combine(combine(combine(combine(combine(datasets::LargeDepthwiseDilatedConvolutionLayerDataset(),
834  depth_multipliers),
835  framework::dataset::make("InputDataType", DataType::QASYMM8)),
837  input_qinfo_dataset),
838  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
840  ActivationFunctionsDataset))
841 {
842  validate(Accessor(_target), _reference, tolerance_qasymm8);
843 }
844 TEST_SUITE_END() // Dilation
845 TEST_SUITE_END() // Generic
846 
847 TEST_SUITE(Optimized)
849  combine(combine(combine(combine(combine(combine(combine(datasets::SmallOptimizedDepthwiseConvolutionLayerDataset3x3(),
850  framework::dataset::make("DepthMultiplier", 1)),
851  framework::dataset::make("InputDataType", DataType::QASYMM8)),
853  input_qinfo_dataset),
854  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
855  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
856  ActivationFunctionsDataset))
857 {
858  validate(Accessor(_target), _reference, tolerance_qasymm8);
859 }
861  combine(combine(combine(combine(combine(combine(combine(datasets::LargeOptimizedDepthwiseConvolutionLayerDataset3x3(),
862  framework::dataset::make("DepthMultiplier", 1)),
863  framework::dataset::make("InputDataType", DataType::QASYMM8)),
865  input_qinfo_dataset),
866  framework::dataset::make("DstQuantizationInfo", { QuantizationInfo(0.5f, 4) })),
867  framework::dataset::make("DataLayout", { DataLayout::NHWC })),
868  ActivationFunctionsDataset))
869 {
870  validate(Accessor(_target), _reference, tolerance_qasymm8);
871 }
872 TEST_SUITE_END() // Optimized
873 TEST_SUITE_END() // QSYMM8_PER_CHANNEL
874 TEST_SUITE_END() // Quantized
875 
876 TEST_SUITE_END() // DepthwiseConvLayer
877 TEST_SUITE_END() // Neon
878 } // namespace validation
879 } // namespace test
880 } // namespace arm_compute
Shape of a tensor.
Definition: TensorShape.h:39
RelativeTolerance< float > tolerance_f32(0.001f)
F32 Tolerance value for comparing reference&#39;s output against implementation&#39;s output for floating poi...
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)
DepthwiseConvolutionLayerValidationQuantizedPerChannelFixture< Tensor, Accessor, NEDepthwiseConvolutionLayer, uint8_t, int8_t > NEDepthwiseConvolutionLayerQuantizedSymmetricPerChannelFixture
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:1625
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
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)
DepthwiseConvolutionLayerValidationQuantizedFixture< Tensor, Accessor, NEDepthwiseConvolutionLayer, T, true > NEDepthwiseConvolutionLayerQuantizedMixedDataLayoutFixture
Accessor implementation for Tensor objects.
Definition: Accessor.h:35
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
DepthwiseConvolutionLayerValidationFixture< Tensor, Accessor, NEDepthwiseConvolutionLayer, T > NEDepthwiseConvolutionLayerFixture
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier=1, const ActivationLayerInfo &act_info=ActivationLayerInfo(), const Size2D &dilation=Size2D(1U, 1U))
Static function to check if given info will lead to a valid configuration of NEDepthwiseConvolutionLa...
quantized, asymmetric fixed-point 8-bit number unsigned
Padding and stride information class.
Definition: Types.h:669
validate(CLAccessor(output_state), expected_output)
Num samples, channels, height, width.
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
quantized, asymmetric fixed-point 8-bit number signed
RelativeTolerance< half_float::half > tolerance_f16(half(0.2))
F16 Tolerance value for comparing reference&#39;s output against implementation&#39;s output for floating poi...
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
DepthwiseConvolutionLayerValidationFixture< Tensor, Accessor, NEDepthwiseConvolutionLayer, T, true > NEDepthwiseConvolutionLayerMixedDataLayoutFixture
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65
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))