blob: 012018c0fcb9d47ee7736173849810d852a13a76 [file] [log] [blame]
Gian Marco Iodice9285adb2019-09-05 16:10:27 +01001/*
Gunes Bayir3af4c9b2023-10-08 17:51:28 +01002 * Copyright (c) 2019-2023 Arm Limited.
Gian Marco Iodice9285adb2019-09-05 16:10:27 +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,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010024#include "arm_compute/core/KernelDescriptors.h"
25#include "arm_compute/core/Types.h"
26#include "arm_compute/core/utils/misc/ShapeCalculator.h"
27#include "arm_compute/runtime/CL/CLTensor.h"
28#include "arm_compute/runtime/CL/CLTensorAllocator.h"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010029#include "src/core/CL/kernels/CLDepthwiseConvolutionLayerNativeKernel.h"
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010030#include "tests/CL/CLAccessor.h"
31#include "tests/CL/Helper.h"
32#include "tests/PaddingCalculator.h"
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010033#include "tests/framework/Asserts.h"
34#include "tests/framework/Macros.h"
35#include "tests/framework/datasets/Datasets.h"
36#include "tests/validation/Validation.h"
37#include "tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010045using framework::dataset::make;
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010046using namespace arm_compute::misc::shape_calculator;
47
48// Create function for CLDepthwiseConvolutionLayerNativeKernel
49using CLDepthwiseConvolutionLayerNative = CLSynthetizeFunction<CLDepthwiseConvolutionLayerNativeKernel>;
50
51// Fixture for CLDepthwiseConvolutionLayerNative
52template <typename T>
53using CLDepthwiseConvolutionLayerNativeFixture = DepthwiseConvolutionLayerNativeConfigurableValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayerNative, T>;
54
55namespace
56{
57// *INDENT-OFF*
58// clang-format off
59RelativeTolerance<float> rel_tolerance_f32(0.001f);
60constexpr float abs_tolerance_f32(0.0001f);
61
Giorgio Arenadac622a2019-12-23 15:01:17 +000062RelativeTolerance<half_float::half> rel_tolerance_f16(half_float::half(0.01f));
Michele Di Giorgio7d7c4202020-02-25 20:13:36 +000063constexpr float abs_tolerance_f16(0.03f);
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010064
65/** Width values to test - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010066const auto width_values_precommit = make("width", { 1U, 33U } );
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010067
68/** Width values to test - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010069const auto width_values_nightly = make("width", { 53U, 47U } );
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010070
71/** Height values to test - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010072const auto height_values_precommit = make("height", { 19U } );
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010073
74/** Height values to test - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010075const auto height_values_nightly = make("height", { 39U, 43U } );
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010076
77/** Channel values to test - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010078const auto channel_values_precommit = make("channels", { 15U });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010079
80/** Channel values to test - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010081const auto channel_values_nightly = make("channels", { 33U, 19U });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010082
Gian Marco Iodice8155c022021-04-16 15:08:59 +010083/** Channel values to test with cl_image support - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010084const auto channel_values_export_to_cl_image_precommit = make("channels", { 16U });
Gian Marco Iodice8155c022021-04-16 15:08:59 +010085
86/** Channel values to test with cl_image support - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010087const auto channel_values_export_to_cl_image_nightly = make("channels", { 32U });
Gian Marco Iodice8155c022021-04-16 15:08:59 +010088
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010089/** Batch values to test - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010090const auto batch_values_precommit = make("batch", { 1U, 2U });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010091
92/** Batch values to test - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010093const auto batch_values_nightly = make("batch", { 3U });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010094
95/** Kernel size values to test - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010096const auto kernel_sz_values_precommit = make("kernel_size", { Size2D(1U, 1U), Size2D(1U, 3U), Size2D(5U, 5U) });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +010097
98/** Kernel size values to test - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +010099const auto kernel_sz_values_nightly = make("kernel_size", { Size2D(3U, 5U), Size2D(5U, 1U), Size2D(1U, 7U), Size2D(9U, 7U) });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100100
101/** Depth multiplier values to test - All */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100102const auto depth_multiplier_values = make("depth_multiplier", {3U});
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100103
104/** Dilation values to test - All */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100105const auto dilation_values = make("dilation", { Size2D(1U, 1U), Size2D(3U, 3U) });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100106
107/** Stride values to test - All */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100108const auto stride_values = make("stride", { Size2D(1U, 1U), Size2D(3U, 2U) });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100109
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100110/** Padding values to test - Precommit */
111const auto padding_valid_values = make("padding_valid", { true, false });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100112
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100113/** Padding values to test - Nightly */
114const auto padding_valid_values_nightly = make("padding_valid", { false });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100115
116/** Data layout values to test - All */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100117const auto data_layout_values = make("data_layout", { DataLayout::NHWC });
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100118
119/** N0 values to test - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100120const auto n0_values_precommit = make("N0", {2, 4});
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100121
122/** N0 values to test - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100123const auto n0_values_nightly = make("N0", {3, 8});
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100124
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100125/** N0 values to test with cl_image support - Precommit */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100126const auto n0_values_export_to_cl_image_precommit = make("N0", {4});
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100127
128/** N0 values to test with cl_image support - Nightly */
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100129const auto n0_values_export_to_cl_image_nightly = make("N0", {8});
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100130
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100131/** Activation values to test in precommit */
132const auto act_values = make("Activation", { ActivationLayerInfo() });
133
134const auto activations_rest = make("Activation",
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100135{
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100136 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
137 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.f, 0.5f),
138 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.8f, -0.5f),
139 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LEAKY_RELU, 0.1f),
140 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SOFT_RELU),
141 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ELU),
142 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS),
143 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC),
144 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH),
145 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQUARE),
146 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::HARD_SWISH),
147 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LINEAR, 2.f, 1.f),
148 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::GELU)
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100149});
150
151} // namespace
152
153TEST_SUITE(CL)
154TEST_SUITE(DepthwiseConvolutionLayerNative)
155TEST_SUITE(Float)
156TEST_SUITE(FP32)
Giorgio Arena68e29da2021-02-08 16:31:10 +0000157FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::ALL,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100158 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100159 width_values_precommit,
160 height_values_precommit),
161 channel_values_precommit),
162 batch_values_precommit),
163 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100164 make("depth_multiplier", 1)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100165 dilation_values),
166 stride_values),
167 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100168 make("DataType", DataType::F32)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100169 data_layout_values),
170 act_values),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100171 n0_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100172 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100173{
174 // Validate output
175 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
176}
177
Giorgio Arena68e29da2021-02-08 16:31:10 +0000178FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100179 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100180 width_values_nightly,
181 height_values_nightly),
182 channel_values_nightly),
183 batch_values_nightly),
184 kernel_sz_values_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100185 make("depth_multiplier", 1)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100186 dilation_values),
187 stride_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100188 padding_valid_values_nightly),
189 make("DataType", DataType::F32)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100190 data_layout_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100191 make("Activation", { ActivationLayerInfo() })),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100192 n0_values_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100193 make("ExportToCLImage", false)))
194{
195 // Validate output
196 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
197}
198
199FIXTURE_DATA_TEST_CASE_NEW(RunActivations, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::ALL,
200 combine(
201 make("width", { 33U } ),
202 height_values_precommit,
203 channel_values_precommit,
204 make("batch", { 2U } ),
205 make("kernel_size", { Size2D(5U, 5U) }),
206 make("depth_multiplier", 1),
207 make("dilation", Size2D(3U, 3U)),
208 make("stride", Size2D(3U, 2U)),
209 padding_valid_values_nightly,
210 make("DataType", DataType::F32),
211 data_layout_values,
212 activations_rest,
213 n0_values_precommit,
214 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100215{
216 // Validate output
217 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
218}
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100219
220TEST_SUITE(ExportWeightsToCLImage)
221FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::ALL,
222 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
223 width_values_precommit,
224 height_values_precommit),
225 channel_values_export_to_cl_image_precommit),
226 batch_values_precommit),
227 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100228 make("depth_multiplier", 1)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100229 dilation_values),
230 stride_values),
231 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100232 make("DataType", DataType::F32)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100233 data_layout_values),
234 act_values),
235 n0_values_export_to_cl_image_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100236 make("ExportToCLImage", true)))
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100237{
238 // Validate output
239 if(_validate_output)
240 {
241 // Validate output
242 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
243 }
244 else
245 {
246 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
247 framework::ARM_COMPUTE_PRINT_INFO();
248 }
249}
250
251FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::NIGHTLY,
252 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
253 width_values_nightly,
254 height_values_nightly),
255 channel_values_export_to_cl_image_nightly),
256 batch_values_nightly),
257 kernel_sz_values_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100258 make("depth_multiplier", 1)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100259 dilation_values),
260 stride_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100261 padding_valid_values_nightly),
262 make("DataType", DataType::F32)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100263 data_layout_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100264 make("Activation", { ActivationLayerInfo() })),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100265 n0_values_export_to_cl_image_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100266 make("ExportToCLImage", true)))
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100267{
268 // Validate output
269 if(_validate_output)
270 {
271 // Validate output
272 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
273 }
274 else
275 {
276 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
277 framework::ARM_COMPUTE_PRINT_INFO();
278 }
279}
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100280
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100281TEST_SUITE_END() // ExportWeightsToCLImage
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100282TEST_SUITE_END() // FP32
283
284TEST_SUITE(FP16)
Giorgio Arena68e29da2021-02-08 16:31:10 +0000285FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100286 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100287 width_values_precommit,
288 height_values_precommit),
289 channel_values_precommit),
290 batch_values_precommit),
291 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100292 make("depth_multiplier", 1)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100293 dilation_values),
294 stride_values),
295 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100296 make("DataType", DataType::F16)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100297 data_layout_values),
298 act_values),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100299 n0_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100300 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100301{
302 // Validate output
Giorgio Arenadac622a2019-12-23 15:01:17 +0000303 validate(CLAccessor(_target), _reference, rel_tolerance_f16);
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100304}
Giorgio Arena68e29da2021-02-08 16:31:10 +0000305FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100306 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100307 make("width", { 47U } ),
308 make("height", { 39U } )),
309 make("channels", { 19U } )),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100310 batch_values_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100311 make("kernel_size", { Size2D(5U, 5U) })),
312 make("depth_multiplier", 1)),
313 make("dilation", { Size2D(3U, 3U) })),
314 make("stride", { Size2D(3U, 2U) })),
315 padding_valid_values_nightly),
316 make("DataType", DataType::F16)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100317 data_layout_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100318 make("Activation", { ActivationLayerInfo() })),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100319 n0_values_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100320 make("ExportToCLImage", false)))
321{
322 // Validate output
323 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
324}
325
326FIXTURE_DATA_TEST_CASE_NEW(RunActivations, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::ALL,
327 combine(
328 make("width", { 33U } ),
329 height_values_precommit,
330 channel_values_precommit,
331 make("batch", { 2U } ),
332 make("kernel_size", { Size2D(5U, 5U) }),
333 make("depth_multiplier", 4),
334 make("dilation", Size2D(3U, 3U)),
335 make("stride", Size2D(3U, 2U)),
336 padding_valid_values_nightly,
337 make("DataType", DataType::F16),
338 data_layout_values,
339 activations_rest,
340 n0_values_precommit,
341 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100342{
343 // Validate output
Giorgio Arenadac622a2019-12-23 15:01:17 +0000344 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100345}
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100346
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100347TEST_SUITE(ExportWeightsToCLImage)
348FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::ALL,
349 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
350 width_values_precommit,
351 height_values_precommit),
352 channel_values_export_to_cl_image_precommit),
353 batch_values_precommit),
354 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100355 make("depth_multiplier", 1)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100356 dilation_values),
357 stride_values),
358 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100359 make("DataType", DataType::F16)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100360 data_layout_values),
361 act_values),
362 n0_values_export_to_cl_image_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100363 make("ExportToCLImage", true)))
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100364{
365 // Validate output
366 if(_validate_output)
367 {
368 // Validate output
369 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
370 }
371 else
372 {
373 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
374 framework::ARM_COMPUTE_PRINT_INFO();
375 }
376}
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100377FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::NIGHTLY,
378 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100379 make("width", { 47U } ),
380 make("height", { 39U } )),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100381 channel_values_export_to_cl_image_nightly),
382 batch_values_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100383 make("kernel_size", { Size2D(5U, 5U) })),
384 make("depth_multiplier", 1)),
385 make("dilation", { Size2D(3U, 3U) })),
386 make("stride", { Size2D(3U, 2U) })),
387 padding_valid_values_nightly),
388 make("DataType", DataType::F16)),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100389 data_layout_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100390 make("Activation", { ActivationLayerInfo() })),
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100391 n0_values_export_to_cl_image_nightly),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100392 make("ExportToCLImage", true)))
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100393{
394 // Validate output
395 if(_validate_output)
396 {
397 // Validate output
398 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
399 }
400 else
401 {
402 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
403 framework::ARM_COMPUTE_PRINT_INFO();
404 }
405}
406TEST_SUITE_END() // ExportWeightsToCLImage
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100407TEST_SUITE_END() // FP16
408TEST_SUITE_END() // Float
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100409
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100410TEST_SUITE(DepthMultiplier)
411TEST_SUITE(Float)
412TEST_SUITE(FP32)
Giorgio Arena68e29da2021-02-08 16:31:10 +0000413FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::ALL,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100414 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100415 make("width", { 33U } ),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100416 height_values_precommit),
417 channel_values_precommit),
418 batch_values_precommit),
419 kernel_sz_values_precommit),
420 depth_multiplier_values),
421 dilation_values),
422 stride_values),
423 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100424 make("DataType", DataType::F32)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100425 data_layout_values),
426 act_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100427 make("N0", 1)),
428 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100429{
430 // Validate output
431 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
432}
433
Giorgio Arena68e29da2021-02-08 16:31:10 +0000434FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100435 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100436 make("width", { 53U } ),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100437 height_values_nightly),
438 channel_values_nightly),
439 batch_values_nightly),
440 kernel_sz_values_nightly),
441 depth_multiplier_values),
442 dilation_values),
443 stride_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100444 padding_valid_values_nightly),
445 make("DataType", DataType::F32)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100446 data_layout_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100447 make("Activation", { ActivationLayerInfo() })),
448 make("N0", 1)),
449 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100450{
451 // Validate output
452 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
453}
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100454
455TEST_SUITE(DepthMultiplierMultipleOfOutputChannels)
456FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::ALL,
457 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100458 make("width", { 33U } ),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100459 height_values_precommit),
460 channel_values_precommit),
461 batch_values_precommit),
462 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100463 make("depth_multiplier", 2)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100464 dilation_values),
465 stride_values),
466 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100467 make("DataType", DataType::F32)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100468 data_layout_values),
469 act_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100470 make("N0", {2})),
471 make("ExportToCLImage", false)))
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100472{
473 // Validate output
474 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
475}
476
477TEST_SUITE(ExportWeightsToCLImage)
478FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<float>, framework::DatasetMode::ALL,
479 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100480 make("width", { 33U } ),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100481 height_values_precommit),
482 channel_values_precommit),
483 batch_values_precommit),
484 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100485 make("depth_multiplier", 4)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100486 dilation_values),
487 stride_values),
488 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100489 make("DataType", DataType::F32)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100490 data_layout_values),
491 act_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100492 make("N0", {4})),
493 make("ExportToCLImage", true)))
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100494{
495 // Validate output
496 if(_validate_output)
497 {
498 // Validate output
499 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
500 }
501 else
502 {
503 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
504 framework::ARM_COMPUTE_PRINT_INFO();
505 }
506}
507TEST_SUITE_END() // ExportWeightsToCLImage
508TEST_SUITE_END() // DepthMultiplierMultipleOfOutputChannels
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100509TEST_SUITE_END() // FP32
510
511TEST_SUITE(FP16)
Giorgio Arena68e29da2021-02-08 16:31:10 +0000512FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100513 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100514 make("width", { 33U } ),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100515 height_values_precommit),
516 channel_values_precommit),
517 batch_values_precommit),
518 kernel_sz_values_precommit),
519 depth_multiplier_values),
520 dilation_values),
521 stride_values),
522 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100523 make("DataType", DataType::F16)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100524 data_layout_values),
525 act_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100526 make("N0", 1)),
527 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100528{
529 // Validate output
Giorgio Arenadac622a2019-12-23 15:01:17 +0000530 validate(CLAccessor(_target), _reference, rel_tolerance_f16);
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100531}
532
Giorgio Arena68e29da2021-02-08 16:31:10 +0000533FIXTURE_DATA_TEST_CASE_NEW(RunLarge, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice8155c022021-04-16 15:08:59 +0100534 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100535 make("width", { 53U } ),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100536 height_values_nightly),
537 channel_values_nightly),
538 batch_values_nightly),
539 kernel_sz_values_nightly),
540 depth_multiplier_values),
541 dilation_values),
542 stride_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100543 padding_valid_values_nightly),
544 make("DataType", DataType::F16)),
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100545 data_layout_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100546 make("Activation", { ActivationLayerInfo() })),
547 make("N0", 1)),
548 make("ExportToCLImage", false)))
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100549{
550 // Validate output
Giorgio Arenadac622a2019-12-23 15:01:17 +0000551 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100552}
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100553
554TEST_SUITE(DepthMultiplierMultipleOfOutputChannels)
555FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::ALL,
556 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100557 make("width", { 33U } ),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100558 height_values_precommit),
559 channel_values_precommit),
560 batch_values_precommit),
561 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100562 make("depth_multiplier", 2)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100563 dilation_values),
564 stride_values),
565 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100566 make("DataType", DataType::F16)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100567 data_layout_values),
568 act_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100569 make("N0", {2})),
570 make("ExportToCLImage", false)))
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100571{
572 // Validate output
573 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
574}
575
576TEST_SUITE(ExportWeightsToCLImage)
577FIXTURE_DATA_TEST_CASE_NEW(RunSmall, CLDepthwiseConvolutionLayerNativeFixture<half>, framework::DatasetMode::ALL,
578 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100579 make("width", { 33U } ),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100580 height_values_precommit),
581 channel_values_precommit),
582 batch_values_precommit),
583 kernel_sz_values_precommit),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100584 make("depth_multiplier", 4)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100585 dilation_values),
586 stride_values),
587 padding_valid_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100588 make("DataType", DataType::F16)),
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100589 data_layout_values),
590 act_values),
Gunes Bayir3af4c9b2023-10-08 17:51:28 +0100591 make("N0", {4})),
592 make("ExportToCLImage", true)))
Gian Marco Iodice211a55d2022-08-31 11:47:08 +0100593{
594 // Validate output
595 if(_validate_output)
596 {
597 // Validate output
598 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
599 }
600 else
601 {
602 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
603 framework::ARM_COMPUTE_PRINT_INFO();
604 }
605}
606TEST_SUITE_END() // ExportWeightsToCLImage
607TEST_SUITE_END() // DepthMultiplierMultipleOfOutputChannels
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100608TEST_SUITE_END() // FP16
609TEST_SUITE_END() // Float
610TEST_SUITE_END() // DepthMultiplier
611TEST_SUITE_END() // DepthwiseConvolutionLayerNative
612TEST_SUITE_END() // CL
613} // namespace validation
614} // namespace test
615} // namespace arm_compute