blob: 14b1c66e2cbd42cf07f6dc1c3c7ab208ab89c970 [file] [log] [blame]
Gian Marco Iodiceadc53952019-02-15 11:10:31 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2019-2020 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 */
24#include "arm_compute/core/CL/kernels/CLGEMMMatrixMultiplyReshapedOnlyRHSKernel.h"
25#include "arm_compute/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h"
Gian Marco Iodice7026b302019-06-26 17:18:11 +010026#include "arm_compute/core/KernelDescriptors.h"
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000027#include "arm_compute/core/Types.h"
28#include "arm_compute/core/utils/misc/ShapeCalculator.h"
29#include "arm_compute/runtime/CL/CLTensor.h"
30#include "arm_compute/runtime/CL/CLTensorAllocator.h"
31#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 Iodiced820db62019-08-05 14:23:23 +010077const auto beta_values = framework::dataset::make("beta", {-0.35f, 0.0f} );
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 */
95const auto b_values = framework::dataset::make("batch_size", 1, 3);
96
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +010097/** Activation values to test */
98const auto act_values = framework::dataset::make("Activation",
99{
100 ActivationLayerInfo(),
101 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f),
102});
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
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000134/** Configuration test */
Sheri Zhang1a378102020-04-30 12:59:39 +0100135bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
136 unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100137 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 +0100138 DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000139{
140 const unsigned int M = m_value;
141 const unsigned int N = n_value;
142 const unsigned int K = k_value;
143
144 GEMMLHSMatrixInfo lhs_info;
145 lhs_info.m0 = m0_value;
146 lhs_info.k0 = k0_value;
147
148 GEMMRHSMatrixInfo rhs_info;
149 rhs_info.n0 = n0_value;
150 rhs_info.k0 = k0_value;
151 rhs_info.h0 = h0_value;
152 rhs_info.interleave = i_value_rhs;
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000153 rhs_info.transpose = t_value_rhs;
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100154 rhs_info.export_to_cl_image = export_to_cl_image;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000155
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100156 GEMMKernelInfo kernel_info;
157 kernel_info.m = M;
158 kernel_info.n = N;
159 kernel_info.k = K;
Sheri Zhang1a378102020-04-30 12:59:39 +0100160 kernel_info.depth_output_gemm3d = depth_output_gemm3d;
161 kernel_info.reinterpret_input_as_3d = input_as_3d;
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100162 kernel_info.broadcast_bias = broadcast_bias;
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100163 kernel_info.activation_info = act_info;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000164
165 const TensorShape lhs_shape(K, M, b_value);
166 const TensorShape rhs_shape(N, K, b_value);
Sheri Zhang1a378102020-04-30 12:59:39 +0100167 const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000168 rhs_info);
169
Sheri Zhang1a378102020-04-30 12:59:39 +0100170 const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
171 TensorInfo(rhs_shape_reshaped, 1, dt_input1),
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100172 kernel_info);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000173
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100174 const TensorShape bias_shape(N,
Sheri Zhang1a378102020-04-30 12:59:39 +0100175 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 +0100176 broadcast_bias? 1 : b_value);
177
Sheri Zhang1a378102020-04-30 12:59:39 +0100178 // Create tensor info
179 TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0);
180 TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1);
181 TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2);
182 TensorInfo dst = TensorInfo(dst_shape, 1, dt_output);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000183
184 // Create and configure function
185 CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
Sheri Zhang1a378102020-04-30 12:59:39 +0100186 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 +0000187}
188} // namespace
189
190TEST_SUITE(CL)
191TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100192
193/** Validate tests
194 *
195 * A series of validation tests on configurations which according to the API specification
196 * the function should fail against.
197 *
198 * Checks performed in order:
199 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
200 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
201 * - Unsupported N0: NO can only be 2,3,4,8,16
202 * - Unsupported K0: KO can only be 2,3,4,8,16
203 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
204 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
205 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100206 * - Correct support for creating an OpenCL image object from buffer
207 * - Incorrect support for creating an OpenCL image object from buffer. N0 is 2 but it can only be 4,8 and 16
208 * - Incorrect support for creating an OpenCL image object from buffer. Data type is F16 but it can only be F32
Sheri Zhang1a378102020-04-30 12:59:39 +0100209 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100210DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
211framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
212framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
213framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
214framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
215framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
216framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
217framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
218framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
219framework::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})),
220framework::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})),
221framework::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})),
222framework::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})),
223framework::dataset::make("Beta", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f , 1.0f})),
224framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, false })),
225b_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 +0100226{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100227 bool expected_value = expected;
228
229 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
230 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
231 {
232 expected_value = false;
233 }
234
235 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);
236 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100237}
238
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000239TEST_SUITE(Float)
240TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000241
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100242FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
243 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000244 m_values,
245 n_values),
246 k_values),
247 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100248 m0_values_precommit),
249 n0_values_precommit),
250 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100251 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000252 i_values_rhs),
253 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100254 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000255 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100256 a_values),
257 beta_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100258 broadcast_bias_values),
259 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000260{
261 // Validate output
262 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
263}
264
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100265FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
266 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
267 m_values,
268 n_values),
269 k_values),
270 b_values),
271 m0_values_nightly),
272 n0_values_nightly),
273 k0_values_nightly),
274 h0_values),
275 i_values_rhs),
276 t_values_rhs),
277 framework::dataset::make("export_to_cl_image_rhs", false)),
278 framework::dataset::make("DataType", DataType::F32)),
279 a_values),
280 beta_values),
281 broadcast_bias_values),
282 act_values))
283{
284 // Validate output
285 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
286}
287
288FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
289 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000290 m_w_values,
291 m_h_values),
292 n_values),
293 k_values),
294 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100295 m0_values_precommit),
296 n0_values_precommit),
297 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100298 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000299 i_values_rhs),
300 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100301 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000302 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100303 a_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100304 beta_values),
305 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000306{
307 // Validate output
308 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
309}
310
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100311FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
312 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
313 m_w_values,
314 m_h_values),
315 n_values),
316 k_values),
317 b_values),
318 m0_values_nightly),
319 n0_values_nightly),
320 k0_values_nightly),
321 h0_values),
322 i_values_rhs),
323 t_values_rhs),
324 framework::dataset::make("export_to_cl_image_rhs", false)),
325 framework::dataset::make("DataType", DataType::F32)),
326 a_values),
327 beta_values),
328 act_values))
329{
330 // Validate output
331 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
332}
333
334TEST_SUITE(ExportToCLImage)
335FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
336 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
337 m_values,
338 n_values),
339 k_values),
340 b_values),
341 m0_values_precommit),
342 n0_values_precommit),
343 k0_values_precommit),
344 h0_values),
345 i_values_rhs),
346 t_values_rhs),
347 framework::dataset::make("export_to_cl_image_rhs", true)),
348 framework::dataset::make("DataType", DataType::F32)),
349 a_values),
350 beta_values),
351 broadcast_bias_values),
352 act_values))
353{
354 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
355 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
356 {
357 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
358 }
359 else
360 {
361 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
362 framework::ARM_COMPUTE_PRINT_INFO();
363 }
364}
365
366FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
367 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
368 m_values,
369 n_values),
370 k_values),
371 b_values),
372 m0_values_nightly),
373 n0_values_nightly),
374 k0_values_nightly),
375 h0_values),
376 i_values_rhs),
377 t_values_rhs),
378 framework::dataset::make("export_to_cl_image_rhs", true)),
379 framework::dataset::make("DataType", DataType::F32)),
380 a_values),
381 beta_values),
382 broadcast_bias_values),
383 act_values))
384{
385 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
386 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
387 {
388 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
389 }
390 else
391 {
392 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
393 framework::ARM_COMPUTE_PRINT_INFO();
394 }
395}
396
397FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
398 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
399 m_w_values,
400 m_h_values),
401 n_values),
402 k_values),
403 b_values),
404 m0_values_precommit),
405 n0_values_precommit),
406 k0_values_precommit),
407 h0_values),
408 i_values_rhs),
409 t_values_rhs),
410 framework::dataset::make("export_to_cl_image_rhs", true)),
411 framework::dataset::make("DataType", DataType::F32)),
412 a_values),
413 beta_values),
414 act_values))
415{
416 // Validate output
417 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
418}
419
420FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
421 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
422 m_w_values,
423 m_h_values),
424 n_values),
425 k_values),
426 b_values),
427 m0_values_nightly),
428 n0_values_nightly),
429 k0_values_nightly),
430 h0_values),
431 i_values_rhs),
432 t_values_rhs),
433 framework::dataset::make("export_to_cl_image_rhs", true)),
434 framework::dataset::make("DataType", DataType::F32)),
435 a_values),
436 beta_values),
437 act_values))
438{
439 // Validate output
440 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
441}
442TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000443TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100444
445TEST_SUITE(FP16)
446FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
447 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
448 m_values,
449 n_values),
450 k_values),
451 b_values),
452 m0_values_precommit),
453 n0_values_precommit),
454 k0_values_precommit),
455 h0_values),
456 i_values_rhs),
457 t_values_rhs),
458 framework::dataset::make("export_to_cl_image_rhs", false)),
459 framework::dataset::make("DataType", DataType::F16)),
460 a_values),
461 beta_values),
462 broadcast_bias_values),
463 act_values))
464{
465 // Validate output
466 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
467}
468
469FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
470 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
471 m_values,
472 n_values),
473 k_values),
474 b_values),
475 m0_values_nightly),
476 n0_values_nightly),
477 k0_values_nightly),
478 h0_values),
479 i_values_rhs),
480 t_values_rhs),
481 framework::dataset::make("export_to_cl_image_rhs", false)),
482 framework::dataset::make("DataType", DataType::F16)),
483 a_values),
484 beta_values),
485 broadcast_bias_values),
486 act_values))
487{
488 // Validate output
489 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
490}
491
492FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
493 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
494 m_w_values,
495 m_h_values),
496 n_values),
497 k_values),
498 b_values),
499 m0_values_precommit),
500 n0_values_precommit),
501 k0_values_precommit),
502 h0_values),
503 i_values_rhs),
504 t_values_rhs),
505 framework::dataset::make("export_to_cl_image_rhs", false)),
506 framework::dataset::make("DataType", DataType::F16)),
507 a_values),
508 beta_values),
509 act_values))
510{
511 // Validate output
512 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
513}
514
515FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
516 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
517 m_w_values,
518 m_h_values),
519 n_values),
520 k_values),
521 b_values),
522 m0_values_nightly),
523 n0_values_nightly),
524 k0_values_nightly),
525 h0_values),
526 i_values_rhs),
527 t_values_rhs),
528 framework::dataset::make("export_to_cl_image_rhs", false)),
529 framework::dataset::make("DataType", DataType::F16)),
530 a_values),
531 beta_values),
532 act_values))
533{
534 // Validate output
535 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
536}
537
538TEST_SUITE_END() // FP16
539
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000540TEST_SUITE_END() // Float
541TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
542TEST_SUITE_END() // CL
543} // namespace validation
544} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100545} // namespace arm_compute