blob: 4bfe4c8f429f880239f5e1d5aee44abc4cd6cc22 [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"
44#include "tests/validation/fixtures/WinogradLayerFixture.h"
45
46namespace arm_compute
47{
48namespace test
49{
50namespace validation
51{
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000052namespace
53{
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000054constexpr AbsoluteTolerance<float> tolerance_f32(0.001f);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +000055} // namespace
56
57using namespace arm_compute::misc::shape_calculator;
58
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000059TEST_SUITE(CL)
60TEST_SUITE(Winograd)
61
62TEST_SUITE(InputTransform)
63
64// *INDENT-OFF*
65// clang-format off
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000066DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000067 framework::dataset::make("InputInfo",{
68 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F16), // F16 not supported
69 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported
70 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Kernel size not supported
71 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Strides not supported
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000072 TensorInfo(TensorShape(53U, 33U, 4U), 1, DataType::F32), // Padding needed
73 TensorInfo(TensorShape(34U, 42U, 7U, 3U), 1, DataType::F32), // Padding needed
74 TensorInfo(TensorShape(31U, 37U, 37U), 1, DataType::F32) // Padding needed
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000075 }),
76 framework::dataset::make("OutputInfo", {
77 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F16),
78 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::QASYMM8),
79 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F32),
80 TensorInfo(TensorShape(5U, 1U, 16U, 3U), 1, DataType::F32),
81 TensorInfo(TensorShape(4U, 442U, 16U), 1, DataType::F32),
82 TensorInfo(TensorShape(7U, 320U, 16U, 3U), 1, DataType::F32),
83 TensorInfo(TensorShape(37U, 304U, 16U), 1, DataType::F32)
84 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000085 framework::dataset::make("WinogradInfo", {
86 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW),
87 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW),
88 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
89 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(2, 1, 1, 1), DataLayout::NCHW),
90 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW),
91 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(34U, 42U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW),
92 WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(31U, 37U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000093 })),
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000094 framework::dataset::make("Expected", { false, false, false, false, false, false, false })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000095 input_info, output_info, winograd_info, expected)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000096{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000097 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 +000098}
99// clang-format on
100// *INDENT-ON*
101
102using CLWinogradInputTransformFixture = WinogradInputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradInputTransform, float>;
103
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000104DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallWinogradInputTransformDataset(), datasets::LargeWinogradInputTransformDataset()),
105 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000106 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000107 shape_in, winograd_info, data_layout, data_type)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000108{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000109 TensorShape shape_out = compute_winograd_input_transform_shape(TensorInfo(shape_in, 1, data_type), winograd_info);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000110
111 // Create tensors
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000112 CLTensor in = create_tensor<CLTensor>(shape_in, data_type, 1, 0, QuantizationInfo(), data_layout);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000113 CLTensor out = create_tensor<CLTensor>(shape_out, data_type);
114
115 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
116 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
117
118 // Create and configure function
119 CLWinogradInputTransform winograd_input_transform;
120
121 // Configure the function
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000122 winograd_input_transform.configure(&in, &out, winograd_info);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000123}
124
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000125FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradInputTransformFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradInputTransformDataset(),
126 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
127 framework::dataset::make("DataType", { DataType::F32 })))
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000128{
Giorgio Arenafe5ef382018-04-17 10:14:10 +0100129 validate(CLAccessor(_target), _reference, tolerance_f32);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000130}
131
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000132FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradInputTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradInputTransformDataset(),
133 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
134 framework::dataset::make("DataType", { DataType::F32 })))
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000135{
Giorgio Arenafe5ef382018-04-17 10:14:10 +0100136 validate(CLAccessor(_target), _reference, tolerance_f32);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000137}
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000138TEST_SUITE_END() // InputTransform
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000139
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000140TEST_SUITE(FilterTransform)
141// *INDENT-OFF*
142// clang-format off
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000143DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000144 framework::dataset::make("InputInfo",{
145 TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F16), // F16 not supported
146 TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported
147 TensorInfo(TensorShape(5U, 5U, 5U, 3U), 1, DataType::F32), // Kernel size not supported
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000148 TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), // Output tile not supported
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000149 TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F32), // valid
150 TensorInfo(TensorShape(3U, 3U, 37U, 2U), 1, DataType::F32), // valid
151 TensorInfo(TensorShape(3U, 3U, 37U, 22U), 1, DataType::F32) // valid
152 }),
153 framework::dataset::make("OutputInfo", {
154 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F16),
155 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::QASYMM8),
156 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32),
157 TensorInfo(TensorShape(1U, 1U, 16U), 1, DataType::F32),
158 TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32),
159 TensorInfo(TensorShape(2U, 37U, 16U), 1, DataType::F32),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000160 TensorInfo(TensorShape(22U, 37U, 36U), 1, DataType::F32)
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000161 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000162 framework::dataset::make("WinogradInfo", {
163 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
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(3U, 3U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ),
167 WinogradInfo(Size2D(2U, 2U), 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(4U, 4U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ )
170 })),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000171 framework::dataset::make("Expected", { false, false, false, false, true, true, true })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000172 input_info, output_info, winograd_info, expected)
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000173{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000174 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 +0000175}
176// clang-format on
177// *INDENT-ON*
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000178
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000179using CLWinogradFilterTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradFilterTransformKernel, 0>;
180using CLWinogradFilterTransformFixture = WinogradFilterTransformValidationFixture<CLTensor, CLAccessor, CLWinogradFilterTransform, float>;
181
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000182DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(framework::dataset::concat(datasets::Small3x3Shapes(), datasets::Large3x3Shapes()),
183 framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
184 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000185 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000186 shape_a, output_tile, data_layout, data_type)
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000187{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000188 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 +0000189
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000190 TensorShape shape_b = compute_winograd_filter_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000191
192 // Create tensors
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000193 CLTensor a = create_tensor<CLTensor>(shape_a, data_type, 1, 0, QuantizationInfo(), data_layout);
194 CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, 0, QuantizationInfo(), data_layout);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000195
196 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
197 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
198
199 // Create and configure function
200 CLWinogradFilterTransform winograd_filter_transform;
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000201 winograd_filter_transform.configure(&a, &b, winograd_info);
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000202}
203
Giorgio Arena9373c8b2018-04-11 19:07:17 +0100204FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::ALL,
205 combine(combine(framework::dataset::concat(framework::dataset::concat(combine(datasets::Small3x3Shapes(), framework::dataset::make("OutputTile", Size2D(2U, 2U))), combine(datasets::Small3x3Shapes(),
206 framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
207 combine(datasets::Small5x5Shapes(), framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
208 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
209 framework::dataset::make("DataType", { DataType::F32 })))
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000210{
211 // Validate output
212 validate(CLAccessor(_target), _reference, tolerance_f32);
213}
214
Giorgio Arena9373c8b2018-04-11 19:07:17 +0100215FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY,
216 combine(combine(framework::dataset::concat(framework::dataset::concat(combine(datasets::Large3x3Shapes(), framework::dataset::make("OutputTile", Size2D(2U, 2U))), combine(datasets::Large3x3Shapes(),
217 framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
218 combine(datasets::Large5x5Shapes(), framework::dataset::make("OutputTile", Size2D(4U, 4U)))),
219 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
220 framework::dataset::make("DataType", { DataType::F32 })))
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000221{
222 // Validate output
223 validate(CLAccessor(_target), _reference, tolerance_f32);
224}
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000225
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000226TEST_SUITE_END() // FilterTransform
227
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000228TEST_SUITE(OutputTransform)
229// *INDENT-OFF*
230// clang-format off
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000231DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000232 framework::dataset::make("InputInfo",{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000233 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F16), // F16 not supported
234 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::QASYMM8), // QASYMM8 not supported
235 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Kernel size not supported
236 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Valid
237 TensorInfo(TensorShape(13U, 108U, 16U, 4U), 1, DataType::F32), // Padding needed
238 TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Valid
239 TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32) // Wrong WinogradInfo
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000240 }),
241 framework::dataset::make("BiasInfo", {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000242 TensorInfo(TensorShape(512U), 1, DataType::F16),
243 TensorInfo(TensorShape(512U), 1, DataType::QASYMM8),
244 TensorInfo(TensorShape(512U), 1, DataType::F32),
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000245 TensorInfo(TensorShape(512U), 1, DataType::F32),
246 TensorInfo(TensorShape(13U), 1, DataType::F32),
247 TensorInfo(TensorShape(7U), 1, DataType::F32),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000248 TensorInfo(TensorShape(7U), 1, DataType::F32)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000249 })),
250 framework::dataset::make("OutputInfo", {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000251 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F16),
252 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::QASYMM8),
253 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32),
254 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32),
255 TensorInfo(TensorShape(17U, 23U, 13U, 4U), 1, DataType::F32),
256 TensorInfo(TensorShape(8U, 10U, 7U, 7U), 1, DataType::F32),
257 TensorInfo(TensorShape(7U, 9U, 7U, 7U), 1, DataType::F32)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000258 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000259 framework::dataset::make("WinogradInfo", {
260 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
261 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
262 WinogradInfo(Size2D(2U, 2U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
263 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
264 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(17U, 23U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
265 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
266 WinogradInfo(Size2D(2U, 3U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW),
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000267 })),
268 framework::dataset::make("Expected", { false, false, false, true, false, true, false })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000269 input_info, bias_info, output_info, winograd_info, expected)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000270{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000271 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 +0000272}
273// clang-format on
274// *INDENT-ON*
275
276using CLWinogradOutputTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradOutputTransformKernel, 0>;
277using CLWinogradOutputTransformFixture = WinogradOutputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradOutputTransform, float>;
278
279DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallWinogradOutputTransformDataset(), datasets::LargeWinogradOutputTransformDataset()),
280 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000281 shape_a, winograd_info, data_type)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000282{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000283 TensorShape shape_b = compute_winograd_output_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000284
285 // Create tensors
286 CLTensor a = create_tensor<CLTensor>(shape_a, data_type);
287 CLTensor b = create_tensor<CLTensor>(shape_b, data_type);
288
289 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
290 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
291
292 // Create and configure function
293 CLWinogradOutputTransform winograd_output_transform;
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000294 winograd_output_transform.configure(&a, nullptr, &b, winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000295}
296
297FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradOutputTransformFixture, framework::DatasetMode::ALL, combine(datasets::SmallWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
298{
299 // Validate output
300 validate(CLAccessor(_target), _reference, tolerance_f32);
301}
302
303FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradOutputTransformFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
304{
305 // Validate output
306 validate(CLAccessor(_target), _reference, tolerance_f32);
307}
308
309TEST_SUITE_END() // OutputTransform
310
311TEST_SUITE(ConvolutionLayer)
312// *INDENT-OFF*
313// clang-format off
314DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
315 framework::dataset::make("InputInfo", {
316 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F16), // FP16 not supported
317 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Datatype mismatch
318 TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Stride y not supported
319 TensorInfo(TensorShape(16U, 16U, 8U), 1, DataType::F32), // Padding needed
320 TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) // Kernel size not supported
321 }),
322 framework::dataset::make("WeightsInfo", {
323 TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::F32),
324 TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::QASYMM8),
325 TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
326 TensorInfo(TensorShape(3U, 3U, 8U, 16U), 1, DataType::F32),
327 TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16)
328 })),
329 framework::dataset::make("BiasesInfo", {
330 TensorInfo(TensorShape(19U), 1, DataType::F32),
331 TensorInfo(TensorShape(19U), 1, DataType::F32),
332 TensorInfo(TensorShape(21U), 1, DataType::F32),
333 TensorInfo(TensorShape(16U), 1, DataType::F32),
334 TensorInfo(TensorShape(16U), 1, DataType::F32)
335 })),
336 framework::dataset::make("OutputInfo", {
337 TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
338 TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
339 TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
340 TensorInfo(TensorShape(16U, 16U, 16U), 1, DataType::F32),
341 TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32)
342 })),
343 framework::dataset::make("ConvInfo", {
344 PadStrideInfo(1, 1, 1, 1),
345 PadStrideInfo(1, 1, 1, 1),
346 PadStrideInfo(1, 2, 0, 0),
347 PadStrideInfo(1, 1, 1, 1),
348 PadStrideInfo(1, 1, 1, 0)
349 })),
350 framework::dataset::make("Expected", { false, false, false, false, false })),
351 input_info, weights_info, bias_info, output_info, conv_info, expected)
352{
353 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);
354}
355// clang-format on
356// *INDENT-ON*
357
358using CLWinogradConvolutionLayerFixture = WinogradConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLWinogradConvolutionLayer, float>;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000359FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(),
360 framework::dataset::make("DataType", { DataType::F32 })),
361 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000362{
363 // Validate output
364 validate(CLAccessor(_target), _reference, tolerance_f32);
365}
366
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000367FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(),
368 framework::dataset::make("DataType", { DataType::F32 })),
369 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000370{
371 // Validate output
372 validate(CLAccessor(_target), _reference, tolerance_f32);
373}
374TEST_SUITE_END() // ConvolutionLayer
375
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000376TEST_SUITE_END() // Winograd
377TEST_SUITE_END() // CL
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000378} // namespace validation
379} // namespace test
380} // namespace arm_compute