blob: d892c9f77feda0676ef32929817cfe2005a55a86 [file] [log] [blame]
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
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,
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000022 * SOFTWARE.
23 */
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000024#include "arm_compute/core/CL/kernels/CLWinogradFilterTransformKernel.h"
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000025#include "arm_compute/core/CL/kernels/CLWinogradOutputTransformKernel.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000026#include "arm_compute/core/Types.h"
27#include "arm_compute/core/utils/misc/ShapeCalculator.h"
28#include "arm_compute/runtime/CL/CLTensor.h"
29#include "arm_compute/runtime/CL/CLTensorAllocator.h"
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000030#include "arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000031#include "arm_compute/runtime/CL/functions/CLWinogradInputTransform.h"
32#include "tests/CL/CLAccessor.h"
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000033#include "tests/CL/Helper.h"
34#include "tests/PaddingCalculator.h"
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000035#include "tests/datasets/LargeConvolutionLayerDataset.h"
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000036#include "tests/datasets/ShapeDatasets.h"
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000037#include "tests/datasets/SmallConvolutionLayerDataset.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000038#include "tests/datasets/WinogradInputTransformDataset.h"
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000039#include "tests/datasets/WinogradOutputTransformDataset.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000040#include "tests/framework/Asserts.h"
41#include "tests/framework/Macros.h"
42#include "tests/framework/datasets/Datasets.h"
43#include "tests/validation/Validation.h"
Georgios Pinitas9fb11592018-04-26 20:34:58 +010044#include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000045
46namespace arm_compute
47{
48namespace test
49{
50namespace validation
51{
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000052namespace
53{
Gian Marco Iodice2213d4b2018-04-27 10:39:06 +010054constexpr AbsoluteTolerance<float> tolerance_f32(0.0001f);
55constexpr AbsoluteTolerance<float> tolerance_fast_math_f32(0.1f);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000056} // namespace
57
58using namespace arm_compute::misc::shape_calculator;
59
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000060TEST_SUITE(CL)
61TEST_SUITE(Winograd)
62
63TEST_SUITE(InputTransform)
64
65// *INDENT-OFF*
66// clang-format off
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000067DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000068 framework::dataset::make("InputInfo",{
69 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F16), // F16 not supported
70 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported
71 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Kernel size not supported
72 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Strides not supported
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000073 TensorInfo(TensorShape(53U, 33U, 4U), 1, DataType::F32), // Padding needed
74 TensorInfo(TensorShape(34U, 42U, 7U, 3U), 1, DataType::F32), // Padding needed
75 TensorInfo(TensorShape(31U, 37U, 37U), 1, DataType::F32) // Padding needed
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000076 }),
77 framework::dataset::make("OutputInfo", {
78 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F16),
79 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::QASYMM8),
80 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F32),
81 TensorInfo(TensorShape(5U, 1U, 16U, 3U), 1, DataType::F32),
82 TensorInfo(TensorShape(4U, 442U, 16U), 1, DataType::F32),
83 TensorInfo(TensorShape(7U, 320U, 16U, 3U), 1, DataType::F32),
84 TensorInfo(TensorShape(37U, 304U, 16U), 1, DataType::F32)
85 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000086 framework::dataset::make("WinogradInfo", {
87 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW),
88 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW),
89 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
90 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(2, 1, 1, 1), DataLayout::NCHW),
91 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW),
92 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(34U, 42U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW),
93 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(31U, 37U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000094 })),
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000095 framework::dataset::make("Expected", { false, false, false, false, false, false, false })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000096 input_info, output_info, winograd_info, expected)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000097{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000098 ARM_COMPUTE_EXPECT(bool(CLWinogradInputTransform::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), winograd_info)) == expected, framework::LogLevel::ERRORS);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000099}
100// clang-format on
101// *INDENT-ON*
102
103using CLWinogradInputTransformFixture = WinogradInputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradInputTransform, float>;
104
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000105DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallWinogradInputTransformDataset(), datasets::LargeWinogradInputTransformDataset()),
106 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000107 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000108 shape_in, winograd_info, data_layout, data_type)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000109{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000110 TensorShape shape_out = compute_winograd_input_transform_shape(TensorInfo(shape_in, 1, data_type), winograd_info);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000111
112 // Create tensors
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000113 CLTensor in = create_tensor<CLTensor>(shape_in, data_type, 1, 0, QuantizationInfo(), data_layout);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000114 CLTensor out = create_tensor<CLTensor>(shape_out, data_type);
115
116 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
117 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
118
119 // Create and configure function
120 CLWinogradInputTransform winograd_input_transform;
121
122 // Configure the function
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000123 winograd_input_transform.configure(&in, &out, winograd_info);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000124}
125
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000126FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradInputTransformFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradInputTransformDataset(),
127 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
128 framework::dataset::make("DataType", { DataType::F32 })))
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000129{
Giorgio Arenafe5ef382018-04-17 10:14:10 +0100130 validate(CLAccessor(_target), _reference, tolerance_f32);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000131}
132
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000133FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradInputTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradInputTransformDataset(),
134 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
135 framework::dataset::make("DataType", { DataType::F32 })))
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000136{
Giorgio Arenafe5ef382018-04-17 10:14:10 +0100137 validate(CLAccessor(_target), _reference, tolerance_f32);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000138}
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000139TEST_SUITE_END() // InputTransform
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000140
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000141TEST_SUITE(FilterTransform)
142// *INDENT-OFF*
143// clang-format off
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000144DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000145 framework::dataset::make("InputInfo",{
146 TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F16), // F16 not supported
147 TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported
148 TensorInfo(TensorShape(5U, 5U, 5U, 3U), 1, DataType::F32), // Kernel size not supported
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000149 TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), // Output tile not supported
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000150 TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F32), // valid
151 TensorInfo(TensorShape(3U, 3U, 37U, 2U), 1, DataType::F32), // valid
152 TensorInfo(TensorShape(3U, 3U, 37U, 22U), 1, DataType::F32) // valid
153 }),
154 framework::dataset::make("OutputInfo", {
155 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F16),
156 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::QASYMM8),
157 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32),
158 TensorInfo(TensorShape(1U, 1U, 16U), 1, DataType::F32),
159 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32),
160 TensorInfo(TensorShape(2U, 37U, 16U), 1, DataType::F32),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000161 TensorInfo(TensorShape(22U, 37U, 36U), 1, DataType::F32)
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000162 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000163 framework::dataset::make("WinogradInfo", {
164 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
165 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
166 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
167 WinogradInfo(Size2D(3U, 3U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
168 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
169 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
170 WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ )
171 })),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000172 framework::dataset::make("Expected", { false, false, false, false, true, true, true })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000173 input_info, output_info, winograd_info, expected)
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000174{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000175 ARM_COMPUTE_EXPECT(bool(CLWinogradFilterTransformKernel::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), winograd_info)) == expected, framework::LogLevel::ERRORS);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000176}
177// clang-format on
178// *INDENT-ON*
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000179
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000180using CLWinogradFilterTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradFilterTransformKernel, 0>;
181using CLWinogradFilterTransformFixture = WinogradFilterTransformValidationFixture<CLTensor, CLAccessor, CLWinogradFilterTransform, float>;
182
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000183DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(framework::dataset::concat(datasets::Small3x3Shapes(), datasets::Large3x3Shapes()),
184 framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
185 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000186 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000187 shape_a, output_tile, data_layout, data_type)
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000188{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000189 WinogradInfo winograd_info(output_tile, Size2D(shape_a[0], shape_a[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000190
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000191 TensorShape shape_b = compute_winograd_filter_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000192
193 // Create tensors
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000194 CLTensor a = create_tensor<CLTensor>(shape_a, data_type, 1, 0, QuantizationInfo(), data_layout);
195 CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, 0, QuantizationInfo(), data_layout);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000196
197 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
198 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
199
200 // Create and configure function
201 CLWinogradFilterTransform winograd_filter_transform;
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000202 winograd_filter_transform.configure(&a, &b, winograd_info);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000203}
204
Giorgio Arena9373c8b2018-04-11 19:07:17 +0100205FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::ALL,
206 combine(combine(framework::dataset::concat(framework::dataset::concat(combine(datasets::Small3x3Shapes(), framework::dataset::make("OutputTile", Size2D(2U, 2U))), combine(datasets::Small3x3Shapes(),
207 framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
208 combine(datasets::Small5x5Shapes(), framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
209 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
210 framework::dataset::make("DataType", { DataType::F32 })))
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000211{
212 // Validate output
213 validate(CLAccessor(_target), _reference, tolerance_f32);
214}
215
Giorgio Arena9373c8b2018-04-11 19:07:17 +0100216FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY,
217 combine(combine(framework::dataset::concat(framework::dataset::concat(combine(datasets::Large3x3Shapes(), framework::dataset::make("OutputTile", Size2D(2U, 2U))), combine(datasets::Large3x3Shapes(),
218 framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
219 combine(datasets::Large5x5Shapes(), framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
220 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
221 framework::dataset::make("DataType", { DataType::F32 })))
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000222{
223 // Validate output
224 validate(CLAccessor(_target), _reference, tolerance_f32);
225}
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000226
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000227TEST_SUITE_END() // FilterTransform
228
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000229TEST_SUITE(OutputTransform)
230// *INDENT-OFF*
231// clang-format off
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000232DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000233 framework::dataset::make("InputInfo",{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000234 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F16), // F16 not supported
235 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::QASYMM8), // QASYMM8 not supported
236 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Kernel size not supported
237 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Valid
238 TensorInfo(TensorShape(13U, 108U, 16U, 4U), 1, DataType::F32), // Padding needed
239 TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Valid
Gian Marco Iodicee52a3002018-04-11 15:59:10 +0100240 TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Wrong WinogradInfo
241 TensorInfo(TensorShape(7U, 256U, 36U, 3U), 1, DataType::F32), // Valid
242 TensorInfo(TensorShape(7U, 256U, 16U, 3U), 1, DataType::F32) // Wrong number of batches
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000243 }),
244 framework::dataset::make("BiasInfo", {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000245 TensorInfo(TensorShape(512U), 1, DataType::F16),
246 TensorInfo(TensorShape(512U), 1, DataType::QASYMM8),
247 TensorInfo(TensorShape(512U), 1, DataType::F32),
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000248 TensorInfo(TensorShape(512U), 1, DataType::F32),
249 TensorInfo(TensorShape(13U), 1, DataType::F32),
250 TensorInfo(TensorShape(7U), 1, DataType::F32),
Gian Marco Iodicee52a3002018-04-11 15:59:10 +0100251 TensorInfo(TensorShape(7U), 1, DataType::F32),
252 TensorInfo(TensorShape(7U), 1, DataType::F32),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000253 TensorInfo(TensorShape(7U), 1, DataType::F32)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000254 })),
255 framework::dataset::make("OutputInfo", {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000256 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F16),
257 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::QASYMM8),
258 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32),
259 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32),
260 TensorInfo(TensorShape(17U, 23U, 13U, 4U), 1, DataType::F32),
261 TensorInfo(TensorShape(8U, 10U, 7U, 7U), 1, DataType::F32),
Gian Marco Iodicee52a3002018-04-11 15:59:10 +0100262 TensorInfo(TensorShape(7U, 9U, 7U, 7U), 1, DataType::F32),
263 TensorInfo(TensorShape(64U, 64U, 7U, 3U), 1, DataType::F32),
264 TensorInfo(TensorShape(64U, 64U, 7U, 3U), 1, DataType::F32)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000265 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000266 framework::dataset::make("WinogradInfo", {
267 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
268 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
269 WinogradInfo(Size2D(2U, 2U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
270 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
271 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(17U, 23U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
272 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
273 WinogradInfo(Size2D(2U, 3U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW),
Gian Marco Iodicee52a3002018-04-11 15:59:10 +0100274 WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D(64U, 64U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
275 WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D(64U, 64U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000276 })),
Gian Marco Iodicee52a3002018-04-11 15:59:10 +0100277 framework::dataset::make("Expected", { false, false, false, true, false, true, false, true, false })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000278 input_info, bias_info, output_info, winograd_info, expected)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000279{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000280 ARM_COMPUTE_EXPECT(bool(CLWinogradOutputTransformKernel::validate(&input_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), winograd_info)) == expected, framework::LogLevel::ERRORS);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000281}
282// clang-format on
283// *INDENT-ON*
284
285using CLWinogradOutputTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradOutputTransformKernel, 0>;
286using CLWinogradOutputTransformFixture = WinogradOutputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradOutputTransform, float>;
287
288DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallWinogradOutputTransformDataset(), datasets::LargeWinogradOutputTransformDataset()),
289 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000290 shape_a, winograd_info, data_type)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000291{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000292 TensorShape shape_b = compute_winograd_output_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000293
294 // Create tensors
295 CLTensor a = create_tensor<CLTensor>(shape_a, data_type);
296 CLTensor b = create_tensor<CLTensor>(shape_b, data_type);
297
298 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
299 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
300
301 // Create and configure function
302 CLWinogradOutputTransform winograd_output_transform;
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000303 winograd_output_transform.configure(&a, nullptr, &b, winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000304}
305
306FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradOutputTransformFixture, framework::DatasetMode::ALL, combine(datasets::SmallWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
307{
308 // Validate output
309 validate(CLAccessor(_target), _reference, tolerance_f32);
310}
311
312FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradOutputTransformFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
313{
314 // Validate output
315 validate(CLAccessor(_target), _reference, tolerance_f32);
316}
317
318TEST_SUITE_END() // OutputTransform
319
320TEST_SUITE(ConvolutionLayer)
321// *INDENT-OFF*
322// clang-format off
323DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
324 framework::dataset::make("InputInfo", {
325 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F16), // FP16 not supported
326 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Datatype mismatch
327 TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Stride y not supported
328 TensorInfo(TensorShape(16U, 16U, 8U), 1, DataType::F32), // Padding needed
329 TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) // Kernel size not supported
330 }),
331 framework::dataset::make("WeightsInfo", {
332 TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::F32),
333 TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::QASYMM8),
334 TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
335 TensorInfo(TensorShape(3U, 3U, 8U, 16U), 1, DataType::F32),
336 TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16)
337 })),
338 framework::dataset::make("BiasesInfo", {
339 TensorInfo(TensorShape(19U), 1, DataType::F32),
340 TensorInfo(TensorShape(19U), 1, DataType::F32),
341 TensorInfo(TensorShape(21U), 1, DataType::F32),
342 TensorInfo(TensorShape(16U), 1, DataType::F32),
343 TensorInfo(TensorShape(16U), 1, DataType::F32)
344 })),
345 framework::dataset::make("OutputInfo", {
346 TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
347 TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
348 TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
349 TensorInfo(TensorShape(16U, 16U, 16U), 1, DataType::F32),
350 TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32)
351 })),
352 framework::dataset::make("ConvInfo", {
353 PadStrideInfo(1, 1, 1, 1),
354 PadStrideInfo(1, 1, 1, 1),
355 PadStrideInfo(1, 2, 0, 0),
356 PadStrideInfo(1, 1, 1, 1),
357 PadStrideInfo(1, 1, 1, 0)
358 })),
359 framework::dataset::make("Expected", { false, false, false, false, false })),
360 input_info, weights_info, bias_info, output_info, conv_info, expected)
361{
362 ARM_COMPUTE_EXPECT(bool(CLWinogradConvolutionLayer::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), conv_info)) == expected, framework::LogLevel::ERRORS);
363}
364// clang-format on
365// *INDENT-ON*
366
367using CLWinogradConvolutionLayerFixture = WinogradConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLWinogradConvolutionLayer, float>;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000368FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(),
369 framework::dataset::make("DataType", { DataType::F32 })),
370 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000371{
372 // Validate output
373 validate(CLAccessor(_target), _reference, tolerance_f32);
374}
375
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000376FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(),
377 framework::dataset::make("DataType", { DataType::F32 })),
378 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000379{
380 // Validate output
381 validate(CLAccessor(_target), _reference, tolerance_f32);
382}
Gian Marco Iodice2213d4b2018-04-27 10:39:06 +0100383TEST_SUITE(EnableFastMath)
384using CLWinogradConvolutionLayerFastMathFixture = WinogradConvolutionLayerFastMathValidationFixture<CLTensor, CLAccessor, CLWinogradConvolutionLayer, float>;
385FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::PRECOMMIT,
386 combine(combine(framework::dataset::concat(datasets::SmallWinogradConvolutionLayer3x3Dataset(), datasets::SmallWinogradConvolutionLayer5x5Dataset()),
387 framework::dataset::make("DataType", { DataType::F32 })),
388 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
389{
390 // Validate output
391 validate(CLAccessor(_target), _reference, tolerance_fast_math_f32);
392}
393
394FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::NIGHTLY,
395 combine(combine(framework::dataset::concat(datasets::LargeWinogradConvolutionLayer3x3Dataset(), datasets::LargeWinogradConvolutionLayer5x5Dataset()),
396 framework::dataset::make("DataType", { DataType::F32 })),
397 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
398{
399 // Validate output
400 validate(CLAccessor(_target), _reference, tolerance_fast_math_f32);
401}
402
403TEST_SUITE_END() // EnableFastMath
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000404TEST_SUITE_END() // ConvolutionLayer
405
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000406TEST_SUITE_END() // Winograd
407TEST_SUITE_END() // CL
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000408} // namespace validation
409} // namespace test
410} // namespace arm_compute