blob: ae2949c76788b7d9f2e8ebe700f75c303bf742c4 [file] [log] [blame]
Moritz Pflanzerb3d25792017-07-26 11:49:37 +01001/*
Sheri Zhang06d1efd2021-07-28 11:20:04 +01002 * Copyright (c) 2017-2021 Arm Limited.
Moritz Pflanzerb3d25792017-07-26 11:49:37 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Michalis Spyrou80943252019-01-10 17:19:50 +000021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010022 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTensorAllocator.h"
27#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h"
Isabella Gottardif07d28d2018-02-06 14:52:43 +000028#include "arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h"
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010029#include "tests/CL/CLAccessor.h"
30#include "tests/PaddingCalculator.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010031#include "tests/datasets/LargeConvolutionLayerDataset.h"
32#include "tests/datasets/SmallConvolutionLayerDataset.h"
Anthony Barbier1c0d0ff2018-01-31 13:05:09 +000033#include "tests/datasets/TinyConvolutionLayerDataset.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010034#include "tests/framework/Asserts.h"
35#include "tests/framework/Macros.h"
36#include "tests/framework/datasets/Datasets.h"
37#include "tests/validation/Validation.h"
38#include "tests/validation/fixtures/ConvolutionLayerFixture.h"
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010039
40namespace arm_compute
41{
42namespace test
43{
44namespace validation
45{
46namespace
47{
Manuel Bottini28a46c92020-11-11 15:05:29 +000048class SmallConvolutionLayerDatasetCases final : public datasets::ConvolutionLayerDataset
49{
50public:
51 SmallConvolutionLayerDatasetCases()
52 {
53 // 1D Kernel
54 add_config(TensorShape(1U, 130U, 2000U), TensorShape(1U, 1U, 2000U, 2000U), TensorShape(2000U), TensorShape(1U, 130U, 2000U), PadStrideInfo(1, 1, 0, 0));
55 }
56};
57
Georgios Pinitas8be91482019-03-26 17:23:28 +000058RelativeTolerance<float> tolerance_f32(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
steniu01f81652d2017-09-11 15:29:12 +010059RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.2)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */
Georgios Pinitas51e53a32018-10-22 13:49:08 +010060constexpr AbsoluteTolerance<float> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */
steniu01f81652d2017-09-11 15:29:12 +010061constexpr float tolerance_num = 0.07f; /**< Tolerance number */
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010062
63/** CNN data types */
64const auto CNNDataTypes = framework::dataset::make("DataType",
65{
66 DataType::F16,
67 DataType::F32,
Chunosov5124be52017-11-22 20:42:13 +070068 DataType::QASYMM8,
Sang-Hoon Park4715cf92020-01-08 16:02:47 +000069 DataType::QASYMM8_SIGNED,
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010070});
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +010071
72/** Grouped CNN data types */
73const auto GroupedCNNDataTypes = framework::dataset::make("DataType",
74{
75 DataType::F16,
76 DataType::F32
77});
78
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000079const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
80{
81 ActivationLayerInfo(),
82 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
83 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f),
84 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f)
85});
Michalis Spyrou80943252019-01-10 17:19:50 +000086const auto ActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo",
87{
88 ActivationLayerInfo(),
89 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f)
90});
Moritz Pflanzerb3d25792017-07-26 11:49:37 +010091} // namespace
92
93TEST_SUITE(CL)
94TEST_SUITE(ConvolutionLayer)
95
Michalis Spyrou80943252019-01-10 17:19:50 +000096// *INDENT-OFF*
97// clang-format off
Gian Marco Iodice2213d4b2018-04-27 10:39:06 +010098DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +000099 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Select GEMM
100 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Select GEMM
101 TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Select GEMM
102 TensorInfo(TensorShape(23U, 27U, 31U, 4U), 1, DataType::F32), // Select WINOGRAD
103 TensorInfo(TensorShape(3U, 3U, 2U, 1U), 1, DataType::F32), // Select GEMM
104 TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32), // Select GEMM
105 TensorInfo(TensorShape(17U, 31U, 32U), 1, DataType::F32), // Select WINOGRAD
106 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Select GEMM
107 TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::QASYMM8_SIGNED), // Select GEMM
Michalis Spyrou80943252019-01-10 17:19:50 +0000108 }),
109 framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32),
110 TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32),
111 TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
112 TensorInfo(TensorShape(3U, 3U, 31U, 21U), 1, DataType::F32),
113 TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32),
114 TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16),
115 TensorInfo(TensorShape(5U, 5U, 32U, 19U), 1, DataType::F32),
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000116 TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32),
117 TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::QASYMM8_SIGNED),
Michalis Spyrou80943252019-01-10 17:19:50 +0000118 })),
119 framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
120 TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32),
121 TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
122 TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32),
123 TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32),
124 TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32),
125 TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000126 TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32),
127 TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::QASYMM8_SIGNED),
Michalis Spyrou80943252019-01-10 17:19:50 +0000128 })),
129 framework::dataset::make("ConvInfo", { PadStrideInfo(1, 2, 1, 1),
130 PadStrideInfo(1, 2, 1, 1),
131 PadStrideInfo(1, 1, 0, 0),
132 PadStrideInfo(1, 1, 0, 0),
133 PadStrideInfo(2, 1, 0, 0),
134 PadStrideInfo(3, 2, 1, 0),
135 PadStrideInfo(1, 1, 2, 2),
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000136 PadStrideInfo(1, 1, 2, 2),
137 PadStrideInfo(1, 1, 2, 2),
Michalis Spyrou80943252019-01-10 17:19:50 +0000138 })),
139 framework::dataset::make("GpuTarget", { GPUTarget::BIFROST,
140 GPUTarget::MIDGARD,
141 GPUTarget::G71,
142 GPUTarget::G71,
143 GPUTarget::MIDGARD,
144 GPUTarget::BIFROST,
145 GPUTarget::BIFROST,
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000146 GPUTarget::BIFROST,
147 GPUTarget::BIFROST,
Michalis Spyrou80943252019-01-10 17:19:50 +0000148 })),
149 framework::dataset::make("Dilation", { Size2D(1U, 1U),
150 Size2D(1U, 1U),
151 Size2D(1U, 1U),
152 Size2D(1U, 1U),
153 Size2D(1U, 1U),
154 Size2D(1U, 1U),
155 Size2D(1U, 1U),
156 Size2D(2U, 1U),
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000157 Size2D(2U, 1U),
Michalis Spyrou80943252019-01-10 17:19:50 +0000158 })),
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000159 framework::dataset::make("EnableFastMath", { false, false, false, false, false, false, true, true, true })),
Michalis Spyrou80943252019-01-10 17:19:50 +0000160 framework::dataset::make("Expected",{ ConvolutionMethod::GEMM,
161 ConvolutionMethod::GEMM,
162 ConvolutionMethod::GEMM,
163 ConvolutionMethod::WINOGRAD,
164 ConvolutionMethod::GEMM,
165 ConvolutionMethod::GEMM,
166 ConvolutionMethod::WINOGRAD,
167 ConvolutionMethod::GEMM,
Sang-Hoon Park70d33bd2020-01-08 16:29:15 +0000168 ConvolutionMethod::GEMM,
Michalis Spyrou80943252019-01-10 17:19:50 +0000169 })),
170 input_info, weights_info, output_info, conv_info, gpu_target, dilation, enable_fast_math, expected)
Gian Marco Iodice2213d4b2018-04-27 10:39:06 +0100171{
172 ConvolutionMethod is_valid = CLConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true),
173 &weights_info.clone()->set_is_resizable(true),
174 &output_info.clone()->set_is_resizable(true), conv_info,
175 WeightsInfo(),
176 ActivationLayerInfo(),
177 gpu_target,
178 dilation,
179 enable_fast_math);
Isabella Gottardif07d28d2018-02-06 14:52:43 +0000180 ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
181}
Michalis Spyrou80943252019-01-10 17:19:50 +0000182// clang-format on
183// *INDENT-ON*
184TEST_SUITE_END() // ConvolutionLayer
Isabella Gottardif07d28d2018-02-06 14:52:43 +0000185
186TEST_SUITE(GEMMConvolutionLayer)
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100187template <typename T>
Isabella Gottardif07d28d2018-02-06 14:52:43 +0000188using CLGEMMConvolutionLayerFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000189template <typename T>
190using CLGEMMConvolutionLayerMixedDataLayoutFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, true>;
Gunes Bayircc171f92021-09-13 13:38:29 +0100191template <typename T>
192using CLConvolutionValidationWithPaddingFixture = ConvolutionValidationWithPaddingFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100193
194TEST_SUITE(Float)
195TEST_SUITE(FP16)
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000196
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100197FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
198 framework::dataset::make("ReshapeWeights", { true })),
199 framework::dataset::make("DataType",
200 DataType::F16)),
201 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
202 ActivationFunctionsSmallDataset))
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100203{
204 // Validate output
steniu013e05e4e2017-08-25 17:18:01 +0100205 validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num);
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100206}
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100207TEST_SUITE_END() // FP16
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100208
209TEST_SUITE(FP32)
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000210
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100211FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
212 framework::dataset::make("ReshapeWeights", { true })),
213 framework::dataset::make("DataType",
214 DataType::F32)),
215 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
216 ActivationFunctionsSmallDataset))
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100217{
218 // Validate output
219 validate(CLAccessor(_target), _reference, tolerance_f32);
220}
Sheri Zhang06d1efd2021-07-28 11:20:04 +0100221FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLGEMMConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::ALL,
222 combine(combine(combine(combine(combine(combine(combine(combine(combine(
223 framework::dataset::make("Input", TensorShape(23U, 27U, 5U)),
224 framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))),
225 framework::dataset::make("Bias", TensorShape(2U))),
226 framework::dataset::make("Output", TensorShape(11U, 25U, 2U))),
227 framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))),
228 framework::dataset::make("Dilation", Size2D(1, 1))),
229 framework::dataset::make("ReshapeWeights", { true })),
230 framework::dataset::make("DataType", DataType::F32)),
231 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
232 ActivationFunctionsSmallDataset))
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000233{
234 // Validate output
235 validate(CLAccessor(_target), _reference, tolerance_f32);
236}
Gunes Bayircc171f92021-09-13 13:38:29 +0100237FIXTURE_DATA_TEST_CASE(RunSmallWithPadding, CLConvolutionValidationWithPaddingFixture<float>, framework::DatasetMode::ALL,
238 combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerPrePaddingDataset(),
239 framework::dataset::make("ReshapeWeights", { true })),
240 framework::dataset::make("DataType", DataType::F32)),
241 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
242 framework::dataset::make("ActivationInfo", { ActivationLayerInfo() })),
243framework::dataset::make("PrePadLayer", { PaddingList({ { 1, 1 }, { 1, 1 } }) })))
244{
245 // Validate output
246 validate(CLAccessor(_target), _reference, tolerance_f32);
247}
248
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100249TEST_SUITE_END() // FP32
250TEST_SUITE_END() // Float
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100251
252template <typename T>
Isabella Gottardif07d28d2018-02-06 14:52:43 +0000253using CLGEMMConvolutionLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +0000254template <typename T>
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000255using CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture = ConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, true>;
256template <typename T>
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +0000257using CLGEMMConvolutionLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, int8_t>;
Chunosov5124be52017-11-22 20:42:13 +0700258
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000259const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
260{
261 ActivationLayerInfo(),
262 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
263 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f)
264});
Michalis Spyrou80943252019-01-10 17:19:50 +0000265const auto QuantizedActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo",
266{
267 ActivationLayerInfo(),
268 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f)
269});
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000270
Chunosov5124be52017-11-22 20:42:13 +0700271TEST_SUITE(Quantized)
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000272
Gian Marco Iodice3139f032018-11-05 14:26:32 +0000273const auto QuantizationData = framework::dataset::make("QuantizationInfo",
274{
275 QuantizationInfo(0.5f, 10),
276 QuantizationInfo(0.3f, 3),
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100277 QuantizationInfo(1.1f, 10),
Gian Marco Iodice3139f032018-11-05 14:26:32 +0000278});
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +0000279TEST_SUITE(QASYMM8)
Gian Marco Iodice3139f032018-11-05 14:26:32 +0000280
Manuel Bottini28a46c92020-11-11 15:05:29 +0000281FIXTURE_DATA_TEST_CASE(RunSmallCases, CLGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL,
282 combine(combine(combine(combine(combine(SmallConvolutionLayerDatasetCases(),
283 framework::dataset::make("ReshapeWeights", { true })),
284 framework::dataset::make("DataType", DataType::QASYMM8)),
285 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
286 QuantizationData),
287 QuantizedActivationFunctionsSmallDataset))
288{
289 // Validate output
290 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
291}
292
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100293FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL,
294 combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
Michalis Spyrou80943252019-01-10 17:19:50 +0000295 framework::dataset::make("ReshapeWeights", { true })),
296 framework::dataset::make("DataType", DataType::QASYMM8)),
297 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
298 QuantizationData),
299 QuantizedActivationFunctionsSmallDataset))
Chunosov5124be52017-11-22 20:42:13 +0700300{
301 // Validate output
302 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
303}
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000304FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::ALL,
Sheri Zhang06d1efd2021-07-28 11:20:04 +0100305 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
306 framework::dataset::make("Input", TensorShape(23U, 27U, 5U)),
307 framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))),
308 framework::dataset::make("Bias", TensorShape(2U))),
309 framework::dataset::make("Output", TensorShape(11U, 25U, 2U))),
310 framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))),
311 framework::dataset::make("Dilation", Size2D(1, 1))),
312 framework::dataset::make("ReshapeWeights", { true })),
313 framework::dataset::make("DataType", DataType::QASYMM8)),
314 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
315 QuantizationData),
316 QuantizedActivationFunctionsSmallDataset))
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000317{
318 // Validate output
319 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
320}
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100321TEST_SUITE_END() // QASYMM8
Sang-Hoon Park4715cf92020-01-08 16:02:47 +0000322TEST_SUITE(QASYMM8_SIGNED)
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100323FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL,
324 combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
Sang-Hoon Park4715cf92020-01-08 16:02:47 +0000325 framework::dataset::make("ReshapeWeights", { true })),
326 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
327 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
328 QuantizationData),
329 QuantizedActivationFunctionsSmallDataset))
330{
331 // Validate output
332 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
333}
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000334FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLGEMMConvolutionLayerQuantizedMixedDataLayoutFixture<int8_t>, framework::DatasetMode::ALL,
Sheri Zhang06d1efd2021-07-28 11:20:04 +0100335 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
336 framework::dataset::make("Input", TensorShape(23U, 27U, 5U)),
337 framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))),
338 framework::dataset::make("Bias", TensorShape(2U))),
339 framework::dataset::make("Output", TensorShape(11U, 25U, 2U))),
340 framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))),
341 framework::dataset::make("Dilation", Size2D(1, 1))),
342 framework::dataset::make("ReshapeWeights", { true })),
343 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
344 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
345 QuantizationData),
346 QuantizedActivationFunctionsSmallDataset))
Manuel Bottinica62c6f2021-03-23 11:50:34 +0000347{
348 // Validate output
349 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
350}
Sang-Hoon Park4715cf92020-01-08 16:02:47 +0000351TEST_SUITE_END() // QASYMM8_SIGNED
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +0000352TEST_SUITE(QSYMM8_PER_CHANNEL)
353
morgolockd13931d2020-06-23 15:49:35 +0100354FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLGEMMConvolutionLayerQuantizedPerChannelFixture<int8_t>, framework::DatasetMode::ALL,
355 combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
356 framework::dataset::make("ReshapeWeights", { true })),
357 framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED })),
358 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
359 QuantizationData),
360 QuantizedActivationFunctionsSmallDataset),
361 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
362{
363 // Validate output
364 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
365}
366
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100367FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedPerChannelFixture<uint8_t>, framework::DatasetMode::ALL,
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +0000368 combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(),
369 framework::dataset::make("ReshapeWeights", { true })),
370 framework::dataset::make("DataType", { DataType::QASYMM8 })),
371 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
372 QuantizationData),
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100373 QuantizedActivationFunctionsSmallDataset),
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +0000374 framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL })))
375{
376 // Validate output
377 validate(CLAccessor(_target), _reference, tolerance_qasymm8);
378}
379TEST_SUITE_END() // QSYMM8_PER_CHANNEL
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100380TEST_SUITE_END() // Quantized
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100381
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100382TEST_SUITE_END() // GEMMConvolutionLayer
383
384template <typename T>
385using CLGEMMGroupedConvolutionLayerFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>;
386
387TEST_SUITE(GroupedGEMMConvolutionLayer)
388
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100389TEST_SUITE(Float)
390TEST_SUITE(FP32)
391
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100392FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(),
393 framework::dataset::make("ReshapeWeights", { true })),
394 framework::dataset::make("DataType", DataType::F32)),
395 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
396 ActivationFunctionsSmallDataset))
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100397{
398 // Validate output
399 validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
400}
401
Michalis Spyrou80943252019-01-10 17:19:50 +0000402FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMGroupedConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY,
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100403 combine(combine(combine(combine(datasets::LargeGroupedConvolutionLayerDataset(),
Michalis Spyrou80943252019-01-10 17:19:50 +0000404 framework::dataset::make("ReshapeWeights", { true })),
405 framework::dataset::make("DataType", DataType::F32)),
406 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
407 ActivationFunctionsDataset))
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100408{
409 // Validate output
410 validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
411}
412TEST_SUITE_END() // FP32
413
414TEST_SUITE(FP16)
415
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100416FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(),
417 framework::dataset::make("ReshapeWeights", { true })),
418 framework::dataset::make("DataType", DataType::F16)),
419 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
420 ActivationFunctionsSmallDataset))
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100421{
422 // Validate output
423 validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
424}
425
Michalis Spyrou80943252019-01-10 17:19:50 +0000426FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMGroupedConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY,
Michele Di Giorgioe37662a2020-04-29 15:14:18 +0100427 combine(combine(combine(combine(datasets::LargeGroupedConvolutionLayerDataset(),
Michalis Spyrou80943252019-01-10 17:19:50 +0000428 framework::dataset::make("ReshapeWeights", { true })),
429 framework::dataset::make("DataType", DataType::F16)),
430 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
431 ActivationFunctionsDataset))
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100432{
433 // Validate output
434 validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num);
435}
436TEST_SUITE_END() // FP16
437TEST_SUITE_END() // Float
438
439TEST_SUITE_END() // GroupedGEMMConvolutionLayer
440TEST_SUITE_END() // CL
Moritz Pflanzerb3d25792017-07-26 11:49:37 +0100441} // namespace validation
442} // namespace test
443} // namespace arm_compute