blob: 88e99bcfeffc18e7d510b635a01018219863bf63 [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"
Georgios Pinitas856f66e2021-04-22 21:13:21 +010029#include "src/core/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.h"
30#include "src/core/gpu/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;
Georgios Pinitas856f66e2021-04-22 21:13:21 +010048using namespace arm_compute::opencl::kernels;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000049
Georgios Pinitas856f66e2021-04-22 21:13:21 +010050// Create function for ClGemmReshapeRhsMatrixKernel
51using CLGEMMReshapeRHSMatrix = CLSynthetizeOperator<ClGemmReshapeRhsMatrixKernel>;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000052
Georgios Pinitas856f66e2021-04-22 21:13:21 +010053// Create function for ClGemmMatrixMultiplyReshapedOnlyRhsKernel
54using CLGEMMMatrixMultiplyReshapedOnlyRHS = CLSynthetizeOperator<ClGemmMatrixMultiplyReshapedOnlyRhsKernel>;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000055
56// Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS
57template <typename T>
58using CLGEMMMatrixMultiplyReshapedOnlyRHSFixture = GEMMMatrixMultiplyReshapedOnlyRHSValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>;
59
60// Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS3D
61template <typename T>
62using CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture = GEMMMatrixMultiplyReshapedOnlyRHS3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>;
63
64namespace
65{
66// *INDENT-OFF*
67// clang-format off
68RelativeTolerance<float> rel_tolerance_f32(0.001f);
69constexpr float abs_tolerance_f32(0.0001f);
70
Gian Marco Iodice781cba72020-06-19 16:56:57 +010071RelativeTolerance<float> rel_tolerance_f16(0.001f);
72constexpr float abs_tolerance_f16(0.01f);
73
Sheri Zhang1a378102020-04-30 12:59:39 +010074/** Alpha values to test */
75const auto a_values = framework::dataset::make("alpha", {-0.75f} );
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000076
Sheri Zhang1a378102020-04-30 12:59:39 +010077/** Beta values to test */
Gian Marco Iodice6f931342020-09-15 14:17:41 +010078const auto beta_values = framework::dataset::make("beta", {-0.35f} );
Georgios Pinitasb0f342e2019-05-21 13:32:43 +010079
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000080/** M values to test */
81const auto m_values = framework::dataset::make("M", 37);
82
83/** M_W values to test */
84const auto m_w_values = framework::dataset::make("M_W", 5);
85
86/** M_H values to test */
87const auto m_h_values = framework::dataset::make("M_H", 7);
88
89/** N values to test */
90const auto n_values = framework::dataset::make("N", 51);
91
92/** K values to test */
93const auto k_values = framework::dataset::make("K", 23);
94
95/** Batch size values to test */
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +010096const auto b_values = framework::dataset::make("batch_size", 2);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000097
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +010098/** Activation values to test */
99const auto act_values = framework::dataset::make("Activation",
100{
Giorgio Arena2ab585b2021-02-25 15:41:49 +0000101 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 10.f),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100102});
103
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100104/** M0 values to test - precommit */
105const auto m0_values_precommit = framework::dataset::make("M0", { 4 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000106
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100107/** N0 values to test - precommit*/
108const auto n0_values_precommit = framework::dataset::make("N0", { 4 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000109
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100110/** K0 values to test - precommit*/
111const auto k0_values_precommit = framework::dataset::make("K0", { 4 });
112
113/** M0 values to test - nightly */
114const auto m0_values_nightly = framework::dataset::make("M0", { 8 });
115
116/** N0 values to test - nightly */
117const auto n0_values_nightly = framework::dataset::make("N0", { 16 });
118
119/** K0 values to test - nightly */
120const auto k0_values_nightly = framework::dataset::make("K0", { 16 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000121
Sheri Zhang1a378102020-04-30 12:59:39 +0100122/** H0 values to test */
123const auto h0_values = framework::dataset::make("H0", 1, 3);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000124
125/** Interleave values to test with RHS matrix */
126const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false });
127
128/** Transpose values to test with RHS matrix */
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000129const auto t_values_rhs = framework::dataset::make("transpose_rhs", { true, false });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000130
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100131/** Broadcast bias from vector to matrix */
Gian Marco Iodiced820db62019-08-05 14:23:23 +0100132const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } );
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100133
SiCong Lib972ae62020-08-03 15:39:45 +0100134/** Boundary handling cases for testing partial/non-partial (full) block dimensions, resulting from different combinations
135 * of M, M0, N and N0 values.
136 * M0 and N0 are kept constant, while the different test cases need to vary M and N.
137 *
138 * Eg. M = 64 and N = 33 result in a block dimension that has no partial blocks (all full blocks) in Y dimension and
139 * parital blocks in X dimension.
140 */
141const auto boundary_handling_cases = combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
142 // Large k to force potential out-of-bound reads on input0
143 framework::dataset::make("K", 315),
144 // Batch size == 1 to force potential out-of-bound reads on input0
145 framework::dataset::make("batch_size", 1)),
146 framework::dataset::make("M0", 4)),
147 framework::dataset::make("N0", 4)),
148 framework::dataset::make("K0", 4)),
149 framework::dataset::make("H0", 3)),
150 i_values_rhs),
151 t_values_rhs),
152 framework::dataset::make("export_to_cl_image_rhs", {true, false})),
153 // Only need to test F32 as F16 shares identical boundary handling logics
154 framework::dataset::make("DataType", DataType::F32)),
155 framework::dataset::make("alpha", -0.75f )),
156 framework::dataset::make("beta", -0.35f )),
157 broadcast_bias_values),
158 framework::dataset::make("Activation", ActivationLayerInfo()));
159
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000160/** Configuration test */
Sheri Zhang1a378102020-04-30 12:59:39 +0100161bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
162 unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100163 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 +0100164 DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000165{
166 const unsigned int M = m_value;
167 const unsigned int N = n_value;
168 const unsigned int K = k_value;
169
170 GEMMLHSMatrixInfo lhs_info;
171 lhs_info.m0 = m0_value;
172 lhs_info.k0 = k0_value;
173
174 GEMMRHSMatrixInfo rhs_info;
175 rhs_info.n0 = n0_value;
176 rhs_info.k0 = k0_value;
177 rhs_info.h0 = h0_value;
178 rhs_info.interleave = i_value_rhs;
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000179 rhs_info.transpose = t_value_rhs;
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100180 rhs_info.export_to_cl_image = export_to_cl_image;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000181
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100182 GEMMKernelInfo kernel_info;
183 kernel_info.m = M;
184 kernel_info.n = N;
185 kernel_info.k = K;
Sheri Zhang1a378102020-04-30 12:59:39 +0100186 kernel_info.depth_output_gemm3d = depth_output_gemm3d;
187 kernel_info.reinterpret_input_as_3d = input_as_3d;
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100188 kernel_info.broadcast_bias = broadcast_bias;
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100189 kernel_info.activation_info = act_info;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000190
191 const TensorShape lhs_shape(K, M, b_value);
192 const TensorShape rhs_shape(N, K, b_value);
Sheri Zhang1a378102020-04-30 12:59:39 +0100193 const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000194 rhs_info);
195
Sheri Zhang1a378102020-04-30 12:59:39 +0100196 const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
197 TensorInfo(rhs_shape_reshaped, 1, dt_input1),
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100198 kernel_info);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000199
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100200 const TensorShape bias_shape(N,
Sheri Zhang1a378102020-04-30 12:59:39 +0100201 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 +0100202 broadcast_bias? 1 : b_value);
203
Sheri Zhang1a378102020-04-30 12:59:39 +0100204 // Create tensor info
205 TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0);
206 TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1);
207 TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2);
208 TensorInfo dst = TensorInfo(dst_shape, 1, dt_output);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000209
210 // Create and configure function
211 CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
Sheri Zhang1a378102020-04-30 12:59:39 +0100212 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 +0000213}
214} // namespace
215
216TEST_SUITE(CL)
217TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100218
219/** Validate tests
220 *
221 * A series of validation tests on configurations which according to the API specification
222 * the function should fail against.
223 *
224 * Checks performed in order:
225 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
226 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
227 * - Unsupported N0: NO can only be 2,3,4,8,16
228 * - Unsupported K0: KO can only be 2,3,4,8,16
229 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
230 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
231 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100232 * - Correct support for creating an OpenCL image object from buffer
233 * - 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 +0100234 * - Correct F16 support for creating an OpenCL image object from buffer.
Sheri Zhang1a378102020-04-30 12:59:39 +0100235 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100236DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
237framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
238framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
239framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
240framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
241framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
242framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
243framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
244framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
245framework::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})),
246framework::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})),
247framework::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})),
248framework::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})),
249framework::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 +0100250framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, true })),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100251b_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 +0100252{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100253 bool expected_value = expected;
254
255 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
256 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
257 {
258 expected_value = false;
259 }
260
261 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);
262 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100263}
264
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000265TEST_SUITE(Float)
266TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000267
SiCong Lib972ae62020-08-03 15:39:45 +0100268FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
269 combine(combine(
270 framework::dataset::make("M", 3),
271 framework::dataset::make("N", 1)),
272 boundary_handling_cases))
273{
274 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000275 if(validate_result)
276 {
277 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
278 }
279 else
280 {
281 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
282 framework::ARM_COMPUTE_PRINT_INFO();
283 }
SiCong Lib972ae62020-08-03 15:39:45 +0100284}
285
286FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
287 combine(combine(
288 framework::dataset::make("M", 64),
289 framework::dataset::make("N", 43)),
290 boundary_handling_cases))
291{
292 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000293 if(validate_result)
294 {
295 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
296 }
297 else
298 {
299 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
300 framework::ARM_COMPUTE_PRINT_INFO();
301 }
SiCong Lib972ae62020-08-03 15:39:45 +0100302}
303
304FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
305 combine(combine(
306 framework::dataset::make("M", 64),
307 framework::dataset::make("N", 32)),
308 boundary_handling_cases))
309{
310 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000311 if(validate_result)
312 {
313 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
314 }
315 else
316 {
317 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
318 framework::ARM_COMPUTE_PRINT_INFO();
319 }
SiCong Lib972ae62020-08-03 15:39:45 +0100320}
321
322FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
323 combine(combine(
324 framework::dataset::make("M", 37),
325 framework::dataset::make("N", 32)),
326 boundary_handling_cases))
327{
328 // Validate output
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000329 if(validate_result)
330 {
331 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
332 }
333 else
334 {
335 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
336 framework::ARM_COMPUTE_PRINT_INFO();
337 }
SiCong Lib972ae62020-08-03 15:39:45 +0100338}
339
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100340FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
341 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000342 m_values,
343 n_values),
344 k_values),
345 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100346 m0_values_precommit),
347 n0_values_precommit),
348 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100349 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000350 i_values_rhs),
351 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000352 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100353 framework::dataset::make("DataType", DataType::F32)),
354 a_values),
355 beta_values),
356 broadcast_bias_values),
357 act_values))
358{
359 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000360 if(validate_result)
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100361 {
362 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
363 }
364 else
365 {
366 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
367 framework::ARM_COMPUTE_PRINT_INFO();
368 }
369}
370
371FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
372 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
373 m_values,
374 n_values),
375 k_values),
376 b_values),
377 m0_values_nightly),
378 n0_values_nightly),
379 k0_values_nightly),
380 h0_values),
381 i_values_rhs),
382 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000383 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100384 framework::dataset::make("DataType", DataType::F32)),
385 a_values),
386 beta_values),
387 broadcast_bias_values),
388 act_values))
389{
390 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000391 if(validate_result)
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100392 {
393 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
394 }
395 else
396 {
397 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
398 framework::ARM_COMPUTE_PRINT_INFO();
399 }
400}
401
402FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100403 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100404 m_w_values,
405 m_h_values),
406 n_values),
407 k_values),
408 b_values),
409 m0_values_precommit),
410 n0_values_precommit),
411 k0_values_precommit),
412 h0_values),
413 i_values_rhs),
414 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000415 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100416 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100417 framework::dataset::make("DataType", DataType::F32)),
418 a_values),
419 beta_values),
420 act_values))
421{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000422 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
423 if(validate_result)
424 {
425 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
426 }
427 else
428 {
429 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
430 framework::ARM_COMPUTE_PRINT_INFO();
431 }
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100432}
433
434FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100435 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100436 m_w_values,
437 m_h_values),
438 n_values),
439 k_values),
440 b_values),
441 m0_values_nightly),
442 n0_values_nightly),
443 k0_values_nightly),
444 h0_values),
445 i_values_rhs),
446 t_values_rhs),
Manuel Bottini827817e2020-11-19 12:12:06 +0000447 framework::dataset::make("export_to_cl_image_rhs", {false, true})),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100448 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100449 framework::dataset::make("DataType", DataType::F32)),
450 a_values),
451 beta_values),
452 act_values))
453{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000454 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
455 if(validate_result)
456 {
457 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
458 }
459 else
460 {
461 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
462 framework::ARM_COMPUTE_PRINT_INFO();
463 }
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100464}
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000465TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100466
467TEST_SUITE(FP16)
468FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
469 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
470 m_values,
471 n_values),
472 k_values),
473 b_values),
474 m0_values_precommit),
475 n0_values_precommit),
476 k0_values_precommit),
477 h0_values),
478 i_values_rhs),
479 t_values_rhs),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100480 framework::dataset::make("export_to_cl_image_rhs", true)),
481 framework::dataset::make("DataType", DataType::F16)),
482 a_values),
483 beta_values),
484 broadcast_bias_values),
485 act_values))
486{
487 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000488 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100489 {
490 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
491 }
492 else
493 {
494 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
495 framework::ARM_COMPUTE_PRINT_INFO();
496 }
497}
498
499FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
500 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
501 m_values,
502 n_values),
503 k_values),
504 b_values),
505 m0_values_nightly),
506 n0_values_nightly),
507 k0_values_nightly),
508 h0_values),
509 i_values_rhs),
510 t_values_rhs),
511 framework::dataset::make("export_to_cl_image_rhs", true)),
512 framework::dataset::make("DataType", DataType::F16)),
513 a_values),
514 beta_values),
515 broadcast_bias_values),
516 act_values))
517{
518 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000519 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100520 {
521 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
522 }
523 else
524 {
525 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
526 framework::ARM_COMPUTE_PRINT_INFO();
527 }
528}
529
530FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100531 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100532 m_w_values,
533 m_h_values),
534 n_values),
535 k_values),
536 b_values),
537 m0_values_precommit),
538 n0_values_precommit),
539 k0_values_precommit),
540 h0_values),
541 i_values_rhs),
542 t_values_rhs),
543 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100544 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100545 framework::dataset::make("DataType", DataType::F16)),
546 a_values),
547 beta_values),
548 act_values))
549{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000550 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
551 if(validate_result)
552 {
553 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
554 }
555 else
556 {
557 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
558 framework::ARM_COMPUTE_PRINT_INFO();
559 }
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100560}
561
562FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100563 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100564 m_w_values,
565 m_h_values),
566 n_values),
567 k_values),
568 b_values),
569 m0_values_nightly),
570 n0_values_nightly),
571 k0_values_nightly),
572 h0_values),
573 i_values_rhs),
574 t_values_rhs),
575 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100576 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100577 framework::dataset::make("DataType", DataType::F16)),
578 a_values),
579 beta_values),
580 act_values))
581{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000582 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
583 if(validate_result)
584 {
585 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
586 }
587 else
588 {
589 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
590 framework::ARM_COMPUTE_PRINT_INFO();
591 }
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100592}
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100593TEST_SUITE_END() // FP16
594
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000595TEST_SUITE_END() // Float
596TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
597TEST_SUITE_END() // CL
598} // namespace validation
599} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100600} // namespace arm_compute