blob: 432b3b239a2531581e9eea8779fbf777979a3dab [file] [log] [blame]
Pablo Tello4a626a72018-04-04 10:01:14 +01001/*
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,
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/CLIm2ColKernel.h"
25#include "arm_compute/core/Types.h"
26#include "tests/CL/Helper.h"
27
28#include "tests/CL/CLAccessor.h"
29#include "tests/datasets/ShapeDatasets.h"
30#include "tests/framework/Asserts.h"
31#include "tests/framework/Macros.h"
32#include "tests/framework/datasets/Datasets.h"
33#include "tests/validation/Validation.h"
34#include "tests/validation/fixtures/Im2ColFixture.h"
35
36namespace arm_compute
37{
38namespace test
39{
40namespace validation
41{
42namespace
43{
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010044// *INDENT-OFF*
45// clang-format off
46const auto conv_filter_sizes = framework::dataset::make("KernelDims", { Size2D(3U, 3U),
47 Size2D(5U, 5U),
48 Size2D(3U, 1U),
49 Size2D(1U, 3U),
50 Size2D(5U, 3U),
51 Size2D(1U, 1U),
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +000052 Size2D(9U, 9U),
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010053 Size2D(11U, 11U)} );
54const auto padstrides = framework::dataset::make("PadStride", { PadStrideInfo(1U, 1U, 0U, 0U),
55 PadStrideInfo(1U, 1U, 1U, 1U),
56 PadStrideInfo(2U, 2U, 0U, 2U) });
Giorgio Arena0f170392018-07-18 16:13:12 +010057const auto conv_args = combine(combine(combine(combine(conv_filter_sizes, padstrides),
58 framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))),
59 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
60 framework::dataset::make("NumGroups", { 1 }));
61const auto grouped_args = combine(combine(combine(combine(conv_filter_sizes, padstrides),
62 framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))),
63 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
64 framework::dataset::make("NumGroups", { 2, 3, 4 }));
Pablo Tello4a626a72018-04-04 10:01:14 +010065
66} // namespace
67TEST_SUITE(CL)
68TEST_SUITE(Im2Col)
69
70using CLIm2Col = CLSynthetizeFunction<CLIm2ColKernel>;
71
Pablo Tello4a626a72018-04-04 10:01:14 +010072DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
73 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::U8), // Unsupported data type
74 TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::F32), // Mismatching data type
Pablo Tello4a626a72018-04-04 10:01:14 +010075 TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::QASYMM8), // Bias not supported with QASYMM8
Pablo Tello4a626a72018-04-04 10:01:14 +010076 TensorInfo(TensorShape(10U, 12U, 2U, 2U), 1, DataType::QASYMM8),
77 }),
78 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::F16),
79 TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::F16),
Pablo Tello4a626a72018-04-04 10:01:14 +010080 TensorInfo(TensorShape(3U, 3U, 10U, 2U), 1, DataType::QASYMM8),
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010081 TensorInfo(TensorShape(18U, 80U, 2U, 1U), 1, DataType::QASYMM8),
Pablo Tello4a626a72018-04-04 10:01:14 +010082 })),
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010083 framework::dataset::make("HasBias", { true, true, true, false })),
84 framework::dataset::make("Expected", { false, false, false, true })),
Pablo Tello4a626a72018-04-04 10:01:14 +010085 input_info, output_info, has_bias, expected)
86{
87
88 bool status = bool(CLIm2Col::validate(&input_info, &output_info, Size2D(3U, 3U), PadStrideInfo(), has_bias));
89 ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS);
90}
91// clang-format on
92// *INDENT-ON*
93
94template <typename T>
Gian Marco Iodice597a8562018-08-01 15:06:06 +010095using CLIm2ColFixture = Im2ColValidationFixture<CLTensor, CLAccessor, CLIm2Col, T, true>;
Pablo Tello4a626a72018-04-04 10:01:14 +010096TEST_SUITE(Float)
97TEST_SUITE(FP32)
Giorgio Arenafb629082018-08-20 18:03:27 +010098FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)),
99 conv_args))
Pablo Tello4a626a72018-04-04 10:01:14 +0100100{
101 // Validate output
102 validate(CLAccessor(_target), _reference);
103}
Pablo Tello4a626a72018-04-04 10:01:14 +0100104
Giorgio Arenafb629082018-08-20 18:03:27 +0100105FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)),
106 conv_args))
Pablo Tello4a626a72018-04-04 10:01:14 +0100107{
108 // Validate output
109 validate(CLAccessor(_target), _reference);
110}
Giorgio Arena0f170392018-07-18 16:13:12 +0100111TEST_SUITE_END()
Pablo Tello4a626a72018-04-04 10:01:14 +0100112
113TEST_SUITE(FP16)
Giorgio Arenafb629082018-08-20 18:03:27 +0100114FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<half>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)),
115 conv_args))
Pablo Tello4a626a72018-04-04 10:01:14 +0100116{
117 // Validate output
118 validate(CLAccessor(_target), _reference);
119}
Giorgio Arenafb629082018-08-20 18:03:27 +0100120FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16)),
121 conv_args))
Pablo Tello4a626a72018-04-04 10:01:14 +0100122{
123 // Validate output
124 validate(CLAccessor(_target), _reference);
125}
126TEST_SUITE_END()
Pablo Tello4a626a72018-04-04 10:01:14 +0100127TEST_SUITE_END()
128
129TEST_SUITE(QASYMM8)
Giorgio Arenafb629082018-08-20 18:03:27 +0100130FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::QASYMM8)),
131 conv_args))
Pablo Tello4a626a72018-04-04 10:01:14 +0100132{
133 // Validate output
134 validate(CLAccessor(_target), _reference);
135}
Giorgio Arenafb629082018-08-20 18:03:27 +0100136FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::QASYMM8)),
137 conv_args))
Pablo Tello4a626a72018-04-04 10:01:14 +0100138{
139 // Validate output
140 validate(CLAccessor(_target), _reference);
141}
142TEST_SUITE_END()
143
Giorgio Arena0f170392018-07-18 16:13:12 +0100144TEST_SUITE(Grouped)
145TEST_SUITE(FP32)
Giorgio Arenafb629082018-08-20 18:03:27 +0100146FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::GroupedIm2ColSmallShapes(), framework::dataset::make("DataType",
147 DataType::F32)),
148 grouped_args))
Giorgio Arena0f170392018-07-18 16:13:12 +0100149{
150 // Validate output
151 validate(CLAccessor(_target), _reference);
152}
153
Giorgio Arenafb629082018-08-20 18:03:27 +0100154FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::GroupedIm2ColLargeShapes(), framework::dataset::make("DataType",
155 DataType::F32)),
156 grouped_args))
Giorgio Arena0f170392018-07-18 16:13:12 +0100157{
158 // Validate output
159 validate(CLAccessor(_target), _reference);
160}
161TEST_SUITE_END()
162
163TEST_SUITE(FP16)
Giorgio Arenafb629082018-08-20 18:03:27 +0100164FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<half>, framework::DatasetMode::ALL, combine(combine(datasets::GroupedIm2ColSmallShapes(), framework::dataset::make("DataType",
165 DataType::F16)),
166 grouped_args))
Giorgio Arena0f170392018-07-18 16:13:12 +0100167{
168 // Validate output
169 validate(CLAccessor(_target), _reference);
170}
171
Giorgio Arenafb629082018-08-20 18:03:27 +0100172FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::GroupedIm2ColLargeShapes(), framework::dataset::make("DataType",
173 DataType::F16)),
174 grouped_args))
Giorgio Arena0f170392018-07-18 16:13:12 +0100175{
176 // Validate output
177 validate(CLAccessor(_target), _reference);
178}
179TEST_SUITE_END()
180
181TEST_SUITE(QASYMM8)
Giorgio Arenafb629082018-08-20 18:03:27 +0100182FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(datasets::GroupedIm2ColSmallShapes(), framework::dataset::make("DataType",
183 DataType::QASYMM8)),
184 grouped_args))
Giorgio Arena0f170392018-07-18 16:13:12 +0100185{
186 // Validate output
187 validate(CLAccessor(_target), _reference);
188}
189
Giorgio Arenafb629082018-08-20 18:03:27 +0100190FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::GroupedIm2ColLargeShapes(), framework::dataset::make("DataType",
191 DataType::QASYMM8)),
192 grouped_args))
Giorgio Arena0f170392018-07-18 16:13:12 +0100193{
194 // Validate output
195 validate(CLAccessor(_target), _reference);
196}
197TEST_SUITE_END()
198TEST_SUITE_END()
199
Pablo Tello4a626a72018-04-04 10:01:14 +0100200TEST_SUITE_END()
201TEST_SUITE_END()
202} // namespace validation
203} // namespace test
204} // namespace arm_compute