blob: 20bf6cd46f868527e664503d38cff9533959d5e4 [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)
57FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallDepthwiseConvolutionLayerDataset(), framework::dataset::make("DataType",
58 DataType::F32)))
59{
60 validate(CLAccessor(_target), _reference, tolerance_f32);
61}
62FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
63 framework::dataset::make("DataType",
64 DataType::F32)))
65{
66 validate(CLAccessor(_target), _reference, tolerance_f32);
67}
68TEST_SUITE_END()
69
70template <typename T>
71using CLDepthwiseConvolutionLayerFixture3x3 = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>;
72
73TEST_SUITE(Float)
Michele Di Giorgio933fe862018-02-19 15:42:12 +000074TEST_SUITE(F16)
75TEST_SUITE(W3x3)
76FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::ALL, combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
77 framework::dataset::make("DataType",
78 DataType::F16)))
79{
80 validate(CLAccessor(_target), _reference, tolerance_f16);
81}
82FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
83 framework::dataset::make("DataType",
84 DataType::F16)))
85{
86 validate(CLAccessor(_target), _reference, tolerance_f16);
87}
88TEST_SUITE_END()
89TEST_SUITE_END()
90
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000091TEST_SUITE(FP32)
92TEST_SUITE(W3x3)
93FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::ALL, combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
94 framework::dataset::make("DataType",
95 DataType::F32)))
96{
97 validate(CLAccessor(_target), _reference, tolerance_f32);
98}
99FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
100 framework::dataset::make("DataType",
101 DataType::F32)))
102{
103 validate(CLAccessor(_target), _reference, tolerance_f32);
104}
105TEST_SUITE_END()
106TEST_SUITE_END()
107TEST_SUITE_END()
108
109template <typename T>
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000110using CLDepthwiseConvolutionLayerQuantizedFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>;
111template <typename T>
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000112using CLDepthwiseConvolutionLayerQuantizedFixture3x3 = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>;
113
114TEST_SUITE(Quantized)
115TEST_SUITE(QASYMM8)
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000116TEST_SUITE(Generic)
117FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(),
118 framework::dataset::make("DataType", DataType::QASYMM8)),
119 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
120{
121 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
122}
123FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(),
124 framework::dataset::make("DataType", DataType::QASYMM8)),
125 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
126{
127 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
128}
129TEST_SUITE_END()
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000130TEST_SUITE(W3x3)
131FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(),
132 framework::dataset::make("DataType", DataType::QASYMM8)),
Georgios Pinitasf72f9362018-01-12 16:29:45 +0000133 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000134{
135 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
136}
137FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(),
138 framework::dataset::make("DataType", DataType::QASYMM8)),
Georgios Pinitasf72f9362018-01-12 16:29:45 +0000139 framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
Giorgio Arena04a8f8c2017-11-23 11:45:24 +0000140{
141 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
142}
143TEST_SUITE_END()
144TEST_SUITE_END()
145TEST_SUITE_END()
146
147TEST_SUITE_END()
148TEST_SUITE_END()
149} // namespace validation
150} // namespace test
151} // namespace arm_compute