xref: /aosp_15_r20/external/ComputeLibrary/tests/validation/CL/ConvolutionLayer.cpp (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1*c217d954SCole Faust /*
2*c217d954SCole Faust  * Copyright (c) 2017-2021, 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/core/experimental/PostOps.h"
26*c217d954SCole Faust #include "arm_compute/core/utils/misc/ShapeCalculator.h"
27*c217d954SCole Faust #include "arm_compute/runtime/CL/CLTensor.h"
28*c217d954SCole Faust #include "arm_compute/runtime/CL/CLTensorAllocator.h"
29*c217d954SCole Faust #include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h"
30*c217d954SCole Faust #include "arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h"
31*c217d954SCole Faust #include "tests/CL/CLAccessor.h"
32*c217d954SCole Faust #include "tests/PaddingCalculator.h"
33*c217d954SCole Faust #include "tests/datasets/LargeConvolutionLayerDataset.h"
34*c217d954SCole Faust #include "tests/datasets/SmallConvolutionLayerDataset.h"
35*c217d954SCole Faust #include "tests/datasets/TinyConvolutionLayerDataset.h"
36*c217d954SCole Faust #include "tests/framework/Asserts.h"
37*c217d954SCole Faust #include "tests/framework/Macros.h"
38*c217d954SCole Faust #include "tests/framework/datasets/Datasets.h"
39*c217d954SCole Faust #include "tests/validation/Validation.h"
40*c217d954SCole Faust #include "tests/validation/fixtures/ConvolutionLayerFixture.h"
41*c217d954SCole Faust 
42*c217d954SCole Faust /** Synced with tests/validation/dynamic_fusion/gpu/cl/DirectConv2d.cpp
43*c217d954SCole Faust  *  Please check there for any differences in the coverage
44*c217d954SCole Faust  */
45*c217d954SCole Faust namespace arm_compute
46*c217d954SCole Faust {
47*c217d954SCole Faust namespace test
48*c217d954SCole Faust {
49*c217d954SCole Faust namespace validation
50*c217d954SCole Faust {
51*c217d954SCole Faust namespace
52*c217d954SCole Faust {
53*c217d954SCole Faust class SmallConvolutionLayerDatasetCases final : public datasets::ConvolutionLayerDataset
54*c217d954SCole Faust {
55*c217d954SCole Faust public:
SmallConvolutionLayerDatasetCases()56*c217d954SCole Faust     SmallConvolutionLayerDatasetCases()
57*c217d954SCole Faust     {
58*c217d954SCole Faust         // 1D Kernel
59*c217d954SCole Faust         add_config(TensorShape(1U, 130U, 2000U), TensorShape(1U, 1U, 2000U, 2000U), TensorShape(2000U), TensorShape(1U, 130U, 2000U), PadStrideInfo(1, 1, 0, 0));
60*c217d954SCole Faust     }
61*c217d954SCole Faust };
62*c217d954SCole Faust 
63*c217d954SCole Faust RelativeTolerance<float>            tolerance_f32(0.1f);                  /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
64*c217d954SCole Faust RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.2)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */
65*c217d954SCole Faust constexpr AbsoluteTolerance<float>  tolerance_qasymm8(1);                 /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */
66*c217d954SCole Faust constexpr float                     tolerance_num = 0.07f;                /**< Tolerance number */
67*c217d954SCole Faust 
68*c217d954SCole Faust /** CNN data types */
69*c217d954SCole Faust const auto CNNDataTypes = framework::dataset::make("DataType",
70*c217d954SCole Faust {
71*c217d954SCole Faust     DataType::F16,
72*c217d954SCole Faust     DataType::F32,
73*c217d954SCole Faust     DataType::QASYMM8,
74*c217d954SCole Faust     DataType::QASYMM8_SIGNED,
75*c217d954SCole Faust });
76*c217d954SCole Faust 
77*c217d954SCole Faust /** Grouped CNN data types */
78*c217d954SCole Faust const auto GroupedCNNDataTypes = framework::dataset::make("DataType",
79*c217d954SCole Faust {
80*c217d954SCole Faust     DataType::F16,
81*c217d954SCole Faust     DataType::F32
82*c217d954SCole Faust });
83*c217d954SCole Faust 
84*c217d954SCole Faust const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
85*c217d954SCole Faust {
86*c217d954SCole Faust     ActivationLayerInfo(),
87*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
88*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f),
89*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f)
90*c217d954SCole Faust });
91*c217d954SCole Faust const auto ActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo",
92*c217d954SCole Faust {
93*c217d954SCole Faust     ActivationLayerInfo(),
94*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f)
95*c217d954SCole Faust });
96*c217d954SCole Faust 
is_post_op_list_valid_in_gemmconv(const TensorShape & input_shape,const TensorShape & weights_shape,const TensorShape & output_shape,DataType data_type,DataLayout data_layout,const PadStrideInfo & conv_info,const experimental::PostOpList<ITensorInfo * > & post_ops)97*c217d954SCole Faust bool is_post_op_list_valid_in_gemmconv(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &output_shape, DataType data_type, DataLayout data_layout,
98*c217d954SCole Faust                                        const PadStrideInfo &conv_info, const experimental::PostOpList<ITensorInfo *> &post_ops)
99*c217d954SCole Faust {
100*c217d954SCole Faust     const int idx_width   = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
101*c217d954SCole Faust     const int idx_height  = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
102*c217d954SCole Faust     const int idx_kernels = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
103*c217d954SCole Faust 
104*c217d954SCole Faust     const auto         dilation   = Size2D(1U, 1U);
105*c217d954SCole Faust     const unsigned int num_groups = 1U;
106*c217d954SCole Faust 
107*c217d954SCole Faust     TensorInfo input_info(input_shape, 1, data_type, data_layout);
108*c217d954SCole Faust     TensorInfo weights_info(weights_shape, 1, data_type, data_layout);
109*c217d954SCole Faust 
110*c217d954SCole Faust     TensorInfo output_info(output_shape, 1, data_type, data_layout);
111*c217d954SCole Faust 
112*c217d954SCole Faust     WeightsInfo w_info(false, weights_info.dimension(idx_width), weights_info.dimension(idx_height), weights_info.dimension(idx_kernels));
113*c217d954SCole Faust 
114*c217d954SCole Faust     const auto status = CLGEMMConvolutionLayer::validate(&input_info.clone()->set_is_resizable(true),
115*c217d954SCole Faust                                                          &weights_info.clone()->set_is_resizable(true), nullptr, &output_info.clone()->set_is_resizable(true),
116*c217d954SCole Faust                                                          conv_info, w_info, dilation, ActivationLayerInfo(), num_groups, post_ops);
117*c217d954SCole Faust     return bool(status);
118*c217d954SCole Faust }
119*c217d954SCole Faust } // namespace
120*c217d954SCole Faust 
121*c217d954SCole Faust TEST_SUITE(CL)
TEST_SUITE(ConvolutionLayer)122*c217d954SCole Faust TEST_SUITE(ConvolutionLayer)
123*c217d954SCole Faust 
124*c217d954SCole Faust // *INDENT-OFF*
125*c217d954SCole Faust // clang-format off
126*c217d954SCole Faust DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
127*c217d954SCole Faust                                           framework::dataset::make("InputInfo", { TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32),            // Select GEMM
128*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32),            // Select GEMM
129*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32),        // Select GEMM
130*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(23U, 27U, 31U, 4U), 1, DataType::F32),       // Select WINOGRAD
131*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(3U, 3U, 2U, 1U), 1, DataType::F32),          // Select GEMM
132*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32),        // Select GEMM
133*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(17U, 31U, 32U), 1, DataType::F32),           // Select WINOGRAD
134*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32),            // Select GEMM
135*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::QASYMM8_SIGNED), // Select GEMM
136*c217d954SCole Faust                                           }),
137*c217d954SCole Faust                                           framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32),
138*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32),
139*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
140*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(3U, 3U, 31U, 21U), 1, DataType::F32),
141*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
142*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16),
143*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 32U, 19U), 1, DataType::F32),
144*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32),
145*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::QASYMM8_SIGNED),
146*c217d954SCole Faust                                           })),
147*c217d954SCole Faust                                           framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
148*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
149*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
150*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
151*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32),
152*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32),
153*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
154*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
155*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::QASYMM8_SIGNED),
156*c217d954SCole Faust                                           })),
157*c217d954SCole Faust                                           framework::dataset::make("ConvInfo", { PadStrideInfo(1, 2, 1, 1),
158*c217d954SCole Faust                                                                                  PadStrideInfo(1, 2, 1, 1),
159*c217d954SCole Faust                                                                                  PadStrideInfo(1, 1, 0, 0),
160*c217d954SCole Faust                                                                                  PadStrideInfo(1, 1, 0, 0),
161*c217d954SCole Faust                                                                                  PadStrideInfo(2, 1, 0, 0),
162*c217d954SCole Faust                                                                                  PadStrideInfo(3, 2, 1, 0),
163*c217d954SCole Faust                                                                                  PadStrideInfo(1, 1, 2, 2),
164*c217d954SCole Faust                                                                                  PadStrideInfo(1, 1, 2, 2),
165*c217d954SCole Faust                                                                                  PadStrideInfo(1, 1, 2, 2),
166*c217d954SCole Faust                                           })),
167*c217d954SCole Faust                                           framework::dataset::make("GpuTarget", { GPUTarget::BIFROST,
168*c217d954SCole Faust                                                                                   GPUTarget::MIDGARD,
169*c217d954SCole Faust                                                                                   GPUTarget::G71,
170*c217d954SCole Faust                                                                                   GPUTarget::G71,
171*c217d954SCole Faust                                                                                   GPUTarget::MIDGARD,
172*c217d954SCole Faust                                                                                   GPUTarget::BIFROST,
173*c217d954SCole Faust                                                                                   GPUTarget::BIFROST,
174*c217d954SCole Faust                                                                                   GPUTarget::BIFROST,
175*c217d954SCole Faust                                                                                   GPUTarget::BIFROST,
176*c217d954SCole Faust                                           })),
177*c217d954SCole Faust                                           framework::dataset::make("Dilation", { Size2D(1U, 1U),
178*c217d954SCole Faust                                                                  Size2D(1U, 1U),
179*c217d954SCole Faust                                                                  Size2D(1U, 1U),
180*c217d954SCole Faust                                                                  Size2D(1U, 1U),
181*c217d954SCole Faust                                                                  Size2D(1U, 1U),
182*c217d954SCole Faust                                                                  Size2D(1U, 1U),
183*c217d954SCole Faust                                                                  Size2D(1U, 1U),
184*c217d954SCole Faust                                                                  Size2D(2U, 1U),
185*c217d954SCole Faust                                                                  Size2D(2U, 1U),
186*c217d954SCole Faust                                           })),
187*c217d954SCole Faust                                          framework::dataset::make("EnableFastMath", { false, false, false, false, false, false, true, true, true })),
188*c217d954SCole Faust                                          framework::dataset::make("Expected",{ ConvolutionMethod::GEMM,
189*c217d954SCole Faust                                                                                ConvolutionMethod::GEMM,
190*c217d954SCole Faust                                                                                ConvolutionMethod::GEMM,
191*c217d954SCole Faust                                                                                ConvolutionMethod::WINOGRAD,
192*c217d954SCole Faust                                                                                ConvolutionMethod::GEMM,
193*c217d954SCole Faust                                                                                ConvolutionMethod::GEMM,
194*c217d954SCole Faust                                                                                ConvolutionMethod::WINOGRAD,
195*c217d954SCole Faust                                                                                ConvolutionMethod::GEMM,
196*c217d954SCole Faust                                                                                ConvolutionMethod::GEMM,
197*c217d954SCole Faust                                          })),
198*c217d954SCole Faust                                          input_info, weights_info, output_info, conv_info, gpu_target, dilation, enable_fast_math, expected)
199*c217d954SCole Faust {
200*c217d954SCole Faust     ConvolutionMethod is_valid = CLConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true),
201*c217d954SCole Faust                                                                             &weights_info.clone()->set_is_resizable(true),
202*c217d954SCole Faust                                                                             &output_info.clone()->set_is_resizable(true), conv_info,
203*c217d954SCole Faust                                                                             WeightsInfo(),
204*c217d954SCole Faust                                                                             ActivationLayerInfo(),
205*c217d954SCole Faust                                                                             gpu_target,
206*c217d954SCole Faust                                                                             dilation,
207*c217d954SCole Faust                                                                             enable_fast_math);
208*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
209*c217d954SCole Faust }
210*c217d954SCole Faust 
211*c217d954SCole Faust DATA_TEST_CASE(ValidatePostOpSupportInConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(
212*c217d954SCole Faust                                           framework::dataset::make("InputInfo", { TensorInfo(TensorShape(2U, 17U, 31U), 1, DataType::F32, DataLayout::NHWC),            // Select GEMM
213*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(17U, 31U, 32U), 1, DataType::F32, DataLayout::NCHW),           // Select WINOGRAD
214*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(27U, 27U, 48U), 1, DataType::F32, DataLayout::NCHW),           // Select Direct
215*c217d954SCole Faust                                                                                   TensorInfo(TensorShape(27U, 27U, 48U), 1, DataType::F32, DataLayout::NCHW),           // Select FFT
216*c217d954SCole Faust                                           }),
217*c217d954SCole Faust                                           framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(2U, 1U, 1U, 19U), 1, DataType::F32, DataLayout::NHWC),
218*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 32U, 19U), 1, DataType::F32, DataLayout::NCHW),
219*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(5U, 5U, 48U, 128U), 1, DataType::F32, DataLayout::NCHW),
220*c217d954SCole Faust                                                                                     TensorInfo(TensorShape(11U, 11U, 48U, 24), 1, DataType::F32, DataLayout::NCHW),
221*c217d954SCole Faust                                           })),
222*c217d954SCole Faust                                           framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(19U, 17U, 31U), 1, DataType::F32, DataLayout::NHWC),
223*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32, DataLayout::NCHW),
224*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(27U, 27U, 128U), 1, DataType::F32, DataLayout::NCHW),
225*c217d954SCole Faust                                                                                    TensorInfo(TensorShape(27U, 27U, 24U), 1, DataType::F32, DataLayout::NCHW),
226*c217d954SCole Faust                                           })),
227*c217d954SCole Faust                                           framework::dataset::make("ConvInfo", { PadStrideInfo(1U, 1U, 0U, 0U),
228*c217d954SCole Faust                                                                                  PadStrideInfo(1U, 1U, 2U, 2U),
229*c217d954SCole Faust                                                                                  PadStrideInfo(1U, 1U, 2U, 2U),
230*c217d954SCole Faust                                                                                  PadStrideInfo(1U, 1U, 5U, 5U),
231*c217d954SCole Faust                                           })),
232*c217d954SCole Faust                                          framework::dataset::make("EnableFastMath", { false, true, false, false})),
233*c217d954SCole Faust                                          framework::dataset::make("ExpectedMethod",{ ConvolutionMethod::GEMM,
234*c217d954SCole Faust                                                                                      ConvolutionMethod::WINOGRAD,
235*c217d954SCole Faust                                                                                      ConvolutionMethod::DIRECT,
236*c217d954SCole Faust                                                                                      ConvolutionMethod::FFT,
237*c217d954SCole Faust                                          })),
238*c217d954SCole Faust                                          framework::dataset::make("PostOpSupported",{ true, false, false, false
239*c217d954SCole Faust                                          })),
240*c217d954SCole Faust                                          input_info, weights_info, output_info, conv_info, enable_fast_math, expected_method, post_op_supported)
241*c217d954SCole Faust {
242*c217d954SCole Faust     const int idx_width  = get_data_layout_dimension_index(input_info.data_layout(), DataLayoutDimension::WIDTH);
243*c217d954SCole Faust     const int idx_height = get_data_layout_dimension_index(input_info.data_layout(), DataLayoutDimension::HEIGHT);
244*c217d954SCole Faust     const int idx_kernels = get_data_layout_dimension_index(input_info.data_layout(), DataLayoutDimension::BATCHES);
245*c217d954SCole Faust 
246*c217d954SCole Faust     const auto dilation = Size2D(1U, 1U);
247*c217d954SCole Faust     const unsigned int num_groups = 1U;
248*c217d954SCole Faust 
249*c217d954SCole Faust     WeightsInfo w_info(false, weights_info.dimension(idx_width), weights_info.dimension(idx_height), weights_info.dimension(idx_kernels));
250*c217d954SCole Faust 
251*c217d954SCole Faust     experimental::PostOpList<ITensorInfo*> post_ops{};
252*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpAct<ITensorInfo*>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F});
253*c217d954SCole Faust 
254*c217d954SCole Faust     ConvolutionMethod actual_method = CLConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true),
255*c217d954SCole Faust                                                                             &weights_info.clone()->set_is_resizable(true),
256*c217d954SCole Faust                                                                             &output_info.clone()->set_is_resizable(true), conv_info,
257*c217d954SCole Faust                                                                             WeightsInfo(),
258*c217d954SCole Faust                                                                             ActivationLayerInfo(),
259*c217d954SCole Faust                                                                             GPUTarget::BIFROST,
260*c217d954SCole Faust                                                                             dilation,
261*c217d954SCole Faust                                                                             enable_fast_math);
262*c217d954SCole Faust     ARM_COMPUTE_EXPECT(actual_method == expected_method, framework::LogLevel::ERRORS);
263*c217d954SCole Faust     const auto is_valid = CLConvolutionLayer::validate(&input_info.clone()->set_is_resizable(true),
264*c217d954SCole Faust                                                                             &weights_info.clone()->set_is_resizable(true),
265*c217d954SCole Faust                                                                             nullptr,
266*c217d954SCole Faust                                                                             &output_info.clone()->set_is_resizable(true),
267*c217d954SCole Faust                                                                             conv_info,
268*c217d954SCole Faust                                                                             w_info,
269*c217d954SCole Faust                                                                             dilation,
270*c217d954SCole Faust                                                                             ActivationLayerInfo(),
271*c217d954SCole Faust                                                                             enable_fast_math,
272*c217d954SCole Faust                                                                             num_groups,
273*c217d954SCole Faust                                                                             post_ops);
274*c217d954SCole Faust     ARM_COMPUTE_EXPECT( bool(is_valid) == post_op_supported, framework::LogLevel::ERRORS);
275*c217d954SCole Faust }
276*c217d954SCole Faust // clang-format on
277*c217d954SCole Faust // *INDENT-ON*
278*c217d954SCole Faust TEST_SUITE_END() // ConvolutionLayer
279*c217d954SCole Faust 
280*c217d954SCole Faust TEST_SUITE(GEMMConvolutionLayer)
281*c217d954SCole Faust template <typename T>
282*c217d954SCole Faust using CLGEMMConvolutionLayerFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
283*c217d954SCole Faust template <typename T>
284*c217d954SCole Faust using CLGEMMConvolutionLayerMixedDataLayoutFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, true>;
285*c217d954SCole Faust template <typename T>
286*c217d954SCole Faust using CLConvolutionValidationWithPaddingFixture = ConvolutionValidationWithPaddingFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
287*c217d954SCole Faust 
288*c217d954SCole Faust TEST_SUITE(ValidateFusedPostOpsConfigs)
TEST_SUITE(Invalid)289*c217d954SCole Faust TEST_SUITE(Invalid)
290*c217d954SCole Faust TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL)
291*c217d954SCole Faust {
292*c217d954SCole Faust     const auto data_type     = DataType::F32;
293*c217d954SCole Faust     const auto data_layout   = DataLayout::NHWC;
294*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(1, 1, 0, 0);
295*c217d954SCole Faust     const auto input_shape   = TensorShape(16U, 14U, 12U, 2U);
296*c217d954SCole Faust     const auto weights_shape = TensorShape(16U, 1U, 1U, 24U);
297*c217d954SCole Faust 
298*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
299*c217d954SCole Faust 
300*c217d954SCole Faust     const TensorShape post_op_arg0_shape(output_shape);
301*c217d954SCole Faust     TensorInfo        post_op_arg_info(post_op_arg0_shape, 1, data_type);
302*c217d954SCole Faust     auto              post_op_arg1_info = post_op_arg_info.clone();
303*c217d954SCole Faust 
304*c217d954SCole Faust     // Unsupported sequence of post ops
305*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
306*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
307*c217d954SCole Faust                                                                           &post_op_arg_info,
308*c217d954SCole Faust                                                                           1,
309*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
310*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
311*c217d954SCole Faust                                                                           post_op_arg1_info.get(),
312*c217d954SCole Faust                                                                           0,
313*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
314*c217d954SCole Faust 
315*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS);
316*c217d954SCole Faust }
TEST_CASE(OnlyNHWCIsSupported,framework::DatasetMode::ALL)317*c217d954SCole Faust TEST_CASE(OnlyNHWCIsSupported, framework::DatasetMode::ALL)
318*c217d954SCole Faust {
319*c217d954SCole Faust     const auto data_type     = DataType::F32;
320*c217d954SCole Faust     const auto data_layout   = DataLayout::NCHW;
321*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(1, 1, 0, 0);
322*c217d954SCole Faust     const auto input_shape   = TensorShape(14U, 12U, 16U, 2U);
323*c217d954SCole Faust     const auto weights_shape = TensorShape(1U, 1U, 16U, 24U);
324*c217d954SCole Faust 
325*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
326*c217d954SCole Faust 
327*c217d954SCole Faust     const TensorShape post_op_arg0_shape(output_shape);
328*c217d954SCole Faust     TensorInfo        post_op_arg_info(post_op_arg0_shape, 1, data_type);
329*c217d954SCole Faust 
330*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
331*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
332*c217d954SCole Faust                                                                           &post_op_arg_info,
333*c217d954SCole Faust                                                                           1,
334*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
335*c217d954SCole Faust 
336*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS);
337*c217d954SCole Faust }
TEST_CASE(OnlyFloatingTypeIsSupported,framework::DatasetMode::ALL)338*c217d954SCole Faust TEST_CASE(OnlyFloatingTypeIsSupported, framework::DatasetMode::ALL)
339*c217d954SCole Faust {
340*c217d954SCole Faust     const auto data_type     = DataType::QASYMM8;
341*c217d954SCole Faust     const auto data_layout   = DataLayout::NHWC;
342*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(1, 1, 0, 0);
343*c217d954SCole Faust     const auto input_shape   = TensorShape(16U, 14U, 12U, 2U);
344*c217d954SCole Faust     const auto weights_shape = TensorShape(16U, 1U, 1U, 24U);
345*c217d954SCole Faust 
346*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
347*c217d954SCole Faust 
348*c217d954SCole Faust     const TensorShape post_op_arg0_shape(output_shape);
349*c217d954SCole Faust     TensorInfo        post_op_arg_info(post_op_arg0_shape, 1, data_type);
350*c217d954SCole Faust 
351*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
352*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
353*c217d954SCole Faust                                                                           &post_op_arg_info,
354*c217d954SCole Faust                                                                           1,
355*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
356*c217d954SCole Faust 
357*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS);
358*c217d954SCole Faust }
TEST_CASE(OnlyConv1x1Stride1IsSupported_UnsupportedKernelSize,framework::DatasetMode::ALL)359*c217d954SCole Faust TEST_CASE(OnlyConv1x1Stride1IsSupported_UnsupportedKernelSize, framework::DatasetMode::ALL)
360*c217d954SCole Faust {
361*c217d954SCole Faust     const auto data_type     = DataType::F32;
362*c217d954SCole Faust     const auto data_layout   = DataLayout::NHWC;
363*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(1, 1, 0, 0);
364*c217d954SCole Faust     const auto input_shape   = TensorShape(16U, 14U, 12U, 2U);
365*c217d954SCole Faust     const auto weights_shape = TensorShape(16U, 3U, 3U, 24U);
366*c217d954SCole Faust 
367*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
368*c217d954SCole Faust 
369*c217d954SCole Faust     const TensorShape post_op_arg0_shape(output_shape);
370*c217d954SCole Faust     TensorInfo        post_op_arg_info(post_op_arg0_shape, 1, data_type);
371*c217d954SCole Faust 
372*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
373*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
374*c217d954SCole Faust                                                                           &post_op_arg_info,
375*c217d954SCole Faust                                                                           1,
376*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
377*c217d954SCole Faust 
378*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS);
379*c217d954SCole Faust }
TEST_CASE(OnlyConv1x1Stride1IsSupported_UnsupportedStride,framework::DatasetMode::ALL)380*c217d954SCole Faust TEST_CASE(OnlyConv1x1Stride1IsSupported_UnsupportedStride, framework::DatasetMode::ALL)
381*c217d954SCole Faust {
382*c217d954SCole Faust     const auto data_type     = DataType::F32;
383*c217d954SCole Faust     const auto data_layout   = DataLayout::NHWC;
384*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(3, 3, 0, 0);
385*c217d954SCole Faust     const auto input_shape   = TensorShape(16U, 14U, 12U, 2U);
386*c217d954SCole Faust     const auto weights_shape = TensorShape(16U, 1U, 1U, 24U);
387*c217d954SCole Faust 
388*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
389*c217d954SCole Faust 
390*c217d954SCole Faust     const TensorShape post_op_arg0_shape(output_shape);
391*c217d954SCole Faust     TensorInfo        post_op_arg_info(post_op_arg0_shape, 1, data_type);
392*c217d954SCole Faust 
393*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
394*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
395*c217d954SCole Faust                                                                           &post_op_arg_info,
396*c217d954SCole Faust                                                                           1,
397*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
398*c217d954SCole Faust 
399*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == false, framework::LogLevel::ERRORS);
400*c217d954SCole Faust }
401*c217d954SCole Faust TEST_SUITE_END() // Invalid
TEST_SUITE(Valid)402*c217d954SCole Faust TEST_SUITE(Valid)
403*c217d954SCole Faust TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL)
404*c217d954SCole Faust {
405*c217d954SCole Faust     const auto data_type     = DataType::F32;
406*c217d954SCole Faust     const auto data_layout   = DataLayout::NHWC;
407*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(1, 1, 0, 0);
408*c217d954SCole Faust     const auto input_shape   = TensorShape(16U, 14U, 12U, 2U);
409*c217d954SCole Faust     const auto weights_shape = TensorShape(16U, 1U, 1U, 24U);
410*c217d954SCole Faust 
411*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
412*c217d954SCole Faust 
413*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
414*c217d954SCole Faust 
415*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == true, framework::LogLevel::ERRORS);
416*c217d954SCole Faust }
TEST_CASE(SupportedPostOps,framework::DatasetMode::ALL)417*c217d954SCole Faust TEST_CASE(SupportedPostOps, framework::DatasetMode::ALL)
418*c217d954SCole Faust {
419*c217d954SCole Faust     const auto data_type     = DataType::F32;
420*c217d954SCole Faust     const auto data_layout   = DataLayout::NHWC;
421*c217d954SCole Faust     const auto conv_info     = PadStrideInfo(1, 1, 0, 0);
422*c217d954SCole Faust     const auto input_shape   = TensorShape(16U, 14U, 12U, 2U);
423*c217d954SCole Faust     const auto weights_shape = TensorShape(16U, 1U, 1U, 24U);
424*c217d954SCole Faust 
425*c217d954SCole Faust     const auto output_shape = misc::shape_calculator::compute_deep_convolution_shape(input_shape, data_layout, weights_shape, conv_info);
426*c217d954SCole Faust 
427*c217d954SCole Faust     TensorShape post_op_arg0_shape(output_shape);
428*c217d954SCole Faust     post_op_arg0_shape[1] = 1; // Broadcast in "Y" (second) dimension
429*c217d954SCole Faust     TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type);
430*c217d954SCole Faust 
431*c217d954SCole Faust     experimental::PostOpList<ITensorInfo *> post_ops{};
432*c217d954SCole Faust     post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo *>>(
433*c217d954SCole Faust                                                                           &post_op_arg_info,
434*c217d954SCole Faust                                                                           1,
435*c217d954SCole Faust                                                                           ConvertPolicy::SATURATE);
436*c217d954SCole Faust 
437*c217d954SCole Faust     ARM_COMPUTE_EXPECT(is_post_op_list_valid_in_gemmconv(input_shape, weights_shape, output_shape, data_type, data_layout, conv_info, post_ops) == true, framework::LogLevel::ERRORS);
438*c217d954SCole Faust }
439*c217d954SCole Faust TEST_SUITE_END() // Valid
TEST_SUITE_END()440*c217d954SCole Faust TEST_SUITE_END() // ValidateFusedPostOps
441*c217d954SCole Faust TEST_SUITE(Float)
442*c217d954SCole Faust TEST_SUITE(FP16)
443*c217d954SCole Faust 
444*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
445*c217d954SCole Faust                                                                                                                    framework::dataset::make("ReshapeWeights", { true })),
446*c217d954SCole Faust                                                                                                                    framework::dataset::make("DataType",
447*c217d954SCole Faust                                                                                                                            DataType::F16)),
448*c217d954SCole Faust                                                                                                                    framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
449*c217d954SCole Faust                                                                                                            ActivationFunctionsSmallDataset))
450*c217d954SCole Faust {
451*c217d954SCole Faust     // Validate output
452*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
453*c217d954SCole Faust }
454*c217d954SCole Faust TEST_SUITE_END() // FP16
455*c217d954SCole Faust 
TEST_SUITE(FP32)456*c217d954SCole Faust TEST_SUITE(FP32)
457*c217d954SCole Faust 
458*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
459*c217d954SCole Faust                                                                                                                     framework::dataset::make("ReshapeWeights", { true })),
460*c217d954SCole Faust                                                                                                                     framework::dataset::make("DataType",
461*c217d954SCole Faust                                                                                                                             DataType::F32)),
462*c217d954SCole Faust                                                                                                                     framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
463*c217d954SCole Faust                                                                                                             ActivationFunctionsSmallDataset))
464*c217d954SCole Faust {
465*c217d954SCole Faust     // Validate output
466*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32);
467*c217d954SCole Faust }
468*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLGEMMConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::ALL,
469*c217d954SCole Faust                        combine(combine(combine(combine(combine(combine(combine(combine(combine(
470*c217d954SCole Faust                                                                                            framework::dataset::make("Input", TensorShape(23U, 27U, 5U)),
471*c217d954SCole Faust                                                                                            framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))),
472*c217d954SCole Faust                                                                                        framework::dataset::make("Bias", TensorShape(2U))),
473*c217d954SCole Faust                                                                                framework::dataset::make("Output", TensorShape(11U, 25U, 2U))),
474*c217d954SCole Faust                                                                        framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))),
475*c217d954SCole Faust                                                                framework::dataset::make("Dilation", Size2D(1, 1))),
476*c217d954SCole Faust                                                        framework::dataset::make("ReshapeWeights", { true })),
477*c217d954SCole Faust                                                framework::dataset::make("DataType", DataType::F32)),
478*c217d954SCole Faust                                        framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
479*c217d954SCole Faust                                ActivationFunctionsSmallDataset))
480*c217d954SCole Faust {
481*c217d954SCole Faust     // Validate output
482*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32);
483*c217d954SCole Faust }
484*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallWithPadding, CLConvolutionValidationWithPaddingFixture<float>, framework::DatasetMode::ALL,
485*c217d954SCole Faust                        combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerPrePaddingDataset(),
486*c217d954SCole Faust                                                                framework::dataset::make("ReshapeWeights", { true })),
487*c217d954SCole Faust                                                        framework::dataset::make("DataType", DataType::F32)),
488*c217d954SCole Faust                                                framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
489*c217d954SCole Faust                                        framework::dataset::make("ActivationInfo", { ActivationLayerInfo() })),
490*c217d954SCole Faust framework::dataset::make("PrePadLayer", { PaddingList({ { 1, 1 }, { 1, 1 } }) })))
491*c217d954SCole Faust {
492*c217d954SCole Faust     // Validate output
493*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32);
494*c217d954SCole Faust }
495*c217d954SCole Faust 
496*c217d954SCole Faust TEST_SUITE_END() // FP32
497*c217d954SCole Faust TEST_SUITE_END() // Float
498*c217d954SCole Faust 
499*c217d954SCole Faust template <typename T>
500*c217d954SCole Faust using CLGEMMConvolutionLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
501*c217d954SCole Faust template <typename T>
502*c217d954SCole Faust using CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture = ConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, true>;
503*c217d954SCole Faust template <typename T>
504*c217d954SCole Faust using CLGEMMConvolutionLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, int8_t>;
505*c217d954SCole Faust 
506*c217d954SCole Faust const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
507*c217d954SCole Faust {
508*c217d954SCole Faust     ActivationLayerInfo(),
509*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
510*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f)
511*c217d954SCole Faust });
512*c217d954SCole Faust const auto QuantizedActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo",
513*c217d954SCole Faust {
514*c217d954SCole Faust     ActivationLayerInfo(),
515*c217d954SCole Faust     ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f)
516*c217d954SCole Faust });
517*c217d954SCole Faust 
518*c217d954SCole Faust TEST_SUITE(Quantized)
519*c217d954SCole Faust 
520*c217d954SCole Faust const auto QuantizationData = framework::dataset::make("QuantizationInfo",
521*c217d954SCole Faust {
522*c217d954SCole Faust     QuantizationInfo(0.5f, 10),
523*c217d954SCole Faust     QuantizationInfo(0.3f, 3),
524*c217d954SCole Faust     QuantizationInfo(1.1f, 10),
525*c217d954SCole Faust });
526*c217d954SCole Faust TEST_SUITE(QASYMM8)
527*c217d954SCole Faust 
528*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallCases, CLGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL,
529*c217d954SCole Faust                        combine(combine(combine(combine(combine(SmallConvolutionLayerDatasetCases(),
530*c217d954SCole Faust                                                                framework::dataset::make("ReshapeWeights", { true })),
531*c217d954SCole Faust                                                        framework::dataset::make("DataType", DataType::QASYMM8)),
532*c217d954SCole Faust                                                framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
533*c217d954SCole Faust                                        QuantizationData),
534*c217d954SCole Faust                                QuantizedActivationFunctionsSmallDataset))
535*c217d954SCole Faust {
536*c217d954SCole Faust     // Validate output
537*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
538*c217d954SCole Faust }
539*c217d954SCole Faust 
540*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL,
541*c217d954SCole Faust                        combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
542*c217d954SCole Faust                                                                framework::dataset::make("ReshapeWeights", { true })),
543*c217d954SCole Faust                                                        framework::dataset::make("DataType", DataType::QASYMM8)),
544*c217d954SCole Faust                                                framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
545*c217d954SCole Faust                                        QuantizationData),
546*c217d954SCole Faust                                QuantizedActivationFunctionsSmallDataset))
547*c217d954SCole Faust {
548*c217d954SCole Faust     // Validate output
549*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
550*c217d954SCole Faust }
551*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::ALL,
552*c217d954SCole Faust                        combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
553*c217d954SCole Faust                                                                                                    framework::dataset::make("Input", TensorShape(23U, 27U, 5U)),
554*c217d954SCole Faust                                                                                                    framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))),
555*c217d954SCole Faust                                                                                                framework::dataset::make("Bias", TensorShape(2U))),
556*c217d954SCole Faust                                                                                        framework::dataset::make("Output", TensorShape(11U, 25U, 2U))),
557*c217d954SCole Faust                                                                                framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))),
558*c217d954SCole Faust                                                                        framework::dataset::make("Dilation", Size2D(1, 1))),
559*c217d954SCole Faust                                                                framework::dataset::make("ReshapeWeights", { true })),
560*c217d954SCole Faust                                                        framework::dataset::make("DataType", DataType::QASYMM8)),
561*c217d954SCole Faust                                                framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
562*c217d954SCole Faust                                        QuantizationData),
563*c217d954SCole Faust                                QuantizedActivationFunctionsSmallDataset))
564*c217d954SCole Faust {
565*c217d954SCole Faust     // Validate output
566*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
567*c217d954SCole Faust }
568*c217d954SCole Faust TEST_SUITE_END() // QASYMM8
TEST_SUITE(QASYMM8_SIGNED)569*c217d954SCole Faust TEST_SUITE(QASYMM8_SIGNED)
570*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL,
571*c217d954SCole Faust                        combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
572*c217d954SCole Faust                                                                framework::dataset::make("ReshapeWeights", { true })),
573*c217d954SCole Faust                                                        framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
574*c217d954SCole Faust                                                framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
575*c217d954SCole Faust                                        QuantizationData),
576*c217d954SCole Faust                                QuantizedActivationFunctionsSmallDataset))
577*c217d954SCole Faust {
578*c217d954SCole Faust     // Validate output
579*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
580*c217d954SCole Faust }
581*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture<int8_t>, framework::DatasetMode::ALL,
582*c217d954SCole Faust                        combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
583*c217d954SCole Faust                                                                                                    framework::dataset::make("Input", TensorShape(23U, 27U, 5U)),
584*c217d954SCole Faust                                                                                                    framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))),
585*c217d954SCole Faust                                                                                                framework::dataset::make("Bias", TensorShape(2U))),
586*c217d954SCole Faust                                                                                        framework::dataset::make("Output", TensorShape(11U, 25U, 2U))),
587*c217d954SCole Faust                                                                                framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))),
588*c217d954SCole Faust                                                                        framework::dataset::make("Dilation", Size2D(1, 1))),
589*c217d954SCole Faust                                                                framework::dataset::make("ReshapeWeights", { true })),
590*c217d954SCole Faust                                                        framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
591*c217d954SCole Faust                                                framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
592*c217d954SCole Faust                                        QuantizationData),
593*c217d954SCole Faust                                QuantizedActivationFunctionsSmallDataset))
594*c217d954SCole Faust {
595*c217d954SCole Faust     // Validate output
596*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
597*c217d954SCole Faust }
598*c217d954SCole Faust TEST_SUITE_END() // QASYMM8_SIGNED
TEST_SUITE(QSYMM8_PER_CHANNEL)599*c217d954SCole Faust TEST_SUITE(QSYMM8_PER_CHANNEL)
600*c217d954SCole Faust 
601*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLGEMMConvolutionLayerQuantizedPerChannelFixture<int8_t>, framework::DatasetMode::ALL,
602*c217d954SCole Faust                        combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
603*c217d954SCole Faust                                                                        framework::dataset::make("ReshapeWeights", { true })),
604*c217d954SCole Faust                                                                framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED })),
605*c217d954SCole Faust                                                        framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
606*c217d954SCole Faust                                                QuantizationData),
607*c217d954SCole Faust                                        QuantizedActivationFunctionsSmallDataset),
608*c217d954SCole Faust                                framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
609*c217d954SCole Faust {
610*c217d954SCole Faust     // Validate output
611*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
612*c217d954SCole Faust }
613*c217d954SCole Faust 
614*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedPerChannelFixture<uint8_t>, framework::DatasetMode::ALL,
615*c217d954SCole Faust                        combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
616*c217d954SCole Faust                                                                        framework::dataset::make("ReshapeWeights", { true })),
617*c217d954SCole Faust                                                                framework::dataset::make("DataType", { DataType::QASYMM8 })),
618*c217d954SCole Faust                                                        framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
619*c217d954SCole Faust                                                QuantizationData),
620*c217d954SCole Faust                                        QuantizedActivationFunctionsSmallDataset),
621*c217d954SCole Faust                                framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
622*c217d954SCole Faust {
623*c217d954SCole Faust     // Validate output
624*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_qasymm8);
625*c217d954SCole Faust }
626*c217d954SCole Faust TEST_SUITE_END() // QSYMM8_PER_CHANNEL
627*c217d954SCole Faust TEST_SUITE_END() // Quantized
628*c217d954SCole Faust 
629*c217d954SCole Faust TEST_SUITE_END() // GEMMConvolutionLayer
630*c217d954SCole Faust 
631*c217d954SCole Faust template <typename T>
632*c217d954SCole Faust using CLGEMMGroupedConvolutionLayerFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
633*c217d954SCole Faust 
634*c217d954SCole Faust TEST_SUITE(GroupedGEMMConvolutionLayer)
635*c217d954SCole Faust 
TEST_SUITE(Float)636*c217d954SCole Faust TEST_SUITE(Float)
637*c217d954SCole Faust TEST_SUITE(FP32)
638*c217d954SCole Faust 
639*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(),
640*c217d954SCole Faust                                                                                                                    framework::dataset::make("ReshapeWeights", { true })),
641*c217d954SCole Faust                                                                                                                    framework::dataset::make("DataType", DataType::F32)),
642*c217d954SCole Faust                                                                                                                    framework::dataset::make("DataLayout", { DataLayout::NCHW })),
643*c217d954SCole Faust                                                                                                                    ActivationFunctionsSmallDataset))
644*c217d954SCole Faust {
645*c217d954SCole Faust     // Validate output
646*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
647*c217d954SCole Faust }
648*c217d954SCole Faust 
649*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMGroupedConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY,
650*c217d954SCole Faust                        combine(combine(combine(combine(datasets::LargeGroupedConvolutionLayerDataset(),
651*c217d954SCole Faust                                                        framework::dataset::make("ReshapeWeights", { true })),
652*c217d954SCole Faust                                                framework::dataset::make("DataType", DataType::F32)),
653*c217d954SCole Faust                                        framework::dataset::make("DataLayout", { DataLayout::NCHW })),
654*c217d954SCole Faust                                ActivationFunctionsDataset))
655*c217d954SCole Faust {
656*c217d954SCole Faust     // Validate output
657*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
658*c217d954SCole Faust }
659*c217d954SCole Faust TEST_SUITE_END() // FP32
660*c217d954SCole Faust 
TEST_SUITE(FP16)661*c217d954SCole Faust TEST_SUITE(FP16)
662*c217d954SCole Faust 
663*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(),
664*c217d954SCole Faust                                                                                                                   framework::dataset::make("ReshapeWeights", { true })),
665*c217d954SCole Faust                                                                                                                   framework::dataset::make("DataType", DataType::F16)),
666*c217d954SCole Faust                                                                                                                   framework::dataset::make("DataLayout", { DataLayout::NCHW })),
667*c217d954SCole Faust                                                                                                                   ActivationFunctionsSmallDataset))
668*c217d954SCole Faust {
669*c217d954SCole Faust     // Validate output
670*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
671*c217d954SCole Faust }
672*c217d954SCole Faust 
673*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMGroupedConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY,
674*c217d954SCole Faust                        combine(combine(combine(combine(datasets::LargeGroupedConvolutionLayerDataset(),
675*c217d954SCole Faust                                                        framework::dataset::make("ReshapeWeights", { true })),
676*c217d954SCole Faust                                                framework::dataset::make("DataType", DataType::F16)),
677*c217d954SCole Faust                                        framework::dataset::make("DataLayout", { DataLayout::NCHW })),
678*c217d954SCole Faust                                ActivationFunctionsDataset))
679*c217d954SCole Faust {
680*c217d954SCole Faust     // Validate output
681*c217d954SCole Faust     validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
682*c217d954SCole Faust }
683*c217d954SCole Faust TEST_SUITE_END() // FP16
684*c217d954SCole Faust TEST_SUITE_END() // Float
685*c217d954SCole Faust 
686*c217d954SCole Faust TEST_SUITE_END() // GroupedGEMMConvolutionLayer
687*c217d954SCole Faust TEST_SUITE_END() // CL
688*c217d954SCole Faust } // namespace validation
689*c217d954SCole Faust } // namespace test
690*c217d954SCole Faust } // namespace arm_compute
691