blob: 450bb21e777352899f9fbd594ae2d58f593409b5 [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 */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000048} // namespace
49
50TEST_SUITE(CL)
51TEST_SUITE(DepthwiseConvolutionLayer)
52
53template <typename T>
54using CLDepthwiseConvolutionLayerFixture = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
55
56TEST_SUITE(Generic)
Giorgio Arena1ed1fc62018-03-26 16:20:05 +010057FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
58 framework::dataset::make("DataType",
59 DataType::F32)),
60 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000061{
62 validate(CLAccessor(_target), _reference, tolerance_f32);
63}
Giorgio Arena1ed1fc62018-03-26 16:20:05 +010064FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000065 framework::dataset::make("DataType",
Giorgio Arena1ed1fc62018-03-26 16:20:05 +010066 DataType::F32)),
67 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000068{
69 validate(CLAccessor(_target), _reference, tolerance_f32);
70}
71TEST_SUITE_END()
72
73template <typename T>
74using CLDepthwiseConvolutionLayerFixture3x3 = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>;
75
76TEST_SUITE(Float)
Michele Di Giorgio933fe862018-02-19 15:42:12 +000077TEST_SUITE(F16)
78TEST_SUITE(W3x3)
Giorgio Arenadfca60b2018-01-31 10:30:59 +000079FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::ALL,
80 combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
81 datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()),
82 framework::dataset::make("DataType",
83 DataType::F16)),
84 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Michele Di Giorgio933fe862018-02-19 15:42:12 +000085{
86 validate(CLAccessor(_target), _reference, tolerance_f16);
87}
Giorgio Arena1ed1fc62018-03-26 16:20:05 +010088FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
Michele Di Giorgio933fe862018-02-19 15:42:12 +000089 framework::dataset::make("DataType",
Giorgio Arena1ed1fc62018-03-26 16:20:05 +010090 DataType::F16)),
91 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Michele Di Giorgio933fe862018-02-19 15:42:12 +000092{
93 validate(CLAccessor(_target), _reference, tolerance_f16);
94}
95TEST_SUITE_END()
96TEST_SUITE_END()
97
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000098TEST_SUITE(FP32)
99TEST_SUITE(W3x3)
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000100FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::ALL,
101 combine(combine(framework::dataset::concat(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
102 datasets::SmallDepthwiseConvolutionLayerDataset3x3NCHW()),
103 framework::dataset::make("DataType",
104 DataType::F32)),
105 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000106{
107 validate(CLAccessor(_target), _reference, tolerance_f32);
108}
Giorgio Arena1ed1fc62018-03-26 16:20:05 +0100109FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000110 framework::dataset::make("DataType",
Giorgio Arena1ed1fc62018-03-26 16:20:05 +0100111 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}
116TEST_SUITE_END()
117TEST_SUITE_END()
118TEST_SUITE_END()
119
120template <typename T>
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000121using CLDepthwiseConvolutionLayerQuantizedFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
122template <typename T>
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000123using CLDepthwiseConvolutionLayerQuantizedFixture3x3 = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>;
124
125TEST_SUITE(Quantized)
126TEST_SUITE(QASYMM8)
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000127TEST_SUITE(Generic)
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000128FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000129 framework::dataset::make("DataType", DataType::QASYMM8)),
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000130 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
131 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000132{
133 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
134}
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000135FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000136 framework::dataset::make("DataType", DataType::QASYMM8)),
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000137 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
138 framework::dataset::make("DataLayout", DataLayout::NCHW)))
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000139{
140 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
141}
142TEST_SUITE_END()
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000143TEST_SUITE(W3x3)
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000144FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT,
145 combine(combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
146 framework::dataset::make("DataType", DataType::QASYMM8)),
147 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
148 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000149{
150 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
151}
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000152FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000153 framework::dataset::make("DataType", DataType::QASYMM8)),
Giorgio Arenadfca60b2018-01-31 10:30:59 +0000154 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })),
155 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000156{
157 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
158}
159TEST_SUITE_END()
160TEST_SUITE_END()
161TEST_SUITE_END()
162
163TEST_SUITE_END()
164TEST_SUITE_END()
165} // namespace validation
166} // namespace test
167} // namespace arm_compute