1*c217d954SCole Faust /*
2*c217d954SCole Faust * Copyright (c) 2017-2023 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 "arm_compute/runtime/CL/CLTensor.h"
26*c217d954SCole Faust #include "arm_compute/runtime/CL/CLTensorAllocator.h"
27*c217d954SCole Faust #include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h"
28*c217d954SCole Faust #include "tests/CL/CLAccessor.h"
29*c217d954SCole Faust #include "tests/PaddingCalculator.h"
30*c217d954SCole Faust #include "tests/datasets/DirectConvolutionLayerDataset.h"
31*c217d954SCole Faust #include "tests/datasets/ShapeDatasets.h"
32*c217d954SCole Faust #include "tests/framework/Asserts.h"
33*c217d954SCole Faust #include "tests/framework/Macros.h"
34*c217d954SCole Faust #include "tests/framework/datasets/Datasets.h"
35*c217d954SCole Faust #include "tests/validation/Validation.h"
36*c217d954SCole Faust #include "tests/validation/fixtures/DirectConvolutionLayerFixture.h"
37*c217d954SCole Faust
38*c217d954SCole Faust /** Synced with tests/validation/dynamic_fusion/gpu/cl/DirectConv2d.cpp
39*c217d954SCole Faust * Please check there for any differences in the coverage
40*c217d954SCole Faust */
41*c217d954SCole Faust namespace arm_compute
42*c217d954SCole Faust {
43*c217d954SCole Faust namespace test
44*c217d954SCole Faust {
45*c217d954SCole Faust namespace validation
46*c217d954SCole Faust {
47*c217d954SCole Faust namespace
48*c217d954SCole Faust {
49*c217d954SCole Faust RelativeTolerance<half> tolerance_fp16(half(0.2)); /**< Tolerance for floating point tests */
50*c217d954SCole Faust RelativeTolerance<float> tolerance_fp32(0.05f); /**< Tolerance for floating point tests */
51*c217d954SCole Faust constexpr float abs_tolerance_f32(0.0001f); /**< Absolute tolerance for FP32 tests*/
52*c217d954SCole Faust
53*c217d954SCole Faust constexpr float tolerance_num = 0.07f; /**< Tolerance number */
54*c217d954SCole Faust constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance for quantized tests */
55*c217d954SCole Faust
56*c217d954SCole Faust const auto data_strides = combine(framework::dataset::make("StrideX", 1, 3), framework::dataset::make("StrideY", 1, 3));
57*c217d954SCole Faust const auto data_strides_small = combine(framework::dataset::make("StrideX", 1), framework::dataset::make("StrideY", 1));
58*c217d954SCole Faust const auto data_ksize_one = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 1)));
59*c217d954SCole Faust const auto data_ksize_one_small = combine(framework::dataset::make("PadX", 0), combine(framework::dataset::make("PadY", 0), framework::dataset::make("KernelSize", 1)));
60*c217d954SCole Faust const auto data_ksize_three = combine(framework::dataset::make("PadX", 0, 2), combine(framework::dataset::make("PadY", 0, 2), framework::dataset::make("KernelSize", 3)));
61*c217d954SCole Faust const auto data_ksize_five = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 5)));
62*c217d954SCole Faust const auto data_ksize_nine = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 9)));
63*c217d954SCole Faust const auto data_ksize_nine_small = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 9)));
64*c217d954SCole Faust
65*c217d954SCole Faust const auto data_all_kernels = concat(concat(data_ksize_one, data_ksize_three), data_ksize_five);
66*c217d954SCole Faust
67*c217d954SCole Faust const auto data = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_all_kernels));
68*c217d954SCole Faust const auto data9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_ksize_nine));
69*c217d954SCole Faust const auto data_small = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_one_small));
70*c217d954SCole Faust const auto data_small9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_nine_small));
71*c217d954SCole Faust
72*c217d954SCole Faust /** Direct convolution nightly data set. */
73*c217d954SCole Faust const auto data_nightly = combine(data, framework::dataset::make("NumKernels", { 1, 4 }));
74*c217d954SCole Faust const auto data_nightly_9x9 = combine(data9x9, framework::dataset::make("NumKernels", { 1, 4 }));
75*c217d954SCole Faust const auto data_nightly_usecase = combine(framework::dataset::make("InputShape", { TensorShape{ 3U, 800U, 800U } }),
76*c217d954SCole Faust combine(framework::dataset::make("StrideX", { 1 }),
77*c217d954SCole Faust combine(framework::dataset::make("StrideY", { 1 }),
78*c217d954SCole Faust combine(framework::dataset::make("PadX", { 4 }),
79*c217d954SCole Faust combine(framework::dataset::make("PadY", { 4 }),
80*c217d954SCole Faust combine(framework::dataset::make("KernelSize", 9),
81*c217d954SCole Faust framework::dataset::make("NumKernels", { 16 })))))));
82*c217d954SCole Faust
83*c217d954SCole Faust /** Direct convolution precommit data set. */
84*c217d954SCole Faust const auto data_precommit = combine(data_small, framework::dataset::make("NumKernels", { 1 }));
85*c217d954SCole Faust const auto data_precommit_9x9 = combine(data_small9x9, framework::dataset::make("NumKernels", { 1 }));
86*c217d954SCole Faust
87*c217d954SCole Faust /** Activation function Dataset*/
88*c217d954SCole Faust const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
89*c217d954SCole Faust { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) });
90*c217d954SCole Faust } // namespace
91*c217d954SCole Faust
92*c217d954SCole Faust TEST_SUITE(CL)
TEST_SUITE(DirectConvolutionLayer)93*c217d954SCole Faust TEST_SUITE(DirectConvolutionLayer)
94*c217d954SCole Faust
95*c217d954SCole Faust /** Check whether the configuration of a Direct Convolution layer with no
96*c217d954SCole Faust * bias leads to a successful execution.
97*c217d954SCole Faust */
98*c217d954SCole Faust TEST_CASE(NoBias, framework::DatasetMode::PRECOMMIT)
99*c217d954SCole Faust {
100*c217d954SCole Faust const auto src_shape = TensorShape(27U, 13U, 2U);
101*c217d954SCole Faust const auto weights_shape = TensorShape(3U, 3U, 2U, 4U);
102*c217d954SCole Faust const auto bias_shape = TensorShape(4U);
103*c217d954SCole Faust const auto dst_shape = TensorShape(25U, 11U, 4U);
104*c217d954SCole Faust constexpr auto dt = DataType::F32;
105*c217d954SCole Faust
106*c217d954SCole Faust auto src = create_tensor<CLTensor>(src_shape, dt);
107*c217d954SCole Faust auto weights = create_tensor<CLTensor>(weights_shape, dt);
108*c217d954SCole Faust auto dst = create_tensor<CLTensor>(dst_shape, dt);
109*c217d954SCole Faust
110*c217d954SCole Faust const auto conv_info = PadStrideInfo(1, 1, 0, 0);
111*c217d954SCole Faust
112*c217d954SCole Faust // Create Direct Convolution function
113*c217d954SCole Faust CLDirectConvolutionLayer conv{};
114*c217d954SCole Faust conv.configure(&src, &weights, nullptr, &dst, conv_info);
115*c217d954SCole Faust
116*c217d954SCole Faust src.allocator()->allocate();
117*c217d954SCole Faust weights.allocator()->allocate();
118*c217d954SCole Faust dst.allocator()->allocate();
119*c217d954SCole Faust
120*c217d954SCole Faust library->fill_tensor_value(CLAccessor(src), 1.f);
121*c217d954SCole Faust library->fill_tensor_value(CLAccessor(weights), 1.f);
122*c217d954SCole Faust
123*c217d954SCole Faust conv.run();
124*c217d954SCole Faust
125*c217d954SCole Faust // Compute reference to compare
126*c217d954SCole Faust SimpleTensor<float> ref_src{ src_shape, dt };
127*c217d954SCole Faust SimpleTensor<float> ref_weights{ weights_shape, dt };
128*c217d954SCole Faust SimpleTensor<float> ref_bias{ bias_shape, dt };
129*c217d954SCole Faust library->fill_tensor_value(ref_src, 1.f);
130*c217d954SCole Faust library->fill_tensor_value(ref_weights, 1.f);
131*c217d954SCole Faust // No bias
132*c217d954SCole Faust library->fill_tensor_value(ref_bias, 0.f);
133*c217d954SCole Faust auto ref_dst = reference::convolution_layer<float>(ref_src, ref_weights, ref_bias, dst_shape, conv_info);
134*c217d954SCole Faust
135*c217d954SCole Faust validate(CLAccessor(dst), ref_dst);
136*c217d954SCole Faust }
137*c217d954SCole Faust
138*c217d954SCole Faust /** Check whether the case of rectangle kernels i.e. when width and height of the weight_shape are not equal
139*c217d954SCole Faust * would lead to successful run
140*c217d954SCole Faust */
TEST_CASE(NonSquareKernel,framework::DatasetMode::PRECOMMIT)141*c217d954SCole Faust TEST_CASE(NonSquareKernel, framework::DatasetMode::PRECOMMIT)
142*c217d954SCole Faust {
143*c217d954SCole Faust auto src_shape = TensorShape(33U, 27U, 3U);
144*c217d954SCole Faust auto weights_shape = TensorShape(5U, 7U, 3U, 4U); // non-square kernel
145*c217d954SCole Faust const auto bias_shape = TensorShape(4U);
146*c217d954SCole Faust auto dst_shape = TensorShape(11U, 12U, 4U);
147*c217d954SCole Faust constexpr auto dt = DataType::F32;
148*c217d954SCole Faust
149*c217d954SCole Faust TensorShape src_shape_nhwc(src_shape);
150*c217d954SCole Faust TensorShape weights_shape_nhwc(weights_shape);
151*c217d954SCole Faust TensorShape dst_shape_nhwc(dst_shape);
152*c217d954SCole Faust
153*c217d954SCole Faust // Non-square shapes are only allowed for NHWC
154*c217d954SCole Faust permute(src_shape_nhwc, PermutationVector(2U, 0U, 1U));
155*c217d954SCole Faust permute(weights_shape_nhwc, PermutationVector(2U, 0U, 1U));
156*c217d954SCole Faust permute(dst_shape_nhwc, PermutationVector(2U, 0U, 1U));
157*c217d954SCole Faust
158*c217d954SCole Faust auto src = create_tensor<CLTensor>(src_shape_nhwc, dt, 1, QuantizationInfo(), DataLayout::NHWC);
159*c217d954SCole Faust auto weights = create_tensor<CLTensor>(weights_shape_nhwc, dt, 1, QuantizationInfo(), DataLayout::NHWC);
160*c217d954SCole Faust auto dst = create_tensor<CLTensor>(dst_shape_nhwc, dt, 1, QuantizationInfo(), DataLayout::NHWC);
161*c217d954SCole Faust const auto conv_info = PadStrideInfo(3, 2, 1, 1, 2, 0, DimensionRoundingType::FLOOR);
162*c217d954SCole Faust
163*c217d954SCole Faust // Create direct convolution function
164*c217d954SCole Faust CLDirectConvolutionLayer conv{};
165*c217d954SCole Faust conv.configure(&src, &weights, nullptr, &dst, conv_info);
166*c217d954SCole Faust
167*c217d954SCole Faust src.allocator()->allocate();
168*c217d954SCole Faust weights.allocator()->allocate();
169*c217d954SCole Faust dst.allocator()->allocate();
170*c217d954SCole Faust
171*c217d954SCole Faust library->fill_tensor_value(CLAccessor(src), 1.f);
172*c217d954SCole Faust library->fill_tensor_value(CLAccessor(weights), 1.f);
173*c217d954SCole Faust
174*c217d954SCole Faust conv.run();
175*c217d954SCole Faust
176*c217d954SCole Faust // Compute reference to compare
177*c217d954SCole Faust SimpleTensor<float> ref_src{ src_shape, dt };
178*c217d954SCole Faust SimpleTensor<float> ref_weights{ weights_shape, dt };
179*c217d954SCole Faust SimpleTensor<float> ref_bias{ bias_shape, dt };
180*c217d954SCole Faust library->fill_tensor_value(ref_src, 1.f);
181*c217d954SCole Faust library->fill_tensor_value(ref_weights, 1.f);
182*c217d954SCole Faust // No bias
183*c217d954SCole Faust library->fill_tensor_value(ref_bias, 0.f);
184*c217d954SCole Faust auto ref_dst = reference::convolution_layer<float>(ref_src, ref_weights, ref_bias, dst_shape, conv_info);
185*c217d954SCole Faust
186*c217d954SCole Faust validate(CLAccessor(dst), ref_dst);
187*c217d954SCole Faust }
188*c217d954SCole Faust // *INDENT-OFF*
189*c217d954SCole Faust // clang-format off
190*c217d954SCole Faust DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
191*c217d954SCole Faust framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid: Mismatching data type input/weights
192*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid: Mismatching input feature maps
193*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid weights dimensions
194*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Unsupported biases size
195*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Unsupported biases dimensions
196*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid output size
197*c217d954SCole Faust TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32),
198*c217d954SCole Faust }),
199*c217d954SCole Faust framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F16),
200*c217d954SCole Faust TensorInfo(TensorShape(3U, 3U, 3U, 4U), 1, DataType::F32),
201*c217d954SCole Faust TensorInfo(TensorShape(3U, 3U, 2U, 4U, 3U), 1, DataType::F32),
202*c217d954SCole Faust TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
203*c217d954SCole Faust TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
204*c217d954SCole Faust TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
205*c217d954SCole Faust TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32),
206*c217d954SCole Faust })),
207*c217d954SCole Faust framework::dataset::make("BiasesInfo",{ TensorInfo(TensorShape(4U), 1, DataType::F32),
208*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32),
209*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32),
210*c217d954SCole Faust TensorInfo(TensorShape(3U), 1, DataType::F32),
211*c217d954SCole Faust TensorInfo(TensorShape(4U, 2U), 1, DataType::F32),
212*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32),
213*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32),
214*c217d954SCole Faust })),
215*c217d954SCole Faust framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
216*c217d954SCole Faust TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
217*c217d954SCole Faust TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
218*c217d954SCole Faust TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
219*c217d954SCole Faust TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32),
220*c217d954SCole Faust TensorInfo(TensorShape(26U, 11U, 4U), 1, DataType::F32),
221*c217d954SCole Faust TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32),
222*c217d954SCole Faust })),
223*c217d954SCole Faust framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0),
224*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
225*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
226*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
227*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
228*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
229*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
230*c217d954SCole Faust })),
231*c217d954SCole Faust framework::dataset::make("ActivationInfo",
232*c217d954SCole Faust {
233*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
234*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
235*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
236*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
237*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
238*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
239*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)
240*c217d954SCole Faust })),
241*c217d954SCole Faust framework::dataset::make("Expected", { false, false, false, false, false, false, true })),
242*c217d954SCole Faust input_info, weights_info, biases_info, output_info, conv_info, act_info, expected)
243*c217d954SCole Faust {
244*c217d954SCole Faust bool is_valid = bool(CLDirectConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, act_info));
245*c217d954SCole Faust ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
246*c217d954SCole Faust }
247*c217d954SCole Faust // clang-format on
248*c217d954SCole Faust // *INDENT-ON*
249*c217d954SCole Faust
250*c217d954SCole Faust template <typename T>
251*c217d954SCole Faust using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
252*c217d954SCole Faust template <typename T>
253*c217d954SCole Faust using CLDirectConvolutionLayerMixedDataLayoutFixture = DirectConvolutionValidationFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T, true>;
254*c217d954SCole Faust template <typename T>
255*c217d954SCole Faust using CLDirectConvolutionValidationWithTensorShapesFixture = DirectConvolutionValidationWithTensorShapesFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
256*c217d954SCole Faust template <typename T>
257*c217d954SCole Faust using CLDirectConvolutionLayerQuantizedFixture = DirectConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
258*c217d954SCole Faust template <typename T>
259*c217d954SCole Faust using CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture = DirectConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T, true>;
260*c217d954SCole Faust template <typename T>
261*c217d954SCole Faust using CLDirectConvolutionValidationWithTensorShapesQuantizedFixture = DirectConvolutionValidationWithTensorShapesQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>;
262*c217d954SCole Faust
263*c217d954SCole Faust TEST_SUITE(NHWC)
264*c217d954SCole Faust // *INDENT-OFF*
265*c217d954SCole Faust // clang-format off
266*c217d954SCole Faust DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
267*c217d954SCole Faust framework::dataset::make("InputInfo", {
268*c217d954SCole Faust TensorInfo(TensorShape(2U, 27U, 13U), 1, DataType::F32, DataLayout::NHWC), // Arbitrary weight sizes for NHWC are supported
269*c217d954SCole Faust TensorInfo(TensorShape(2U, 27U, 13U), 1, DataType::F32, DataLayout::NHWC), // Non-rectangular weights dimensions for NHWC are supported
270*c217d954SCole Faust TensorInfo(TensorShape(2U, 27U, 13U), 1, DataType::F32, DataLayout::NHWC), // Strides > 2 for any kernel sizes for NHWC are supported
271*c217d954SCole Faust }),
272*c217d954SCole Faust framework::dataset::make("WeightsInfo",{
273*c217d954SCole Faust TensorInfo(TensorShape(2U, 13U, 13U, 4U), 1, DataType::F32, DataLayout::NHWC),
274*c217d954SCole Faust TensorInfo(TensorShape(2U, 5U, 3U, 4U), 1, DataType::F32, DataLayout::NHWC),
275*c217d954SCole Faust TensorInfo(TensorShape(2U, 3U, 3U, 4U), 1, DataType::F32, DataLayout::NHWC),
276*c217d954SCole Faust })),
277*c217d954SCole Faust framework::dataset::make("BiasesInfo",{
278*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NHWC),
279*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NHWC),
280*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NHWC),
281*c217d954SCole Faust })),
282*c217d954SCole Faust framework::dataset::make("OutputInfo",{
283*c217d954SCole Faust TensorInfo(TensorShape(4U, 15U, 1U), 1, DataType::F32, DataLayout::NHWC),
284*c217d954SCole Faust TensorInfo(TensorShape(4U, 23U, 11U), 1, DataType::F32, DataLayout::NHWC),
285*c217d954SCole Faust TensorInfo(TensorShape(4U, 9U, 4U), 1, DataType::F32, DataLayout::NHWC),
286*c217d954SCole Faust })),
287*c217d954SCole Faust framework::dataset::make("ConvInfo", {
288*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
289*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
290*c217d954SCole Faust PadStrideInfo(3, 3, 0, 0),
291*c217d954SCole Faust })),
292*c217d954SCole Faust framework::dataset::make("ActivationInfo",
293*c217d954SCole Faust {
294*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
295*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
296*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
297*c217d954SCole Faust })),
298*c217d954SCole Faust framework::dataset::make("Expected", { true, true, true })),
299*c217d954SCole Faust input_info, weights_info, biases_info, output_info, conv_info, act_info, expected)
300*c217d954SCole Faust {
301*c217d954SCole Faust bool is_valid = bool(CLDirectConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, act_info));
302*c217d954SCole Faust ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
303*c217d954SCole Faust }
304*c217d954SCole Faust TEST_SUITE(FP16)
305*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT,
306*c217d954SCole Faust combine(combine(combine(zip(zip(zip(zip(zip(zip(
307*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
308*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
309*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
310*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
311*c217d954SCole Faust framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
312*c217d954SCole Faust framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
313*c217d954SCole Faust framework::dataset::make("PadX", { 1, 3, 0, 4 })),
314*c217d954SCole Faust framework::dataset::make("PadY", { 1, 3, 0, 4 })),
315*c217d954SCole Faust framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
316*c217d954SCole Faust framework::dataset::make("NumKernels", { 17, 3, 1, 19 })),
317*c217d954SCole Faust framework::dataset::make("DataType", DataType::F16)),
318*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
319*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
320*c217d954SCole Faust {
321*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
322*c217d954SCole Faust }
323*c217d954SCole Faust
324*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY,
325*c217d954SCole Faust combine(combine(combine(zip(zip(zip(zip(zip(zip(
326*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
327*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
328*c217d954SCole Faust framework::dataset::make("StrideY", { 1 })),
329*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
330*c217d954SCole Faust framework::dataset::make("PadY", { 1 })),
331*c217d954SCole Faust framework::dataset::make("KernelSize", { 9 })),
332*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
333*c217d954SCole Faust framework::dataset::make("DataType", DataType::F16)),
334*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::IDENTITY) )),
335*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
336*c217d954SCole Faust {
337*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
338*c217d954SCole Faust }
339*c217d954SCole Faust
340*c217d954SCole Faust TEST_SUITE_END() // FP16
341*c217d954SCole Faust
TEST_SUITE(FP32)342*c217d954SCole Faust TEST_SUITE(FP32)
343*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT,
344*c217d954SCole Faust combine(combine(combine(zip(zip(zip(zip(zip(zip(
345*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
346*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
347*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
348*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
349*c217d954SCole Faust framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
350*c217d954SCole Faust framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
351*c217d954SCole Faust framework::dataset::make("PadX", { 1, 3, 0, 4 })),
352*c217d954SCole Faust framework::dataset::make("PadY", { 1, 3, 0, 4 })),
353*c217d954SCole Faust framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
354*c217d954SCole Faust framework::dataset::make("NumKernels", { 17, 3, 1, 19 })),
355*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
356*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
357*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
358*c217d954SCole Faust {
359*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
360*c217d954SCole Faust }
361*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT,
362*c217d954SCole Faust combine(combine(combine(zip(zip(zip(zip(zip(zip(
363*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
364*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
365*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
366*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
367*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
368*c217d954SCole Faust framework::dataset::make("StrideY", { 2 })),
369*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
370*c217d954SCole Faust framework::dataset::make("PadY", { 3 })),
371*c217d954SCole Faust framework::dataset::make("KernelSize", { 3 })),
372*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
373*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
374*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
375*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
376*c217d954SCole Faust {
377*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
378*c217d954SCole Faust }
379*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY,
380*c217d954SCole Faust combine(combine(combine(zip(zip(zip(zip(zip(zip(
381*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
382*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
383*c217d954SCole Faust framework::dataset::make("StrideY", { 1 })),
384*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
385*c217d954SCole Faust framework::dataset::make("PadY", { 1 })),
386*c217d954SCole Faust framework::dataset::make("KernelSize", { 9 })),
387*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
388*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
389*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::IDENTITY) )),
390*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
391*c217d954SCole Faust {
392*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
393*c217d954SCole Faust }
394*c217d954SCole Faust TEST_SUITE_END() // FP32
395*c217d954SCole Faust
TEST_SUITE(Quantized)396*c217d954SCole Faust TEST_SUITE(Quantized)
397*c217d954SCole Faust TEST_SUITE(QASYMM8)
398*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
399*c217d954SCole Faust combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
400*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
401*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
402*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
403*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
404*c217d954SCole Faust framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
405*c217d954SCole Faust framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
406*c217d954SCole Faust framework::dataset::make("PadX", { 1, 3, 0, 4 })),
407*c217d954SCole Faust framework::dataset::make("PadY", { 1, 3, 0, 4 })),
408*c217d954SCole Faust framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
409*c217d954SCole Faust framework::dataset::make("NumKernels", { 7, 3, 1, 3 })),
410*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
411*c217d954SCole Faust framework::dataset::make("QuantizationInfo", QuantizationInfo(1.1f / 255, 10))),
412*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
413*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
414*c217d954SCole Faust {
415*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
416*c217d954SCole Faust }
417*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
418*c217d954SCole Faust combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
419*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
420*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
421*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
422*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
423*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
424*c217d954SCole Faust framework::dataset::make("StrideY", { 2 })),
425*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
426*c217d954SCole Faust framework::dataset::make("PadY", { 1 })),
427*c217d954SCole Faust framework::dataset::make("KernelSize", { 3 })),
428*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
429*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
430*c217d954SCole Faust framework::dataset::make("QuantizationInfo", QuantizationInfo(1.1f / 255, 10))),
431*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
432*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
433*c217d954SCole Faust {
434*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
435*c217d954SCole Faust }
436*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
437*c217d954SCole Faust combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
438*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
439*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
440*c217d954SCole Faust framework::dataset::make("StrideY", { 1 })),
441*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
442*c217d954SCole Faust framework::dataset::make("PadY", { 1 })),
443*c217d954SCole Faust framework::dataset::make("KernelSize", { 9 })),
444*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
445*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
446*c217d954SCole Faust framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
447*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
448*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
449*c217d954SCole Faust {
450*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
451*c217d954SCole Faust }
452*c217d954SCole Faust
453*c217d954SCole Faust TEST_SUITE_END() // QASYMM8
TEST_SUITE(QASYMM8_SIGNED)454*c217d954SCole Faust TEST_SUITE(QASYMM8_SIGNED)
455*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
456*c217d954SCole Faust combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
457*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
458*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
459*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
460*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
461*c217d954SCole Faust framework::dataset::make("StrideX", { 1, 3, 1, 1 })),
462*c217d954SCole Faust framework::dataset::make("StrideY", { 1, 3, 2, 1 })),
463*c217d954SCole Faust framework::dataset::make("PadX", { 1, 3, 0, 4 })),
464*c217d954SCole Faust framework::dataset::make("PadY", { 1, 3, 0, 4 })),
465*c217d954SCole Faust framework::dataset::make("KernelSize", { 3, 8, 1, 9 })),
466*c217d954SCole Faust framework::dataset::make("NumKernels", { 7, 3, 1, 3 })),
467*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
468*c217d954SCole Faust framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
469*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
470*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
471*c217d954SCole Faust {
472*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
473*c217d954SCole Faust }
474*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
475*c217d954SCole Faust combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
476*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U),
477*c217d954SCole Faust TensorShape(19U, 5U, 16U, 4U),
478*c217d954SCole Faust TensorShape(13U, 5U, 17U, 2U),
479*c217d954SCole Faust TensorShape(32U, 37U, 13U) } ),
480*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
481*c217d954SCole Faust framework::dataset::make("StrideY", { 1 })),
482*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
483*c217d954SCole Faust framework::dataset::make("PadY", { 1 })),
484*c217d954SCole Faust framework::dataset::make("KernelSize", { 3 })),
485*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
486*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
487*c217d954SCole Faust framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
488*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
489*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
490*c217d954SCole Faust {
491*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
492*c217d954SCole Faust }
493*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY,
494*c217d954SCole Faust combine(combine(combine(combine(zip(zip(zip(zip(zip(zip(
495*c217d954SCole Faust framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ),
496*c217d954SCole Faust framework::dataset::make("StrideX", { 1 })),
497*c217d954SCole Faust framework::dataset::make("StrideY", { 1 })),
498*c217d954SCole Faust framework::dataset::make("PadX", { 1 })),
499*c217d954SCole Faust framework::dataset::make("PadY", { 1 })),
500*c217d954SCole Faust framework::dataset::make("KernelSize", { 9 })),
501*c217d954SCole Faust framework::dataset::make("NumKernels", { 3 })),
502*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
503*c217d954SCole Faust framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))),
504*c217d954SCole Faust framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )),
505*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NHWC)))
506*c217d954SCole Faust {
507*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
508*c217d954SCole Faust }
509*c217d954SCole Faust TEST_SUITE_END() // QASYMM8_SIGNED
TEST_SUITE_END()510*c217d954SCole Faust TEST_SUITE_END() // Quantized
511*c217d954SCole Faust TEST_SUITE_END() // NHWC
512*c217d954SCole Faust
513*c217d954SCole Faust TEST_SUITE(NCHW)
514*c217d954SCole Faust DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
515*c217d954SCole Faust framework::dataset::make("InputInfo", {
516*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, DataLayout::NCHW), // Unsupported kernel width
517*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, DataLayout::NCHW), // Non-rectangular weights dimensions are unsupported
518*c217d954SCole Faust TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32, DataLayout::NCHW) // Unsupported stride
519*c217d954SCole Faust }),
520*c217d954SCole Faust framework::dataset::make("WeightsInfo",{
521*c217d954SCole Faust TensorInfo(TensorShape(11U, 11U, 2U, 4U), 1, DataType::F32, DataLayout::NCHW),
522*c217d954SCole Faust TensorInfo(TensorShape(5U, 3U, 2U, 4U), 1, DataType::F32, DataLayout::NCHW),
523*c217d954SCole Faust TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32, DataLayout::NCHW)
524*c217d954SCole Faust })),
525*c217d954SCole Faust framework::dataset::make("BiasesInfo",{
526*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NCHW),
527*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NCHW),
528*c217d954SCole Faust TensorInfo(TensorShape(4U), 1, DataType::F32, DataLayout::NCHW)
529*c217d954SCole Faust })),
530*c217d954SCole Faust framework::dataset::make("OutputInfo",{
531*c217d954SCole Faust TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, DataLayout::NCHW),
532*c217d954SCole Faust TensorInfo(TensorShape(23U, 11U, 4U), 1, DataType::F32, DataLayout::NCHW),
533*c217d954SCole Faust TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32, DataLayout::NCHW)
534*c217d954SCole Faust })),
535*c217d954SCole Faust framework::dataset::make("ConvInfo", {
536*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
537*c217d954SCole Faust PadStrideInfo(1, 1, 0, 0),
538*c217d954SCole Faust PadStrideInfo(3, 3, 0, 0)
539*c217d954SCole Faust })),
540*c217d954SCole Faust framework::dataset::make("ActivationInfo",
541*c217d954SCole Faust {
542*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
543*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
544*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)
545*c217d954SCole Faust })),
546*c217d954SCole Faust framework::dataset::make("Expected", { false, false, false})),
547*c217d954SCole Faust input_info, weights_info, biases_info, output_info, conv_info, act_info, expected)
548*c217d954SCole Faust {
549*c217d954SCole Faust bool is_valid = bool(CLDirectConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, act_info));
550*c217d954SCole Faust ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
551*c217d954SCole Faust }
552*c217d954SCole Faust // clang-format on
553*c217d954SCole Faust // *INDENT-ON*
554*c217d954SCole Faust
555*c217d954SCole Faust TEST_SUITE(Float)
TEST_SUITE(FP16)556*c217d954SCole Faust TEST_SUITE(FP16)
557*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType", DataType::F16)),
558*c217d954SCole Faust ActivationFunctionsDataset),
559*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)))
560*c217d954SCole Faust {
561*c217d954SCole Faust // Validate output
562*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
563*c217d954SCole Faust }
564*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F16)),
565*c217d954SCole Faust ActivationFunctionsDataset),
566*c217d954SCole Faust framework::dataset::make("DataLayout", DataLayout::NCHW)))
567*c217d954SCole Faust {
568*c217d954SCole Faust // Validate output
569*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num);
570*c217d954SCole Faust }
571*c217d954SCole Faust TEST_SUITE_END() // FP16
572*c217d954SCole Faust
TEST_SUITE(FP32)573*c217d954SCole Faust TEST_SUITE(FP32)
574*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType",
575*c217d954SCole Faust DataType::F32)),
576*c217d954SCole Faust ActivationFunctionsDataset),
577*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
578*c217d954SCole Faust {
579*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
580*c217d954SCole Faust }
581*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit,
582*c217d954SCole Faust framework::dataset::make("DataType",
583*c217d954SCole Faust DataType::F32)),
584*c217d954SCole Faust ActivationFunctionsDataset),
585*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
586*c217d954SCole Faust {
587*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
588*c217d954SCole Faust }
589*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F32)),
590*c217d954SCole Faust ActivationFunctionsDataset),
591*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
592*c217d954SCole Faust {
593*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
594*c217d954SCole Faust }
595*c217d954SCole Faust TEST_SUITE_END() // FP32
596*c217d954SCole Faust
TEST_SUITE(FP32_CustomDataset)597*c217d954SCole Faust TEST_SUITE(FP32_CustomDataset)
598*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::DirectConvolutionLayerDataset(),
599*c217d954SCole Faust framework::dataset::make("DataType", DataType::F32)),
600*c217d954SCole Faust ActivationFunctionsDataset))
601*c217d954SCole Faust {
602*c217d954SCole Faust // Validate output
603*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32);
604*c217d954SCole Faust }
605*c217d954SCole Faust TEST_SUITE_END() // FP32_CustomDataset
606*c217d954SCole Faust TEST_SUITE_END() // Float
607*c217d954SCole Faust
608*c217d954SCole Faust const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
609*c217d954SCole Faust {
610*c217d954SCole Faust ActivationLayerInfo(),
611*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
612*c217d954SCole Faust ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f)
613*c217d954SCole Faust });
614*c217d954SCole Faust TEST_SUITE(Quantized)
TEST_SUITE(QASYMM8)615*c217d954SCole Faust TEST_SUITE(QASYMM8)
616*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit,
617*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
618*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10) })),
619*c217d954SCole Faust QuantizedActivationFunctionsDataset),
620*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
621*c217d954SCole Faust {
622*c217d954SCole Faust // Validate output
623*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
624*c217d954SCole Faust }
625*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit,
626*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
627*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })),
628*c217d954SCole Faust QuantizedActivationFunctionsDataset),
629*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
630*c217d954SCole Faust {
631*c217d954SCole Faust // Validate output
632*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
633*c217d954SCole Faust }
634*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit_9x9,
635*c217d954SCole Faust framework::dataset::make("DataType",
636*c217d954SCole Faust DataType::QASYMM8)),
637*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(3.f / 255, 10), QuantizationInfo(1.1f, 10) })),
638*c217d954SCole Faust QuantizedActivationFunctionsDataset),
639*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
640*c217d954SCole Faust {
641*c217d954SCole Faust // Validate output
642*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
643*c217d954SCole Faust }
644*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly, framework::dataset::make("DataType",
645*c217d954SCole Faust DataType::QASYMM8)),
646*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })),
647*c217d954SCole Faust QuantizedActivationFunctionsDataset),
648*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
649*c217d954SCole Faust {
650*c217d954SCole Faust // Validate output
651*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
652*c217d954SCole Faust }
653*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly_9x9,
654*c217d954SCole Faust framework::dataset::make("DataType",
655*c217d954SCole Faust DataType::QASYMM8)),
656*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(3.f / 255, 10), QuantizationInfo(1.1f, 10) })),
657*c217d954SCole Faust QuantizedActivationFunctionsDataset),
658*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
659*c217d954SCole Faust {
660*c217d954SCole Faust // Validate output
661*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
662*c217d954SCole Faust }
663*c217d954SCole Faust
664*c217d954SCole Faust TEST_SUITE_END() // QASYMM8
665*c217d954SCole Faust
TEST_SUITE(QASYMM8_CustomDataset)666*c217d954SCole Faust TEST_SUITE(QASYMM8_CustomDataset)
667*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
668*c217d954SCole Faust combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(),
669*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8)),
670*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })),
671*c217d954SCole Faust QuantizedActivationFunctionsDataset),
672*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
673*c217d954SCole Faust {
674*c217d954SCole Faust // Validate output
675*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
676*c217d954SCole Faust }
677*c217d954SCole Faust TEST_SUITE_END() // QASYMM8_CustomDataset
678*c217d954SCole Faust
TEST_SUITE(QASYMM8_SIGNED)679*c217d954SCole Faust TEST_SUITE(QASYMM8_SIGNED)
680*c217d954SCole Faust
681*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit, framework::dataset::make("DataType",
682*c217d954SCole Faust DataType::QASYMM8_SIGNED)),
683*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, -10) })),
684*c217d954SCole Faust QuantizedActivationFunctionsDataset),
685*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
686*c217d954SCole Faust {
687*c217d954SCole Faust // Validate output
688*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
689*c217d954SCole Faust }
690*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit,
691*c217d954SCole Faust framework::dataset::make("DataType",
692*c217d954SCole Faust DataType::QASYMM8_SIGNED)),
693*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.1f, -10) })),
694*c217d954SCole Faust QuantizedActivationFunctionsDataset),
695*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
696*c217d954SCole Faust {
697*c217d954SCole Faust // Validate output
698*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
699*c217d954SCole Faust }
700*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit_9x9,
701*c217d954SCole Faust framework::dataset::make("DataType",
702*c217d954SCole Faust DataType::QASYMM8_SIGNED)),
703*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })),
704*c217d954SCole Faust QuantizedActivationFunctionsDataset),
705*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
706*c217d954SCole Faust {
707*c217d954SCole Faust // Validate output
708*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
709*c217d954SCole Faust }
710*c217d954SCole Faust
711*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunCustomDataset, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY,
712*c217d954SCole Faust combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(),
713*c217d954SCole Faust framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
714*c217d954SCole Faust framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })),
715*c217d954SCole Faust QuantizedActivationFunctionsDataset),
716*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })))
717*c217d954SCole Faust {
718*c217d954SCole Faust // Validate output
719*c217d954SCole Faust validate(CLAccessor(_target), _reference, tolerance_qasymm8);
720*c217d954SCole Faust }
721*c217d954SCole Faust
722*c217d954SCole Faust TEST_SUITE_END() // QASYMM8_SIGNED
723*c217d954SCole Faust TEST_SUITE_END() // Quantized
724*c217d954SCole Faust TEST_SUITE_END() // NCHW
725*c217d954SCole Faust TEST_SUITE_END() // DirectConvolutionLayer
726*c217d954SCole Faust TEST_SUITE_END() // CL
727*c217d954SCole Faust
728*c217d954SCole Faust } // namespace validation
729*c217d954SCole Faust } // namespace test
730*c217d954SCole Faust } // namespace arm_compute
731