1*c217d954SCole Faust /*
2*c217d954SCole Faust * Copyright (c) 2018-2021 Arm Limited.
3*c217d954SCole Faust *
4*c217d954SCole Faust * SPDX-License-Identifier: MIT
5*c217d954SCole Faust *
6*c217d954SCole Faust * Permission is hereby granted, free of charge, to any person obtaining a copy
7*c217d954SCole Faust * of this software and associated documentation files (the "Software"), to
8*c217d954SCole Faust * deal in the Software without restriction, including without limitation the
9*c217d954SCole Faust * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*c217d954SCole Faust * sell copies of the Software, and to permit persons to whom the Software is
11*c217d954SCole Faust * furnished to do so, subject to the following conditions:
12*c217d954SCole Faust *
13*c217d954SCole Faust * The above copyright notice and this permission notice shall be included in all
14*c217d954SCole Faust * copies or substantial portions of the Software.
15*c217d954SCole Faust *
16*c217d954SCole Faust * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*c217d954SCole Faust * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*c217d954SCole Faust * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*c217d954SCole Faust * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*c217d954SCole Faust * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*c217d954SCole Faust * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22*c217d954SCole Faust * SOFTWARE.
23*c217d954SCole Faust */
24*c217d954SCole Faust #include "arm_compute/core/Types.h"
25*c217d954SCole Faust #include "src/gpu/cl/kernels/ClIm2ColKernel.h"
26*c217d954SCole Faust #include "tests/CL/CLAccessor.h"
27*c217d954SCole Faust #include "tests/CL/Helper.h"
28*c217d954SCole Faust #include "tests/framework/Asserts.h"
29*c217d954SCole Faust #include "tests/framework/Macros.h"
30*c217d954SCole Faust #include "tests/framework/datasets/Datasets.h"
31*c217d954SCole Faust #include "tests/validation/Validation.h"
32*c217d954SCole Faust #include "tests/validation/fixtures/Im2ColFixture.h"
33*c217d954SCole Faust
34*c217d954SCole Faust namespace arm_compute
35*c217d954SCole Faust {
36*c217d954SCole Faust namespace test
37*c217d954SCole Faust {
38*c217d954SCole Faust namespace validation
39*c217d954SCole Faust {
40*c217d954SCole Faust TEST_SUITE(CL)
41*c217d954SCole Faust TEST_SUITE(Im2Col)
42*c217d954SCole Faust
43*c217d954SCole Faust using ClIm2Col = ClSynthetizeOperatorWithBorder<opencl::kernels::ClIm2ColKernel>;
44*c217d954SCole Faust
45*c217d954SCole Faust /** Negative tests
46*c217d954SCole Faust *
47*c217d954SCole Faust * A series of validation tests on configurations which according to the API specification
48*c217d954SCole Faust * the function should fail against.
49*c217d954SCole Faust *
50*c217d954SCole Faust * Checks performed in order:
51*c217d954SCole Faust * - Pass unsupported data type for input
52*c217d954SCole Faust * - Pass a quantized input and ask to compress the bias into the resulting matrix
53*c217d954SCole Faust * - Pass a dilation factor of 0
54*c217d954SCole Faust * - Check NHWC data layout while requesting to perform a grouped operation
55*c217d954SCole Faust * - Check NCHW grouped operation when the number of channels is not multiple of the groups
56*c217d954SCole Faust * - Pass an invalid output shape
57*c217d954SCole Faust */
TEST_CASE(Negative,framework::DatasetMode::ALL)58*c217d954SCole Faust TEST_CASE(Negative, framework::DatasetMode::ALL)
59*c217d954SCole Faust {
60*c217d954SCole Faust // Unsupported data type
61*c217d954SCole Faust {
62*c217d954SCole Faust const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::SIZET);
63*c217d954SCole Faust const auto output = TensorInfo(TensorShape(9U, 10U, 12U, 2U), 1, DataType::F32);
64*c217d954SCole Faust const auto conv_size = Size2D(3, 3);
65*c217d954SCole Faust const bool has_bias = false;
66*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias);
67*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
68*c217d954SCole Faust }
69*c217d954SCole Faust
70*c217d954SCole Faust // Passing quantized input and ask to merge the bias in the output
71*c217d954SCole Faust {
72*c217d954SCole Faust const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::QASYMM8);
73*c217d954SCole Faust const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::QASYMM8);
74*c217d954SCole Faust const auto conv_size = Size2D(3, 3);
75*c217d954SCole Faust const bool has_bias = true;
76*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias);
77*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
78*c217d954SCole Faust }
79*c217d954SCole Faust
80*c217d954SCole Faust // Invalid dilation
81*c217d954SCole Faust {
82*c217d954SCole Faust const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32);
83*c217d954SCole Faust const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::F32);
84*c217d954SCole Faust const auto conv_size = Size2D(3, 3);
85*c217d954SCole Faust const auto dilation = Size2D(0, 1);
86*c217d954SCole Faust const bool has_bias = false;
87*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias, dilation);
88*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
89*c217d954SCole Faust }
90*c217d954SCole Faust
91*c217d954SCole Faust // NHWC and grouping greater than 1
92*c217d954SCole Faust {
93*c217d954SCole Faust const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC);
94*c217d954SCole Faust const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::F32);
95*c217d954SCole Faust const auto conv_size = Size2D(3, 3);
96*c217d954SCole Faust const auto dilation = Size2D(1, 1);
97*c217d954SCole Faust const bool has_bias = false;
98*c217d954SCole Faust const unsigned int num_groups = 2;
99*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias, dilation, num_groups);
100*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
101*c217d954SCole Faust }
102*c217d954SCole Faust
103*c217d954SCole Faust // NCWH and channels % num_groups !=0
104*c217d954SCole Faust {
105*c217d954SCole Faust const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32, DataLayout::NCHW);
106*c217d954SCole Faust const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::F32);
107*c217d954SCole Faust const auto conv_size = Size2D(3, 3);
108*c217d954SCole Faust const auto dilation = Size2D(1, 1);
109*c217d954SCole Faust const bool has_bias = false;
110*c217d954SCole Faust const unsigned int num_groups = 2;
111*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias, dilation, num_groups);
112*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
113*c217d954SCole Faust }
114*c217d954SCole Faust
115*c217d954SCole Faust // Invalid output shape
116*c217d954SCole Faust {
117*c217d954SCole Faust const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32);
118*c217d954SCole Faust const auto output = TensorInfo(TensorShape(9U, 81U, 2U), 1, DataType::F32);
119*c217d954SCole Faust const auto conv_size = Size2D(3, 3);
120*c217d954SCole Faust const bool has_bias = false;
121*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias);
122*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
123*c217d954SCole Faust }
124*c217d954SCole Faust
125*c217d954SCole Faust // Kernel dimensions are too big
126*c217d954SCole Faust {
127*c217d954SCole Faust const auto input = TensorInfo(TensorShape(1U, 9U, 5U, 2U), 1, DataType::F32, DataLayout::NHWC);
128*c217d954SCole Faust const auto output = TensorInfo(TensorShape(1U, 1U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC);
129*c217d954SCole Faust const auto conv_size = Size2D(9, 9);
130*c217d954SCole Faust const bool has_bias = false;
131*c217d954SCole Faust const auto status = opencl::kernels::ClIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias);
132*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
133*c217d954SCole Faust }
134*c217d954SCole Faust }
135*c217d954SCole Faust
136*c217d954SCole Faust template <typename T>
137*c217d954SCole Faust using ClIm2ColFixture = Im2ColOpValidationFixture<CLTensor, CLAccessor, ClIm2Col, T, true>;
138*c217d954SCole Faust
139*c217d954SCole Faust TEST_SUITE(NHWC)
140*c217d954SCole Faust
141*c217d954SCole Faust /** Test special kernel used for NHWC for 3x3 kernels
142*c217d954SCole Faust *
143*c217d954SCole Faust * @note 2 elements processed per iteration
144*c217d954SCole Faust *
145*c217d954SCole Faust * Three tests will be run:
146*c217d954SCole Faust * - Channels are multiple of elements processed
147*c217d954SCole Faust * - Channels larger and non multiple of elements used
148*c217d954SCole Faust * - Channels smaller and not multiple of elements used
149*c217d954SCole Faust *
150*c217d954SCole Faust * Kernel tested im2col3x3_nhwc
151*c217d954SCole Faust */
152*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(W3x3,
153*c217d954SCole Faust ClIm2ColFixture<float>,
154*c217d954SCole Faust framework::DatasetMode::ALL,
155*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
156*c217d954SCole Faust framework::dataset::make("InputShape",
157*c217d954SCole Faust {
158*c217d954SCole Faust TensorShape(5U, 7U, 2U, 2U), TensorShape(4U, 6U, 3U, 2U), TensorShape(5U, 3U, 1U, 2U),
159*c217d954SCole Faust }),
160*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
161*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(3, 3))),
162*c217d954SCole Faust framework::dataset::make("PadStride", { PadStrideInfo(1, 2, 1, 2), PadStrideInfo(1, 1, 0, 0) })),
163*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
164*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)),
165*c217d954SCole Faust framework::dataset::make("Groups", 1)))
166*c217d954SCole Faust {
167*c217d954SCole Faust // Validate output
168*c217d954SCole Faust validate(CLAccessor(_target), _reference);
169*c217d954SCole Faust }
170*c217d954SCole Faust
171*c217d954SCole Faust /** Test special kernel used for NHWC for 9x9 kernels
172*c217d954SCole Faust *
173*c217d954SCole Faust * @note 2 elements processed per iteration
174*c217d954SCole Faust *
175*c217d954SCole Faust * Three tests will be run:
176*c217d954SCole Faust * - Channels are multiple of elements processed
177*c217d954SCole Faust * - Channels larger and non multiple of elements used
178*c217d954SCole Faust * - Channels smaller and not multiple of elements used
179*c217d954SCole Faust *
180*c217d954SCole Faust * Kernel tested im2col9x9_nhwc
181*c217d954SCole Faust */
182*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(W9x9,
183*c217d954SCole Faust ClIm2ColFixture<float>,
184*c217d954SCole Faust framework::DatasetMode::ALL,
185*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
186*c217d954SCole Faust framework::dataset::make("InputShape",
187*c217d954SCole Faust {
188*c217d954SCole Faust TensorShape(13U, 15U, 2U, 2U), TensorShape(15U, 12U, 3U, 2U), TensorShape(13U, 22U, 1U, 2U),
189*c217d954SCole Faust }),
190*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
191*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(9, 9))),
192*c217d954SCole Faust framework::dataset::make("PadStride", { PadStrideInfo(2, 2, 1, 2), PadStrideInfo(1, 1, 0, 0) })),
193*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
194*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)),
195*c217d954SCole Faust framework::dataset::make("Groups", 1)))
196*c217d954SCole Faust {
197*c217d954SCole Faust // Validate output
198*c217d954SCole Faust validate(CLAccessor(_target), _reference);
199*c217d954SCole Faust }
200*c217d954SCole Faust
201*c217d954SCole Faust /** Test generic kernel used for NHWC
202*c217d954SCole Faust *
203*c217d954SCole Faust * @note 2 elements processed per iteration
204*c217d954SCole Faust *
205*c217d954SCole Faust * Three tests will be run:
206*c217d954SCole Faust * - Channels are multiple of elements processed
207*c217d954SCole Faust * - Channels larger and non multiple of elements used
208*c217d954SCole Faust * - Channels smaller and not multiple of elements used
209*c217d954SCole Faust *
210*c217d954SCole Faust * Kernel tested im2col_generic_nhwc
211*c217d954SCole Faust */
212*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(Generic,
213*c217d954SCole Faust ClIm2ColFixture<float>,
214*c217d954SCole Faust framework::DatasetMode::ALL,
215*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
216*c217d954SCole Faust framework::dataset::make("InputShape",
217*c217d954SCole Faust {
218*c217d954SCole Faust TensorShape(13U, 15U, 4U, 2U), TensorShape(15U, 12U, 7U, 1U), TensorShape(5U, 3U, 1U, 1U),
219*c217d954SCole Faust }),
220*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
221*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(5, 3))),
222*c217d954SCole Faust framework::dataset::make("PadStride", { PadStrideInfo(2, 2, 1, 2), PadStrideInfo(1, 1, 0, 0) })),
223*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
224*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)),
225*c217d954SCole Faust framework::dataset::make("Groups", 1)))
226*c217d954SCole Faust {
227*c217d954SCole Faust // Validate output
228*c217d954SCole Faust validate(CLAccessor(_target), _reference);
229*c217d954SCole Faust }
230*c217d954SCole Faust TEST_SUITE_END() // NHWC
231*c217d954SCole Faust
TEST_SUITE(NCHW)232*c217d954SCole Faust TEST_SUITE(NCHW)
233*c217d954SCole Faust
234*c217d954SCole Faust /** Test special kernel used for NCHW for 1x1 kernels with stride 1 and no padding
235*c217d954SCole Faust *
236*c217d954SCole Faust * @note 4 elements processed per iteration
237*c217d954SCole Faust *
238*c217d954SCole Faust * Three tests will be run:
239*c217d954SCole Faust * - Channels are multiple of elements processed
240*c217d954SCole Faust * - Channels larger and non multiple of elements used
241*c217d954SCole Faust * - Channels smaller and not multiple of elements used
242*c217d954SCole Faust *
243*c217d954SCole Faust * Kernel tested im2col1x1_stridex1_nchw
244*c217d954SCole Faust */
245*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(W1x1_Stride1_NoPad,
246*c217d954SCole Faust ClIm2ColFixture<float>,
247*c217d954SCole Faust framework::DatasetMode::ALL,
248*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
249*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(4U, 4U, 3U, 2U), TensorShape(5U, 4U, 3U, 2U), TensorShape(3U, 4U, 3U, 2U) }),
250*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
251*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(1, 1))),
252*c217d954SCole Faust framework::dataset::make("PadStride", PadStrideInfo(1, 1, 0, 0))),
253*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
254*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)),
255*c217d954SCole Faust framework::dataset::make("Groups", 1)))
256*c217d954SCole Faust {
257*c217d954SCole Faust // Validate output
258*c217d954SCole Faust validate(CLAccessor(_target), _reference);
259*c217d954SCole Faust }
260*c217d954SCole Faust
261*c217d954SCole Faust /** Test special kernel used for NCHW for 3x3 kernels
262*c217d954SCole Faust *
263*c217d954SCole Faust * @note 1 elements processed per iteration
264*c217d954SCole Faust *
265*c217d954SCole Faust * Executed single test as padding is required.
266*c217d954SCole Faust *
267*c217d954SCole Faust * Kernel tested im2col3x3_nchw
268*c217d954SCole Faust */
269*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(W3x3,
270*c217d954SCole Faust ClIm2ColFixture<float>,
271*c217d954SCole Faust framework::DatasetMode::ALL,
272*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
273*c217d954SCole Faust framework::dataset::make("InputShape", TensorShape(4U, 4U, 3U, 2U)),
274*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
275*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(3, 3))),
276*c217d954SCole Faust framework::dataset::make("PadStride", PadStrideInfo(1, 2, 1, 2))),
277*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
278*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)),
279*c217d954SCole Faust framework::dataset::make("Groups", { 1, 3 })))
280*c217d954SCole Faust {
281*c217d954SCole Faust // Validate output
282*c217d954SCole Faust validate(CLAccessor(_target), _reference);
283*c217d954SCole Faust }
284*c217d954SCole Faust
285*c217d954SCole Faust /** Test special kernel used for NCHW for 5x5 kernels
286*c217d954SCole Faust *
287*c217d954SCole Faust * @note 1 elements processed per iteration
288*c217d954SCole Faust *
289*c217d954SCole Faust * Executed single test as padding is required.
290*c217d954SCole Faust *
291*c217d954SCole Faust * Kernel tested im2col5x5_nchw
292*c217d954SCole Faust */
293*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(W5x5,
294*c217d954SCole Faust ClIm2ColFixture<float>,
295*c217d954SCole Faust framework::DatasetMode::ALL,
296*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
297*c217d954SCole Faust framework::dataset::make("InputShape", TensorShape(7U, 4U, 3U, 2U)),
298*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
299*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(5, 5))),
300*c217d954SCole Faust framework::dataset::make("PadStride", PadStrideInfo(2, 1, 2, 1))),
301*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
302*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)),
303*c217d954SCole Faust framework::dataset::make("Groups", { 1, 3 })))
304*c217d954SCole Faust {
305*c217d954SCole Faust // Validate output
306*c217d954SCole Faust validate(CLAccessor(_target), _reference);
307*c217d954SCole Faust }
308*c217d954SCole Faust
309*c217d954SCole Faust /** Test special kernel used for NCHW for 11x11 kernels when no padding present
310*c217d954SCole Faust *
311*c217d954SCole Faust * @note 1 elements processed per iteration
312*c217d954SCole Faust *
313*c217d954SCole Faust * Two tests will be run:
314*c217d954SCole Faust * - Without padding requirements
315*c217d954SCole Faust * - With padding requirements
316*c217d954SCole Faust *
317*c217d954SCole Faust * Kernel tested im2col11x11_padx0_pady0_nchw
318*c217d954SCole Faust */
319*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(W11x11_NoPad,
320*c217d954SCole Faust ClIm2ColFixture<float>,
321*c217d954SCole Faust framework::DatasetMode::ALL,
322*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
323*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(11U, 11U, 2U, 2U), TensorShape(14U, 13U, 1U, 2U) }),
324*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
325*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(11, 11))),
326*c217d954SCole Faust framework::dataset::make("PadStride", PadStrideInfo(1, 1, 0, 0))),
327*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
328*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)),
329*c217d954SCole Faust framework::dataset::make("Groups", 1)))
330*c217d954SCole Faust {
331*c217d954SCole Faust // Validate output
332*c217d954SCole Faust validate(CLAccessor(_target), _reference);
333*c217d954SCole Faust }
334*c217d954SCole Faust
335*c217d954SCole Faust /** Test special kernel used for NCHW for kernels which do not fall in the categories above and have no padding present
336*c217d954SCole Faust *
337*c217d954SCole Faust * @note 1 elements processed per iteration
338*c217d954SCole Faust *
339*c217d954SCole Faust * Executed single test as padding is required.
340*c217d954SCole Faust *
341*c217d954SCole Faust * Kernel tested im2col_generic_padx0_pady0_nchw
342*c217d954SCole Faust */
343*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(GenericZeroPad,
344*c217d954SCole Faust ClIm2ColFixture<float>,
345*c217d954SCole Faust framework::DatasetMode::ALL,
346*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
347*c217d954SCole Faust framework::dataset::make("InputShape", TensorShape(13U, 11U, 2U, 2U)),
348*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
349*c217d954SCole Faust framework::dataset::make("Kernel", Size2D(3, 2))),
350*c217d954SCole Faust framework::dataset::make("PadStride", PadStrideInfo(2, 1, 0, 0))),
351*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
352*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)),
353*c217d954SCole Faust framework::dataset::make("Groups", { 1, 2 })))
354*c217d954SCole Faust {
355*c217d954SCole Faust // Validate output
356*c217d954SCole Faust validate(CLAccessor(_target), _reference);
357*c217d954SCole Faust }
358*c217d954SCole Faust TEST_SUITE_END() // NCHW
359*c217d954SCole Faust
360*c217d954SCole Faust /** Generic NCHW/NHWC kernel
361*c217d954SCole Faust *
362*c217d954SCole Faust * @note 1 elements processed per iteration
363*c217d954SCole Faust *
364*c217d954SCole Faust * Padding is not needed thus executed sample tests with different kernels sizes
365*c217d954SCole Faust * and stride/padding information
366*c217d954SCole Faust *
367*c217d954SCole Faust * Kernel tested im2col_generic_(nchw|nhwc)
368*c217d954SCole Faust */
369*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(Generic,
370*c217d954SCole Faust ClIm2ColFixture<float>,
371*c217d954SCole Faust framework::DatasetMode::ALL,
372*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
373*c217d954SCole Faust framework::dataset::make("InputShape", TensorShape(13U, 11U, 5U, 2U)),
374*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
375*c217d954SCole Faust framework::dataset::make("Kernel", { Size2D(3, 2), Size2D(3, 5) })),
376*c217d954SCole Faust framework::dataset::make("PadStride", PadStrideInfo(2, 1, 2, 1))),
377*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
378*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
379*c217d954SCole Faust framework::dataset::make("Groups", 1)))
380*c217d954SCole Faust {
381*c217d954SCole Faust // Validate output
382*c217d954SCole Faust validate(CLAccessor(_target), _reference);
383*c217d954SCole Faust }
384*c217d954SCole Faust
385*c217d954SCole Faust /** Tests to check that quantized padding value is set correctly
386*c217d954SCole Faust *
387*c217d954SCole Faust * Kernels tested:
388*c217d954SCole Faust * - im2col_generic_nhwc
389*c217d954SCole Faust * - im2col_generic_nchw
390*c217d954SCole Faust * - im2col5x5_nchw
391*c217d954SCole Faust * - im2col3x3_nhwc
392*c217d954SCole Faust * - im2col3x3_nchw
393*c217d954SCole Faust * - im2col9x9_nhwc
394*c217d954SCole Faust */
395*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(Quantized,
396*c217d954SCole Faust ClIm2ColFixture<uint8_t>,
397*c217d954SCole Faust framework::DatasetMode::ALL,
398*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
399*c217d954SCole Faust framework::dataset::make("InputShape", TensorShape(13U, 11U, 11U, 2U)),
400*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
401*c217d954SCole Faust framework::dataset::make("Kernel", { Size2D(1, 1), Size2D(3, 3), Size2D(5, 5), Size2D(3, 5), Size2D(9, 9) })),
402*c217d954SCole Faust framework::dataset::make("PadStride", { PadStrideInfo(1, 2, 1, 1) })),
403*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo(0.5f, 10))),
404*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
405*c217d954SCole Faust framework::dataset::make("Groups", 1)))
406*c217d954SCole Faust {
407*c217d954SCole Faust // Validate output
408*c217d954SCole Faust validate(CLAccessor(_target), _reference);
409*c217d954SCole Faust }
410*c217d954SCole Faust
411*c217d954SCole Faust /** Tests to check that half-precision execution
412*c217d954SCole Faust *
413*c217d954SCole Faust * Kernels tested:
414*c217d954SCole Faust * - im2col_generic_nhwc
415*c217d954SCole Faust * - im2col_generic_nchw
416*c217d954SCole Faust * - im2col5x5_nchw
417*c217d954SCole Faust * - im2col3x3_nhwc
418*c217d954SCole Faust * - im2col3x3_nchw
419*c217d954SCole Faust * - im2col9x9_nhwc
420*c217d954SCole Faust */
421*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(FP16,
422*c217d954SCole Faust ClIm2ColFixture<half>,
423*c217d954SCole Faust framework::DatasetMode::ALL,
424*c217d954SCole Faust combine(combine(combine(combine(combine(combine(
425*c217d954SCole Faust framework::dataset::make("InputShape", TensorShape(13U, 11U, 11U, 2U)),
426*c217d954SCole Faust framework::dataset::make("DataType", DataType::F16)),
427*c217d954SCole Faust framework::dataset::make("Kernel", { Size2D(1, 1), Size2D(3, 3), Size2D(5, 5), Size2D(3, 5), Size2D(9, 9) })),
428*c217d954SCole Faust framework::dataset::make("PadStride", { PadStrideInfo(1, 2, 1, 1) })),
429*c217d954SCole Faust framework::dataset::make("QInfo", QuantizationInfo())),
430*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
431*c217d954SCole Faust framework::dataset::make("Groups", 1)))
432*c217d954SCole Faust {
433*c217d954SCole Faust // Validate output
434*c217d954SCole Faust validate(CLAccessor(_target), _reference);
435*c217d954SCole Faust }
436*c217d954SCole Faust
437*c217d954SCole Faust TEST_SUITE_END() // Im2Col
438*c217d954SCole Faust TEST_SUITE_END() // CL
439*c217d954SCole Faust } // namespace validation
440*c217d954SCole Faust } // namespace test
441*c217d954SCole Faust } // namespace arm_compute
442