blob: 8fa5826470097f126f4fc1dee8c3e6ec7fb608ab [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{
129 validate(CLAccessor(_target), _reference);
130}
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{
136 validate(CLAccessor(_target), _reference);
137}
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
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000204FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::ALL, combine(combine(combine(datasets::Small3x3Shapes(),
205 framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
206 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000207 framework::dataset::make("DataType", { DataType::F32 })))
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000208{
209 // Validate output
210 validate(CLAccessor(_target), _reference, tolerance_f32);
211}
212
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000213FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large3x3Shapes(),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000214 framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000215 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Giorgio Arena2d9de0a2018-03-15 17:58:20 +0000216 framework::dataset::make("DataType", { DataType::F32 })))
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000217{
218 // Validate output
219 validate(CLAccessor(_target), _reference, tolerance_f32);
220}
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000221
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000222TEST_SUITE_END() // FilterTransform
223
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000224TEST_SUITE(OutputTransform)
225// *INDENT-OFF*
226// clang-format off
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000227DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000228 framework::dataset::make("InputInfo",{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000229 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F16), // F16 not supported
230 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::QASYMM8), // QASYMM8 not supported
231 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Kernel size not supported
232 TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Valid
233 TensorInfo(TensorShape(13U, 108U, 16U, 4U), 1, DataType::F32), // Padding needed
234 TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Valid
235 TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32) // Wrong WinogradInfo
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000236 }),
237 framework::dataset::make("BiasInfo", {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000238 TensorInfo(TensorShape(512U), 1, DataType::F16),
239 TensorInfo(TensorShape(512U), 1, DataType::QASYMM8),
240 TensorInfo(TensorShape(512U), 1, DataType::F32),
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000241 TensorInfo(TensorShape(512U), 1, DataType::F32),
242 TensorInfo(TensorShape(13U), 1, DataType::F32),
243 TensorInfo(TensorShape(7U), 1, DataType::F32),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000244 TensorInfo(TensorShape(7U), 1, DataType::F32)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000245 })),
246 framework::dataset::make("OutputInfo", {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000247 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F16),
248 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::QASYMM8),
249 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32),
250 TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32),
251 TensorInfo(TensorShape(17U, 23U, 13U, 4U), 1, DataType::F32),
252 TensorInfo(TensorShape(8U, 10U, 7U, 7U), 1, DataType::F32),
253 TensorInfo(TensorShape(7U, 9U, 7U, 7U), 1, DataType::F32)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000254 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000255 framework::dataset::make("WinogradInfo", {
256 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
257 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
258 WinogradInfo(Size2D(2U, 2U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
259 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
260 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(17U, 23U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
261 WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW),
262 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 +0000263 })),
264 framework::dataset::make("Expected", { false, false, false, true, false, true, false })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000265 input_info, bias_info, output_info, winograd_info, expected)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000266{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000267 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 +0000268}
269// clang-format on
270// *INDENT-ON*
271
272using CLWinogradOutputTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradOutputTransformKernel, 0>;
273using CLWinogradOutputTransformFixture = WinogradOutputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradOutputTransform, float>;
274
275DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallWinogradOutputTransformDataset(), datasets::LargeWinogradOutputTransformDataset()),
276 framework::dataset::make("DataType", { DataType::F32 })),
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000277 shape_a, winograd_info, data_type)
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000278{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000279 TensorShape shape_b = compute_winograd_output_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000280
281 // Create tensors
282 CLTensor a = create_tensor<CLTensor>(shape_a, data_type);
283 CLTensor b = create_tensor<CLTensor>(shape_b, data_type);
284
285 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
286 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
287
288 // Create and configure function
289 CLWinogradOutputTransform winograd_output_transform;
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000290 winograd_output_transform.configure(&a, nullptr, &b, winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000291}
292
293FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradOutputTransformFixture, framework::DatasetMode::ALL, combine(datasets::SmallWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
294{
295 // Validate output
296 validate(CLAccessor(_target), _reference, tolerance_f32);
297}
298
299FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradOutputTransformFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
300{
301 // Validate output
302 validate(CLAccessor(_target), _reference, tolerance_f32);
303}
304
305TEST_SUITE_END() // OutputTransform
306
307TEST_SUITE(ConvolutionLayer)
308// *INDENT-OFF*
309// clang-format off
310DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
311 framework::dataset::make("InputInfo", {
312 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F16), // FP16 not supported
313 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Datatype mismatch
314 TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Stride y not supported
315 TensorInfo(TensorShape(16U, 16U, 8U), 1, DataType::F32), // Padding needed
316 TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) // Kernel size not supported
317 }),
318 framework::dataset::make("WeightsInfo", {
319 TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::F32),
320 TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::QASYMM8),
321 TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
322 TensorInfo(TensorShape(3U, 3U, 8U, 16U), 1, DataType::F32),
323 TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16)
324 })),
325 framework::dataset::make("BiasesInfo", {
326 TensorInfo(TensorShape(19U), 1, DataType::F32),
327 TensorInfo(TensorShape(19U), 1, DataType::F32),
328 TensorInfo(TensorShape(21U), 1, DataType::F32),
329 TensorInfo(TensorShape(16U), 1, DataType::F32),
330 TensorInfo(TensorShape(16U), 1, DataType::F32)
331 })),
332 framework::dataset::make("OutputInfo", {
333 TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
334 TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
335 TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
336 TensorInfo(TensorShape(16U, 16U, 16U), 1, DataType::F32),
337 TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32)
338 })),
339 framework::dataset::make("ConvInfo", {
340 PadStrideInfo(1, 1, 1, 1),
341 PadStrideInfo(1, 1, 1, 1),
342 PadStrideInfo(1, 2, 0, 0),
343 PadStrideInfo(1, 1, 1, 1),
344 PadStrideInfo(1, 1, 1, 0)
345 })),
346 framework::dataset::make("Expected", { false, false, false, false, false })),
347 input_info, weights_info, bias_info, output_info, conv_info, expected)
348{
349 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);
350}
351// clang-format on
352// *INDENT-ON*
353
354using CLWinogradConvolutionLayerFixture = WinogradConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLWinogradConvolutionLayer, float>;
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000355FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(),
356 framework::dataset::make("DataType", { DataType::F32 })),
357 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000358{
359 // Validate output
360 validate(CLAccessor(_target), _reference, tolerance_f32);
361}
362
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000363FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(),
364 framework::dataset::make("DataType", { DataType::F32 })),
365 framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })))
Gian Marco Iodiced2fab732018-03-02 11:18:12 +0000366{
367 // Validate output
368 validate(CLAccessor(_target), _reference, tolerance_f32);
369}
370TEST_SUITE_END() // ConvolutionLayer
371
Gian Marco Iodice7e4b2392018-02-22 16:17:20 +0000372TEST_SUITE_END() // Winograd
373TEST_SUITE_END() // CL
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000374} // namespace validation
375} // namespace test
376} // namespace arm_compute