blob: 54b7925a093cabdff896fb4a400b40963279d9f8 [file] [log] [blame]
Giorgio Arena04a8f8c2017-11-23 11:45:24 +00001/*
Georgios Pinitasf72f9362018-01-12 16:29:45 +00002 * Copyright (c) 2017-2018 ARM Limited.
Giorgio Arena04a8f8c2017-11-23 11:45:24 +00003 *
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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTensorAllocator.h"
27#include "arm_compute/runtime/CL/functions/CLDepthwiseConvolutionLayer.h"
28#include "tests/CL/CLAccessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/DepthwiseConvolutionLayerDataset.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
35#include "tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
Michele Di Giorgio933fe862018-02-19 15:42:12 +000045RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.001)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */
46constexpr RelativeTolerance<float> tolerance_f32(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
47constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for DataType::QASYMM8 */
Michele Di Giorgiod24af8a2018-05-08 17:23:52 +010048constexpr float tolerance_num = 0.05f; /**< Tolerance number */
Giorgio Arena76572242018-04-04 17:44:26 +010049
50const auto depth_multipliers = framework::dataset::make("DepthMultiplier", { 1, 2, 3 });
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000051} // namespace
52
53TEST_SUITE(CL)
54TEST_SUITE(DepthwiseConvolutionLayer)
55
56template <typename T>
57using CLDepthwiseConvolutionLayerFixture = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
58
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000059template <typename T>
60using CLDepthwiseConvolutionLayerFixture3x3 = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>;
61
62TEST_SUITE(Float)
Michele Di Giorgiod24af8a2018-05-08 17:23:52 +010063TEST_SUITE(FP16)
Michele Di Giorgio933fe862018-02-19 15:42:12 +000064TEST_SUITE(W3x3)
Giorgio Arenadfca60b2018-01-31 10:30:59 +000065FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::ALL,
Giorgio Arena76572242018-04-04 17:44:26 +010066 combine(combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
67 datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()),
68 depth_multipliers),
Giorgio Arenadfca60b2018-01-31 10:30:59 +000069 framework::dataset::make("DataType",
70 DataType::F16)),
71 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Michele Di Giorgio933fe862018-02-19 15:42:12 +000072{
73 validate(CLAccessor(_target), _reference, tolerance_f16);
74}
Giorgio Arena76572242018-04-04 17:44:26 +010075FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
76 depth_multipliers),
Michele Di Giorgio933fe862018-02-19 15:42:12 +000077 framework::dataset::make("DataType",
Giorgio Arena1ed1fc62018-03-26 16:20:05 +010078 DataType::F16)),
79 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Michele Di Giorgio933fe862018-02-19 15:42:12 +000080{
81 validate(CLAccessor(_target), _reference, tolerance_f16);
82}
83TEST_SUITE_END()
Michele Di Giorgiod24af8a2018-05-08 17:23:52 +010084
85TEST_SUITE(Generic)
86FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(), depth_multipliers),
87 framework::dataset::make("DataType",
88 DataType::F16)),
89 framework::dataset::make("DataLayout", DataLayout::NCHW)))
90{
91 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
92}
93FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
94 depth_multipliers),
95 framework::dataset::make("DataType",
96 DataType::F16)),
97 framework::dataset::make("DataLayout", DataLayout::NCHW)))
98{
99 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
100}
101TEST_SUITE_END()
Michele Di Giorgio933fe862018-02-19 15:42:12 +0000102TEST_SUITE_END()
103
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000104TEST_SUITE(FP32)
105TEST_SUITE(W3x3)
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000106FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::ALL,
Giorgio Arena76572242018-04-04 17:44:26 +0100107 combine(combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
108 datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()),
109 depth_multipliers),
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000110 framework::dataset::make("DataType",
111 DataType::F32)),
112 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000113{
114 validate(CLAccessor(_target), _reference, tolerance_f32);
115}
Giorgio Arena76572242018-04-04 17:44:26 +0100116FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
117 depth_multipliers),
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000118 framework::dataset::make("DataType",
Giorgio Arena1ed1fc62018-03-26 16:20:05 +0100119 DataType::F32)),
120 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000121{
122 validate(CLAccessor(_target), _reference, tolerance_f32);
123}
124TEST_SUITE_END()
Michele Di Giorgiod24af8a2018-05-08 17:23:52 +0100125
126TEST_SUITE(Generic)
127FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(), depth_multipliers),
128 framework::dataset::make("DataType",
129 DataType::F32)),
130 framework::dataset::make("DataLayout", DataLayout::NCHW)))
131{
132 validate(CLAccessor(_target), _reference, tolerance_f32);
133}
134FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
135 depth_multipliers),
136 framework::dataset::make("DataType",
137 DataType::F32)),
138 framework::dataset::make("DataLayout", DataLayout::NCHW)))
139{
140 validate(CLAccessor(_target), _reference, tolerance_f32);
141}
142TEST_SUITE_END()
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000143TEST_SUITE_END()
144TEST_SUITE_END()
145
146template <typename T>
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000147using CLDepthwiseConvolutionLayerQuantizedFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
148template <typename T>
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000149using CLDepthwiseConvolutionLayerQuantizedFixture3x3 = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>;
150
151TEST_SUITE(Quantized)
152TEST_SUITE(QASYMM8)
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000153TEST_SUITE(Generic)
Giorgio Arena76572242018-04-04 17:44:26 +0100154FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
155 combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
156 depth_multipliers),
157 framework::dataset::make("DataType", DataType::QASYMM8)),
158 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
159 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000160{
161 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
162}
Giorgio Arena76572242018-04-04 17:44:26 +0100163FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
164 combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
165 depth_multipliers),
166 framework::dataset::make("DataType", DataType::QASYMM8)),
167 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
168 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000169{
170 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
171}
172TEST_SUITE_END()
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000173TEST_SUITE(W3x3)
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000174FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT,
Giorgio Arena76572242018-04-04 17:44:26 +0100175 combine(combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
176 framework::dataset::make("DepthMultiplier", 1)), // COMPMID-1071 Add depth multiplier support for NHWC
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000177 framework::dataset::make("DataType", DataType::QASYMM8)),
178 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
179 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000180{
181 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
182}
Giorgio Arena76572242018-04-04 17:44:26 +0100183FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY,
184 combine(combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
185 framework::dataset::make("DepthMultiplier", 1)), // COMPMID-1071 Add depth multiplier support for NHWC
186 framework::dataset::make("DataType", DataType::QASYMM8)),
187 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
188 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000189{
190 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
191}
192TEST_SUITE_END()
193TEST_SUITE_END()
194TEST_SUITE_END()
195
196TEST_SUITE_END()
197TEST_SUITE_END()
198} // namespace validation
199} // namespace test
200} // namespace arm_compute