blob: 46a229bb39e95fad61a4fd38ebaaec01e2a204a1 [file] [log] [blame]
Michalis Spyrou780db4e2017-11-23 09:49:51 +00001/*
Michalis Spyrou80943252019-01-10 17:19:50 +00002 * Copyright (c) 2017-2019 ARM Limited.
Michalis Spyrou780db4e2017-11-23 09:49:51 +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 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/CL/kernels/CLFillBorderKernel.h"
25#include "arm_compute/core/Types.h"
Michele Di Giorgioed5a4922018-09-13 16:22:01 +010026#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Michalis Spyrou780db4e2017-11-23 09:49:51 +000027#include "arm_compute/runtime/CL/CLTensor.h"
28#include "arm_compute/runtime/CL/CLTensorAllocator.h"
29#include "arm_compute/runtime/CL/functions/CLDeconvolutionLayer.h"
30#include "tests/CL/CLAccessor.h"
31#include "tests/PaddingCalculator.h"
32#include "tests/datasets/ShapeDatasets.h"
33#include "tests/framework/Asserts.h"
34#include "tests/framework/Macros.h"
35#include "tests/framework/datasets/Datasets.h"
36#include "tests/validation/Validation.h"
37#include "tests/validation/fixtures/DeconvolutionLayerFixture.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45namespace
46{
Georgios Pinitas793f87d2018-05-18 20:08:58 +010047constexpr AbsoluteTolerance<float> tolerance_fp32(0.001f); /**< Tolerance for floating point tests */
48RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.2)); /**< Tolerance value for comparing reference's for DataType::F16 */
Michele Di Giorgioed5a4922018-09-13 16:22:01 +010049constexpr AbsoluteTolerance<float> tolerance_qasymm8(0.0); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */
Georgios Pinitas793f87d2018-05-18 20:08:58 +010050constexpr float tolerance_num = 0.07f; /**< Tolerance number */
Michalis Spyrou780db4e2017-11-23 09:49:51 +000051
Michalis Spyrou5ce99a22019-01-25 14:17:49 +000052const auto data4x4 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 3)
53 * framework::dataset::make("PadY", 0, 3) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 3 });
Georgios Pinitasced7a8d2018-02-01 16:31:33 +000054
Michalis Spyrou780db4e2017-11-23 09:49:51 +000055const auto data3x3 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 2)
Michalis Spyrou5ce99a22019-01-25 14:17:49 +000056 * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 3 });
Michalis Spyrou780db4e2017-11-23 09:49:51 +000057
Michalis Spyrou064add62018-11-01 18:14:27 +000058const auto data3x3_precommit = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 2) * framework::dataset::make("StrideY", 1, 2) * framework::dataset::make("PadX", 0, 2)
59 * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 3 });
60
Michalis Spyrou780db4e2017-11-23 09:49:51 +000061const auto data1x1 = datasets::SmallDeconvolutionShapes() * framework::dataset::make("StrideX", 1, 4) * framework::dataset::make("StrideY", 1, 4) * framework::dataset::make("PadX", 0, 1)
Michalis Spyrou5ce99a22019-01-25 14:17:49 +000062 * framework::dataset::make("PadY", 0, 1) * framework::dataset::make("ax", 0) * framework::dataset::make("ay", 0) * framework::dataset::make("NumKernels", { 3 });
Michalis Spyrou780db4e2017-11-23 09:49:51 +000063
Michalis Spyrou5ce99a22019-01-25 14:17:49 +000064const auto data_layouts_dataset = framework::dataset::make("DataLayout", { DataLayout::NCHW });
Michalis Spyrou780db4e2017-11-23 09:49:51 +000065} // namespace
66
67TEST_SUITE(CL)
68TEST_SUITE(DeconvolutionLayer)
69
Michalis Spyrou780db4e2017-11-23 09:49:51 +000070// *INDENT-OFF*
71// clang-format off
72DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010073 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type
74 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid weights shape
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010075 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid bias shape
76 TensorInfo(TensorShape(13U, 11U, 4U, 3U), 1, DataType::F32), // Window shrink
77 TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000078 }),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010079 framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16),
80 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010081 TensorInfo(TensorShape(3U, 2U, 2U, 2U), 1, DataType::F32),
82 TensorInfo(TensorShape(3U, 3U, 4U), 1, DataType::F32),
83 TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000084 })),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010085 framework::dataset::make("BiasInfo", { TensorInfo(TensorShape(1U), 1, DataType::F16),
86 TensorInfo(TensorShape(1U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010087 TensorInfo(TensorShape(25U, 11U), 1, DataType::F32),
88 TensorInfo(TensorShape(1U), 1, DataType::F32),
89 TensorInfo(TensorShape(4U), 1, DataType::F32),
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +010090 TensorInfo(TensorShape(4U), 1, DataType::S32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000091 })),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010092 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F16),
93 TensorInfo(TensorShape(25U, 10U, 2U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010094 TensorInfo(TensorShape(13U, 13U, 2U), 1, DataType::F32),
95 TensorInfo(TensorShape(11U, 9U, 1U, 3U), 1, DataType::F32),
96 TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000097 })),
98 framework::dataset::make("PadStrideInfo", { PadStrideInfo(1, 1, 0, 0),
99 PadStrideInfo(1, 1, 0, 0),
100 PadStrideInfo(1, 1, 0, 0),
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000101 PadStrideInfo(1, 1, 1, 1),
102 PadStrideInfo(1, 1, 0, 0),
103 })),
104 framework::dataset::make("ax", { 1U,
105 1U,
106 1U,
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000107 0U,
108 0U,
109 })),
110 framework::dataset::make("ay", { 1U,
111 1U,
112 1U,
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000113 0U,
114 0U,
115 })),
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100116 framework::dataset::make("Expected", { false, false, false, false, true })),
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000117 input_info, weights_info, bias_info, output_info, pad_info, ax, ay, expected)
118{
119 bool is_valid = bool(CLDeconvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), pad_info, ax, ay));
120 ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
121}
122// clang-format on
123// *INDENT-ON*
124
125template <typename T>
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000126using CLDeconvolutionLayerFixture4x4 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 4, 4>;
127
128template <typename T>
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000129using CLDeconvolutionLayerFixture3x3 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
130
131template <typename T>
132using CLDeconvolutionLayerFixture1x1 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 1, 1>;
133
134TEST_SUITE(Float)
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000135TEST_SUITE(FP32)
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000136
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100137TEST_SUITE(W4x4)
Michalis Spyrou064add62018-11-01 18:14:27 +0000138FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture4x4<float>, framework::DatasetMode::NIGHTLY, combine(combine(data4x4, framework::dataset::make("DataType", DataType::F32)),
139 data_layouts_dataset))
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000140{
141 // Validate output
142 validate(CLAccessor(_target), _reference, tolerance_fp32);
143}
Michalis Spyrou064add62018-11-01 18:14:27 +0000144TEST_SUITE_END() // W4x4
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000145
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000146TEST_SUITE(W3x3)
Michalis Spyrou064add62018-11-01 18:14:27 +0000147FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::PRECOMMIT, combine(combine(data3x3_precommit, framework::dataset::make("DataType", DataType::F32)),
148 data_layouts_dataset))
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000149{
150 // Validate output
151 validate(CLAccessor(_target), _reference, tolerance_fp32);
152}
Michalis Spyrou064add62018-11-01 18:14:27 +0000153FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(data3x3, framework::dataset::make("DataType", DataType::F32)),
154 data_layouts_dataset))
155{
156 // Validate output
157 validate(CLAccessor(_target), _reference, tolerance_fp32);
158}
159TEST_SUITE_END() // W3x3
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000160
161TEST_SUITE(W1x1)
Michalis Spyrou064add62018-11-01 18:14:27 +0000162FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture1x1<float>, framework::DatasetMode::NIGHTLY, combine(combine(data1x1, framework::dataset::make("DataType", DataType::F32)),
163 data_layouts_dataset))
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000164{
165 // Validate output
166 validate(CLAccessor(_target), _reference, tolerance_fp32);
167}
Michalis Spyrou064add62018-11-01 18:14:27 +0000168TEST_SUITE_END() // W1x1
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000169
Michalis Spyrou064add62018-11-01 18:14:27 +0000170TEST_SUITE_END() // FP32
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100171
172TEST_SUITE(FP16)
173
174TEST_SUITE(W4x4)
Michalis Spyrou064add62018-11-01 18:14:27 +0000175FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture4x4<half>, framework::DatasetMode::NIGHTLY, combine(combine(data4x4, framework::dataset::make("DataType", DataType::F16)), data_layouts_dataset))
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100176{
177 // Validate output
178 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
179}
Michalis Spyrou064add62018-11-01 18:14:27 +0000180TEST_SUITE_END() // W4x4
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100181
182TEST_SUITE(W3x3)
Michalis Spyrou064add62018-11-01 18:14:27 +0000183FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture3x3<half>, framework::DatasetMode::PRECOMMIT, combine(combine(data3x3_precommit, framework::dataset::make("DataType", DataType::F16)),
184 data_layouts_dataset))
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100185{
186 // Validate output
187 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
188}
Michalis Spyrou064add62018-11-01 18:14:27 +0000189FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(combine(data3x3, framework::dataset::make("DataType", DataType::F16)),
190 data_layouts_dataset))
191{
192 // Validate output
193 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
194}
195TEST_SUITE_END() // W3x3
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100196
197TEST_SUITE(W1x1)
Michalis Spyrou064add62018-11-01 18:14:27 +0000198FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture1x1<half>, framework::DatasetMode::NIGHTLY, combine(combine(data1x1, framework::dataset::make("DataType", DataType::F16)), data_layouts_dataset))
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100199{
200 // Validate output
201 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
202}
Michalis Spyrou064add62018-11-01 18:14:27 +0000203TEST_SUITE_END() // W1x1
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100204
Michalis Spyrou064add62018-11-01 18:14:27 +0000205TEST_SUITE_END() // FP16
206TEST_SUITE_END() // Float
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000207
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100208template <typename T>
209using CLDeconvolutionLayerQuantizedFixture4x4 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 4, 4>;
210
211template <typename T>
212using CLDeconvolutionLayerQuantizedFixture3x3 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
213
214template <typename T>
215using CLDeconvolutionLayerQuantizedFixture1x1 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 1, 1>;
216
217TEST_SUITE(Quantized)
218TEST_SUITE(QASYMM8)
219
220TEST_SUITE(W4x4)
Michalis Spyrou064add62018-11-01 18:14:27 +0000221FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture4x4<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data4x4, framework::dataset::make("DataType",
222 DataType::QASYMM8)),
223 data_layouts_dataset),
224 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100225{
226 // Validate output
227 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
228}
Michalis Spyrou064add62018-11-01 18:14:27 +0000229TEST_SUITE_END() // W4x4
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100230
231TEST_SUITE(W3x3)
Michalis Spyrou064add62018-11-01 18:14:27 +0000232FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data3x3_precommit, framework::dataset::make("DataType",
233 DataType::QASYMM8)),
234 data_layouts_dataset),
235 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100236{
237 // Validate output
238 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
239}
Michalis Spyrou064add62018-11-01 18:14:27 +0000240FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data3x3, framework::dataset::make("DataType",
241 DataType::QASYMM8)),
242 data_layouts_dataset),
243 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
244{
245 // Validate output
246 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
247}
248TEST_SUITE_END() // W3x3
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100249
250TEST_SUITE(W1x1)
Michalis Spyrou064add62018-11-01 18:14:27 +0000251FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture1x1<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data1x1, framework::dataset::make("DataType",
252 DataType::QASYMM8)),
253 data_layouts_dataset),
254 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100255{
256 // Validate output
257 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
258}
Michalis Spyrou064add62018-11-01 18:14:27 +0000259TEST_SUITE_END() // W1x1
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100260
Michalis Spyrou064add62018-11-01 18:14:27 +0000261TEST_SUITE_END() // QASYMM8
262TEST_SUITE_END() // Quantized
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100263
Michalis Spyrou064add62018-11-01 18:14:27 +0000264TEST_SUITE_END() // DeconvolutionLayer
265TEST_SUITE_END() // CL
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000266} // namespace validation
267} // namespace test
268} // namespace arm_compute