blob: ebcecb8b78528c526da3c57ad1be8b49ce5d955b [file] [log] [blame]
Gian Marco Iodiceadc53952019-02-15 11:10:31 +00001/*
Giorgio Arena2ab585b2021-02-25 15:41:49 +00002 * Copyright (c) 2019-2021 Arm Limited.
Gian Marco Iodiceadc53952019-02-15 11:10:31 +00003 *
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 Iodice7026b302019-06-26 17:18:11 +010024#include "arm_compute/core/KernelDescriptors.h"
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000025#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/CLGEMMMatrixMultiplyReshapedOnlyRHSKernel.h"
30#include "src/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h"
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000031#include "tests/CL/CLAccessor.h"
32#include "tests/CL/Helper.h"
33#include "tests/PaddingCalculator.h"
34#include "tests/datasets/ShapeDatasets.h"
35#include "tests/framework/Asserts.h"
36#include "tests/framework/Macros.h"
37#include "tests/framework/datasets/Datasets.h"
38#include "tests/validation/Validation.h"
39#include "tests/validation/fixtures/GEMMFixture.h"
40
41namespace arm_compute
42{
43namespace test
44{
45namespace validation
46{
47using namespace arm_compute::misc::shape_calculator;
48
49// Create function for CLGEMMReshapeRHSMatrixKernel
50using CLGEMMReshapeRHSMatrix = CLSynthetizeFunction<CLGEMMReshapeRHSMatrixKernel>;
51
52// Create function for CLGEMMMatrixMultiplyReshapedOnlyRHSKernel
53using CLGEMMMatrixMultiplyReshapedOnlyRHS = CLSynthetizeFunction<CLGEMMMatrixMultiplyReshapedOnlyRHSKernel>;
54
55// Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS
56template <typename T>
57using CLGEMMMatrixMultiplyReshapedOnlyRHSFixture = GEMMMatrixMultiplyReshapedOnlyRHSValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>;
58
59// Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS3D
60template <typename T>
61using CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture = GEMMMatrixMultiplyReshapedOnlyRHS3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>;
62
63namespace
64{
65// *INDENT-OFF*
66// clang-format off
67RelativeTolerance<float> rel_tolerance_f32(0.001f);
68constexpr float abs_tolerance_f32(0.0001f);
69
Gian Marco Iodice781cba72020-06-19 16:56:57 +010070RelativeTolerance<float> rel_tolerance_f16(0.001f);
71constexpr float abs_tolerance_f16(0.01f);
72
Sheri Zhang1a378102020-04-30 12:59:39 +010073/** Alpha values to test */
74const auto a_values = framework::dataset::make("alpha", {-0.75f} );
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000075
Sheri Zhang1a378102020-04-30 12:59:39 +010076/** Beta values to test */
Gian Marco Iodice6f931342020-09-15 14:17:41 +010077const auto beta_values = framework::dataset::make("beta", {-0.35f} );
Georgios Pinitasb0f342e2019-05-21 13:32:43 +010078
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000079/** M values to test */
80const auto m_values = framework::dataset::make("M", 37);
81
82/** M_W values to test */
83const auto m_w_values = framework::dataset::make("M_W", 5);
84
85/** M_H values to test */
86const auto m_h_values = framework::dataset::make("M_H", 7);
87
88/** N values to test */
89const auto n_values = framework::dataset::make("N", 51);
90
91/** K values to test */
92const auto k_values = framework::dataset::make("K", 23);
93
94/** Batch size values to test */
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +010095const auto b_values = framework::dataset::make("batch_size", 2);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000096
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +010097/** Activation values to test */
98const auto act_values = framework::dataset::make("Activation",
99{
Giorgio Arena2ab585b2021-02-25 15:41:49 +0000100 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 10.f),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100101});
102
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100103/** M0 values to test - precommit */
104const auto m0_values_precommit = framework::dataset::make("M0", { 4 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000105
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100106/** N0 values to test - precommit*/
107const auto n0_values_precommit = framework::dataset::make("N0", { 4 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000108
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100109/** K0 values to test - precommit*/
110const auto k0_values_precommit = framework::dataset::make("K0", { 4 });
111
112/** M0 values to test - nightly */
113const auto m0_values_nightly = framework::dataset::make("M0", { 8 });
114
115/** N0 values to test - nightly */
116const auto n0_values_nightly = framework::dataset::make("N0", { 16 });
117
118/** K0 values to test - nightly */
119const auto k0_values_nightly = framework::dataset::make("K0", { 16 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000120
Sheri Zhang1a378102020-04-30 12:59:39 +0100121/** H0 values to test */
122const auto h0_values = framework::dataset::make("H0", 1, 3);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000123
124/** Interleave values to test with RHS matrix */
125const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false });
126
127/** Transpose values to test with RHS matrix */
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000128const auto t_values_rhs = framework::dataset::make("transpose_rhs", { true, false });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000129
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100130/** Broadcast bias from vector to matrix */
Gian Marco Iodiced820db62019-08-05 14:23:23 +0100131const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } );
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100132
SiCong Lib972ae62020-08-03 15:39:45 +0100133/** Boundary handling cases for testing partial/non-partial (full) block dimensions, resulting from different combinations
134 * of M, M0, N and N0 values.
135 * M0 and N0 are kept constant, while the different test cases need to vary M and N.
136 *
137 * Eg. M = 64 and N = 33 result in a block dimension that has no partial blocks (all full blocks) in Y dimension and
138 * parital blocks in X dimension.
139 */
140const auto boundary_handling_cases = combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
141 // Large k to force potential out-of-bound reads on input0
142 framework::dataset::make("K", 315),
143 // Batch size == 1 to force potential out-of-bound reads on input0
144 framework::dataset::make("batch_size", 1)),
145 framework::dataset::make("M0", 4)),
146 framework::dataset::make("N0", 4)),
147 framework::dataset::make("K0", 4)),
148 framework::dataset::make("H0", 3)),
149 i_values_rhs),
150 t_values_rhs),
151 framework::dataset::make("export_to_cl_image_rhs", {true, false})),
152 // Only need to test F32 as F16 shares identical boundary handling logics
153 framework::dataset::make("DataType", DataType::F32)),
154 framework::dataset::make("alpha", -0.75f )),
155 framework::dataset::make("beta", -0.35f )),
156 broadcast_bias_values),
157 framework::dataset::make("Activation", ActivationLayerInfo()));
158
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000159/** Configuration test */
Sheri Zhang1a378102020-04-30 12:59:39 +0100160bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
161 unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100162 bool i_value_rhs, bool t_value_rhs, bool export_to_cl_image, bool broadcast_bias, bool input_as_3d, unsigned int depth_output_gemm3d, const ActivationLayerInfo &act_info,
Sheri Zhang1a378102020-04-30 12:59:39 +0100163 DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000164{
165 const unsigned int M = m_value;
166 const unsigned int N = n_value;
167 const unsigned int K = k_value;
168
169 GEMMLHSMatrixInfo lhs_info;
170 lhs_info.m0 = m0_value;
171 lhs_info.k0 = k0_value;
172
173 GEMMRHSMatrixInfo rhs_info;
174 rhs_info.n0 = n0_value;
175 rhs_info.k0 = k0_value;
176 rhs_info.h0 = h0_value;
177 rhs_info.interleave = i_value_rhs;
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000178 rhs_info.transpose = t_value_rhs;
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100179 rhs_info.export_to_cl_image = export_to_cl_image;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000180
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100181 GEMMKernelInfo kernel_info;
182 kernel_info.m = M;
183 kernel_info.n = N;
184 kernel_info.k = K;
Sheri Zhang1a378102020-04-30 12:59:39 +0100185 kernel_info.depth_output_gemm3d = depth_output_gemm3d;
186 kernel_info.reinterpret_input_as_3d = input_as_3d;
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100187 kernel_info.broadcast_bias = broadcast_bias;
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100188 kernel_info.activation_info = act_info;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000189
190 const TensorShape lhs_shape(K, M, b_value);
191 const TensorShape rhs_shape(N, K, b_value);
Sheri Zhang1a378102020-04-30 12:59:39 +0100192 const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000193 rhs_info);
194
Sheri Zhang1a378102020-04-30 12:59:39 +0100195 const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
196 TensorInfo(rhs_shape_reshaped, 1, dt_input1),
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100197 kernel_info);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000198
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100199 const TensorShape bias_shape(N,
Sheri Zhang1a378102020-04-30 12:59:39 +0100200 M, // Correct calculation should be: broadcast_bias? 1 : M, it's wrong here on purpose just for validation test
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100201 broadcast_bias? 1 : b_value);
202
Sheri Zhang1a378102020-04-30 12:59:39 +0100203 // Create tensor info
204 TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0);
205 TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1);
206 TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2);
207 TensorInfo dst = TensorInfo(dst_shape, 1, dt_output);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000208
209 // Create and configure function
210 CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
Sheri Zhang1a378102020-04-30 12:59:39 +0100211 return bool(gemm.validate(&lhs, &rhs_reshaped, &bias, &dst, alpha, beta, lhs_info, rhs_info, kernel_info));
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000212}
213} // namespace
214
215TEST_SUITE(CL)
216TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100217
218/** Validate tests
219 *
220 * A series of validation tests on configurations which according to the API specification
221 * the function should fail against.
222 *
223 * Checks performed in order:
224 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
225 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
226 * - Unsupported N0: NO can only be 2,3,4,8,16
227 * - Unsupported K0: KO can only be 2,3,4,8,16
228 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
229 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
230 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100231 * - Correct support for creating an OpenCL image object from buffer
232 * - Incorrect support for creating an OpenCL image object from buffer. N0 is 2 but it can only be 4,8 and 16
SiCong Li5bdde852020-08-26 13:55:15 +0100233 * - Correct F16 support for creating an OpenCL image object from buffer.
Sheri Zhang1a378102020-04-30 12:59:39 +0100234 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100235DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
236framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
237framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
238framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
239framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
240framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
241framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
242framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
243framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
244framework::dataset::make("data_type_input0", { DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})),
245framework::dataset::make("data_type_input1", { DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})),
246framework::dataset::make("data_type_input2", { DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})),
247framework::dataset::make("data_type_output", { DataType::F16, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})),
248framework::dataset::make("Beta", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f , 1.0f})),
SiCong Li5bdde852020-08-26 13:55:15 +0100249framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, true })),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100250b_value, m0_value, n0_value, k0_value, broadcast_bias, input_as_3d, depth_output_gemm3d, export_to_cl_image, dt_input0, dt_intpu1, dt_input2, dt_output, beta, expected)
Sheri Zhang1a378102020-04-30 12:59:39 +0100251{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100252 bool expected_value = expected;
253
254 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
255 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
256 {
257 expected_value = false;
258 }
259
260 bool status = validate_configuration(37, 51, 23, b_value, m0_value, n0_value, k0_value, 1, false, false, export_to_cl_image, broadcast_bias, input_as_3d, depth_output_gemm3d, ActivationLayerInfo(), dt_input0, dt_intpu1, dt_input2, dt_output, 1.0f, beta);
261 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100262}
263
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000264TEST_SUITE(Float)
265TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000266
SiCong Lib972ae62020-08-03 15:39:45 +0100267FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
268 combine(combine(
269 framework::dataset::make("M", 3),
270 framework::dataset::make("N", 1)),
271 boundary_handling_cases))
272{
273 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000274 if(validate_result)
275 {
276 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
277 }
278 else
279 {
280 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
281 framework::ARM_COMPUTE_PRINT_INFO();
282 }
SiCong Lib972ae62020-08-03 15:39:45 +0100283}
284
285FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
286 combine(combine(
287 framework::dataset::make("M", 64),
288 framework::dataset::make("N", 43)),
289 boundary_handling_cases))
290{
291 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000292 if(validate_result)
293 {
294 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
295 }
296 else
297 {
298 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
299 framework::ARM_COMPUTE_PRINT_INFO();
300 }
SiCong Lib972ae62020-08-03 15:39:45 +0100301}
302
303FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
304 combine(combine(
305 framework::dataset::make("M", 64),
306 framework::dataset::make("N", 32)),
307 boundary_handling_cases))
308{
309 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000310 if(validate_result)
311 {
312 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
313 }
314 else
315 {
316 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
317 framework::ARM_COMPUTE_PRINT_INFO();
318 }
SiCong Lib972ae62020-08-03 15:39:45 +0100319}
320
321FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
322 combine(combine(
323 framework::dataset::make("M", 37),
324 framework::dataset::make("N", 32)),
325 boundary_handling_cases))
326{
327 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000328 if(validate_result)
329 {
330 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
331 }
332 else
333 {
334 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
335 framework::ARM_COMPUTE_PRINT_INFO();
336 }
SiCong Lib972ae62020-08-03 15:39:45 +0100337}
338
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100339FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
340 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000341 m_values,
342 n_values),
343 k_values),
344 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100345 m0_values_precommit),
346 n0_values_precommit),
347 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100348 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000349 i_values_rhs),
350 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000351 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100352 framework::dataset::make("DataType", DataType::F32)),
353 a_values),
354 beta_values),
355 broadcast_bias_values),
356 act_values))
357{
358 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000359 if(validate_result)
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100360 {
361 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
362 }
363 else
364 {
365 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
366 framework::ARM_COMPUTE_PRINT_INFO();
367 }
368}
369
370FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
371 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
372 m_values,
373 n_values),
374 k_values),
375 b_values),
376 m0_values_nightly),
377 n0_values_nightly),
378 k0_values_nightly),
379 h0_values),
380 i_values_rhs),
381 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000382 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100383 framework::dataset::make("DataType", DataType::F32)),
384 a_values),
385 beta_values),
386 broadcast_bias_values),
387 act_values))
388{
389 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000390 if(validate_result)
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100391 {
392 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
393 }
394 else
395 {
396 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
397 framework::ARM_COMPUTE_PRINT_INFO();
398 }
399}
400
401FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100402 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100403 m_w_values,
404 m_h_values),
405 n_values),
406 k_values),
407 b_values),
408 m0_values_precommit),
409 n0_values_precommit),
410 k0_values_precommit),
411 h0_values),
412 i_values_rhs),
413 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000414 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100415 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100416 framework::dataset::make("DataType", DataType::F32)),
417 a_values),
418 beta_values),
419 act_values))
420{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000421 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
422 if(validate_result)
423 {
424 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
425 }
426 else
427 {
428 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
429 framework::ARM_COMPUTE_PRINT_INFO();
430 }
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100431}
432
433FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100434 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100435 m_w_values,
436 m_h_values),
437 n_values),
438 k_values),
439 b_values),
440 m0_values_nightly),
441 n0_values_nightly),
442 k0_values_nightly),
443 h0_values),
444 i_values_rhs),
445 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000446 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100447 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100448 framework::dataset::make("DataType", DataType::F32)),
449 a_values),
450 beta_values),
451 act_values))
452{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000453 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
454 if(validate_result)
455 {
456 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
457 }
458 else
459 {
460 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
461 framework::ARM_COMPUTE_PRINT_INFO();
462 }
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100463}
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000464TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100465
466TEST_SUITE(FP16)
467FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
468 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
469 m_values,
470 n_values),
471 k_values),
472 b_values),
473 m0_values_precommit),
474 n0_values_precommit),
475 k0_values_precommit),
476 h0_values),
477 i_values_rhs),
478 t_values_rhs),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100479 framework::dataset::make("export_to_cl_image_rhs", true)),
480 framework::dataset::make("DataType", DataType::F16)),
481 a_values),
482 beta_values),
483 broadcast_bias_values),
484 act_values))
485{
486 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000487 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100488 {
489 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
490 }
491 else
492 {
493 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
494 framework::ARM_COMPUTE_PRINT_INFO();
495 }
496}
497
498FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
499 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
500 m_values,
501 n_values),
502 k_values),
503 b_values),
504 m0_values_nightly),
505 n0_values_nightly),
506 k0_values_nightly),
507 h0_values),
508 i_values_rhs),
509 t_values_rhs),
510 framework::dataset::make("export_to_cl_image_rhs", true)),
511 framework::dataset::make("DataType", DataType::F16)),
512 a_values),
513 beta_values),
514 broadcast_bias_values),
515 act_values))
516{
517 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000518 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100519 {
520 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
521 }
522 else
523 {
524 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
525 framework::ARM_COMPUTE_PRINT_INFO();
526 }
527}
528
529FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100530 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100531 m_w_values,
532 m_h_values),
533 n_values),
534 k_values),
535 b_values),
536 m0_values_precommit),
537 n0_values_precommit),
538 k0_values_precommit),
539 h0_values),
540 i_values_rhs),
541 t_values_rhs),
542 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100543 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100544 framework::dataset::make("DataType", DataType::F16)),
545 a_values),
546 beta_values),
547 act_values))
548{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000549 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
550 if(validate_result)
551 {
552 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
553 }
554 else
555 {
556 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
557 framework::ARM_COMPUTE_PRINT_INFO();
558 }
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100559}
560
561FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100562 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100563 m_w_values,
564 m_h_values),
565 n_values),
566 k_values),
567 b_values),
568 m0_values_nightly),
569 n0_values_nightly),
570 k0_values_nightly),
571 h0_values),
572 i_values_rhs),
573 t_values_rhs),
574 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100575 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100576 framework::dataset::make("DataType", DataType::F16)),
577 a_values),
578 beta_values),
579 act_values))
580{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000581 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
582 if(validate_result)
583 {
584 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
585 }
586 else
587 {
588 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
589 framework::ARM_COMPUTE_PRINT_INFO();
590 }
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100591}
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100592TEST_SUITE_END() // FP16
593
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000594TEST_SUITE_END() // Float
595TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
596TEST_SUITE_END() // CL
597} // namespace validation
598} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100599} // namespace arm_compute