blob: 31852c8eb640dcd2e6f4f8e276690bcbeedcd216 [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)
giuros01a69a88b2019-01-31 16:29:19 +000053 * framework::dataset::make("PadY", 0, 3) * 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)
giuros01a69a88b2019-01-31 16:29:19 +000056 * framework::dataset::make("PadY", 0, 2) * 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)
giuros01a69a88b2019-01-31 16:29:19 +000059 * framework::dataset::make("PadY", 0, 2) * framework::dataset::make("NumKernels", { 3 });
Michalis Spyrou064add62018-11-01 18:14:27 +000060
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)
giuros01a69a88b2019-01-31 16:29:19 +000062 * framework::dataset::make("PadY", 0, 1) * 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
giuros01a69a88b2019-01-31 16:29:19 +000077 TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32), // Inner border different from 0
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010078 TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000079 }),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010080 framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 2U), 1, DataType::F16),
81 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010082 TensorInfo(TensorShape(3U, 2U, 2U, 2U), 1, DataType::F32),
83 TensorInfo(TensorShape(3U, 3U, 4U), 1, DataType::F32),
giuros01a69a88b2019-01-31 16:29:19 +000084 TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010085 TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000086 })),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010087 framework::dataset::make("BiasInfo", { TensorInfo(TensorShape(1U), 1, DataType::F16),
88 TensorInfo(TensorShape(1U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010089 TensorInfo(TensorShape(25U, 11U), 1, DataType::F32),
90 TensorInfo(TensorShape(1U), 1, DataType::F32),
91 TensorInfo(TensorShape(4U), 1, DataType::F32),
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +010092 TensorInfo(TensorShape(4U), 1, DataType::S32),
giuros01a69a88b2019-01-31 16:29:19 +000093 TensorInfo(TensorShape(4U), 1, DataType::S32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +000094 })),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010095 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 2U), 1, DataType::F16),
96 TensorInfo(TensorShape(25U, 10U, 2U), 1, DataType::F32),
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010097 TensorInfo(TensorShape(13U, 13U, 2U), 1, DataType::F32),
98 TensorInfo(TensorShape(11U, 9U, 1U, 3U), 1, DataType::F32),
99 TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32),
giuros01a69a88b2019-01-31 16:29:19 +0000100 TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32),
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000101 })),
102 framework::dataset::make("PadStrideInfo", { PadStrideInfo(1, 1, 0, 0),
103 PadStrideInfo(1, 1, 0, 0),
104 PadStrideInfo(1, 1, 0, 0),
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000105 PadStrideInfo(1, 1, 1, 1),
106 PadStrideInfo(1, 1, 0, 0),
giuros01a69a88b2019-01-31 16:29:19 +0000107 PadStrideInfo(1, 1, 0, 0),
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000108 })),
giuros01a69a88b2019-01-31 16:29:19 +0000109 framework::dataset::make("ax", { 0U,
110 0U,
111 0U,
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000112 0U,
113 0U,
114 })),
giuros01a69a88b2019-01-31 16:29:19 +0000115 framework::dataset::make("ay", { 0U,
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000116 0U,
117 0U,
giuros01a69a88b2019-01-31 16:29:19 +0000118 0U,
119 1U,
120 0U,
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000121 })),
giuros01a69a88b2019-01-31 16:29:19 +0000122 framework::dataset::make("Expected", { false, false, false, false, false, true })),
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000123 input_info, weights_info, bias_info, output_info, pad_info, ax, ay, expected)
124{
125 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));
126 ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
127}
128// clang-format on
129// *INDENT-ON*
130
131template <typename T>
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000132using CLDeconvolutionLayerFixture4x4 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 4, 4>;
133
134template <typename T>
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000135using CLDeconvolutionLayerFixture3x3 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
136
137template <typename T>
138using CLDeconvolutionLayerFixture1x1 = DeconvolutionValidationFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 1, 1>;
139
140TEST_SUITE(Float)
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000141TEST_SUITE(FP32)
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000142
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100143TEST_SUITE(W4x4)
Michalis Spyrou064add62018-11-01 18:14:27 +0000144FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture4x4<float>, framework::DatasetMode::NIGHTLY, combine(combine(data4x4, framework::dataset::make("DataType", DataType::F32)),
145 data_layouts_dataset))
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000146{
147 // Validate output
148 validate(CLAccessor(_target), _reference, tolerance_fp32);
149}
Michalis Spyrou064add62018-11-01 18:14:27 +0000150TEST_SUITE_END() // W4x4
Georgios Pinitasced7a8d2018-02-01 16:31:33 +0000151
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000152TEST_SUITE(W3x3)
Michalis Spyrou064add62018-11-01 18:14:27 +0000153FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::PRECOMMIT, combine(combine(data3x3_precommit, framework::dataset::make("DataType", DataType::F32)),
154 data_layouts_dataset))
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000155{
156 // Validate output
157 validate(CLAccessor(_target), _reference, tolerance_fp32);
158}
Michalis Spyrou064add62018-11-01 18:14:27 +0000159FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(data3x3, framework::dataset::make("DataType", DataType::F32)),
160 data_layouts_dataset))
161{
162 // Validate output
163 validate(CLAccessor(_target), _reference, tolerance_fp32);
164}
165TEST_SUITE_END() // W3x3
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000166
167TEST_SUITE(W1x1)
Michalis Spyrou064add62018-11-01 18:14:27 +0000168FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerFixture1x1<float>, framework::DatasetMode::NIGHTLY, combine(combine(data1x1, framework::dataset::make("DataType", DataType::F32)),
169 data_layouts_dataset))
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000170{
171 // Validate output
172 validate(CLAccessor(_target), _reference, tolerance_fp32);
173}
Michalis Spyrou064add62018-11-01 18:14:27 +0000174TEST_SUITE_END() // W1x1
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000175
Michalis Spyrou064add62018-11-01 18:14:27 +0000176TEST_SUITE_END() // FP32
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100177
178TEST_SUITE(FP16)
179
180TEST_SUITE(W4x4)
Michalis Spyrou064add62018-11-01 18:14:27 +0000181FIXTURE_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 +0100182{
183 // Validate output
184 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
185}
Michalis Spyrou064add62018-11-01 18:14:27 +0000186TEST_SUITE_END() // W4x4
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100187
188TEST_SUITE(W3x3)
Michalis Spyrou064add62018-11-01 18:14:27 +0000189FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerFixture3x3<half>, framework::DatasetMode::PRECOMMIT, combine(combine(data3x3_precommit, framework::dataset::make("DataType", DataType::F16)),
190 data_layouts_dataset))
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100191{
192 // Validate output
193 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
194}
Michalis Spyrou064add62018-11-01 18:14:27 +0000195FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(combine(data3x3, framework::dataset::make("DataType", DataType::F16)),
196 data_layouts_dataset))
197{
198 // Validate output
199 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
200}
201TEST_SUITE_END() // W3x3
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100202
203TEST_SUITE(W1x1)
Michalis Spyrou064add62018-11-01 18:14:27 +0000204FIXTURE_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 +0100205{
206 // Validate output
207 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
208}
Michalis Spyrou064add62018-11-01 18:14:27 +0000209TEST_SUITE_END() // W1x1
Georgios Pinitas793f87d2018-05-18 20:08:58 +0100210
Michalis Spyrou064add62018-11-01 18:14:27 +0000211TEST_SUITE_END() // FP16
212TEST_SUITE_END() // Float
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000213
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100214template <typename T>
215using CLDeconvolutionLayerQuantizedFixture4x4 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 4, 4>;
216
217template <typename T>
218using CLDeconvolutionLayerQuantizedFixture3x3 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 3, 3>;
219
220template <typename T>
221using CLDeconvolutionLayerQuantizedFixture1x1 = DeconvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDeconvolutionLayer, T, 1, 1>;
222
223TEST_SUITE(Quantized)
224TEST_SUITE(QASYMM8)
225
226TEST_SUITE(W4x4)
Michalis Spyrou064add62018-11-01 18:14:27 +0000227FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture4x4<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data4x4, framework::dataset::make("DataType",
228 DataType::QASYMM8)),
229 data_layouts_dataset),
230 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100231{
232 // Validate output
233 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
234}
Michalis Spyrou064add62018-11-01 18:14:27 +0000235TEST_SUITE_END() // W4x4
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100236
237TEST_SUITE(W3x3)
Michalis Spyrou064add62018-11-01 18:14:27 +0000238FIXTURE_DATA_TEST_CASE(RunSmall, CLDeconvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data3x3_precommit, framework::dataset::make("DataType",
239 DataType::QASYMM8)),
240 data_layouts_dataset),
241 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100242{
243 // Validate output
244 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
245}
Michalis Spyrou064add62018-11-01 18:14:27 +0000246FIXTURE_DATA_TEST_CASE(RunLarge, CLDeconvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data3x3, framework::dataset::make("DataType",
247 DataType::QASYMM8)),
248 data_layouts_dataset),
249 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
250{
251 // Validate output
252 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
253}
254TEST_SUITE_END() // W3x3
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100255
256TEST_SUITE(W1x1)
Michalis Spyrou064add62018-11-01 18:14:27 +0000257FIXTURE_DATA_TEST_CASE(Run, CLDeconvolutionLayerQuantizedFixture1x1<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data1x1, framework::dataset::make("DataType",
258 DataType::QASYMM8)),
259 data_layouts_dataset),
260 framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255.f, 0))))
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100261{
262 // Validate output
263 validate(CLAccessor(_target), _reference, tolerance_qasymm8, tolerance_num);
264}
Michalis Spyrou064add62018-11-01 18:14:27 +0000265TEST_SUITE_END() // W1x1
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100266
Michalis Spyrou064add62018-11-01 18:14:27 +0000267TEST_SUITE_END() // QASYMM8
268TEST_SUITE_END() // Quantized
Michele Di Giorgio9fef38a2018-07-06 18:06:58 +0100269
Michalis Spyrou064add62018-11-01 18:14:27 +0000270TEST_SUITE_END() // DeconvolutionLayer
271TEST_SUITE_END() // CL
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000272} // namespace validation
273} // namespace test
274} // namespace arm_compute