blob: 0456ca2017711589464dd6024d947dea92a28e6b [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}
SiCong Li3a501662020-06-26 10:02:06 +0100188
189/** Zero padding test */
190bool validate_zero_padding(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
191 unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
192 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,
193 DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
194{
195 const unsigned int M = m_value;
196 const unsigned int N = n_value;
197 const unsigned int K = k_value;
198
199 GEMMLHSMatrixInfo lhs_info;
200 lhs_info.m0 = m0_value;
201 lhs_info.k0 = k0_value;
202
203 GEMMRHSMatrixInfo rhs_info;
204 rhs_info.n0 = n0_value;
205 rhs_info.k0 = k0_value;
206 rhs_info.h0 = h0_value;
207 rhs_info.interleave = i_value_rhs;
208 rhs_info.transpose = t_value_rhs;
209 rhs_info.export_to_cl_image = export_to_cl_image;
210
211 GEMMKernelInfo kernel_info;
212 kernel_info.m = M;
213 kernel_info.n = N;
214 kernel_info.k = K;
215 kernel_info.depth_output_gemm3d = depth_output_gemm3d;
216 kernel_info.reinterpret_input_as_3d = input_as_3d;
217 kernel_info.broadcast_bias = broadcast_bias;
218 kernel_info.activation_info = act_info;
219
220 const TensorShape lhs_shape(K, M, b_value);
221 const TensorShape rhs_shape(N, K, b_value);
222 const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
223 rhs_info);
224
225 const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
226 TensorInfo(rhs_shape_reshaped, 1, dt_input1),
227 kernel_info);
228
229 const TensorShape bias_shape(N,
230 M, // Correct calculation should be: broadcast_bias? 1 : M, it's wrong here on purpose just for validation test
231 broadcast_bias? 1 : b_value);
232
233 // Create tensors
234 CLTensor lhs = create_tensor<CLTensor>(lhs_shape, dt_input0);
235 CLTensor rhs_reshaped = create_tensor<CLTensor>(rhs_shape_reshaped, dt_input1);
236 CLTensor bias = create_tensor<CLTensor>(bias_shape, dt_input2);
237 CLTensor dst = create_tensor<CLTensor>(dst_shape, dt_output);
238
239 ARM_COMPUTE_EXPECT(lhs.info()->is_resizable(), framework::LogLevel::ERRORS);
240 ARM_COMPUTE_EXPECT(rhs_reshaped.info()->is_resizable(), framework::LogLevel::ERRORS);
241 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
242 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
243
244 // Validate zero-padding
245 CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
246
247 gemm.configure(&lhs, &rhs_reshaped, &bias, &dst, alpha, beta, lhs_info, rhs_info, kernel_info);
248
249 return dst.info()->padding().empty();
250}
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000251} // namespace
252
253TEST_SUITE(CL)
254TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100255
256/** Validate tests
257 *
258 * A series of validation tests on configurations which according to the API specification
259 * the function should fail against.
260 *
261 * Checks performed in order:
262 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
263 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
264 * - Unsupported N0: NO can only be 2,3,4,8,16
265 * - Unsupported K0: KO can only be 2,3,4,8,16
266 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
267 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
268 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100269 * - Correct support for creating an OpenCL image object from buffer
270 * - Incorrect support for creating an OpenCL image object from buffer. N0 is 2 but it can only be 4,8 and 16
271 * - 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 +0100272 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100273DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
274framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
275framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
276framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
277framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
278framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
279framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
280framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
281framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
282framework::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})),
283framework::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})),
284framework::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})),
285framework::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})),
286framework::dataset::make("Beta", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f , 1.0f})),
287framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, false })),
288b_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 +0100289{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100290 bool expected_value = expected;
291
292 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
293 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
294 {
295 expected_value = false;
296 }
297
298 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);
299 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100300}
301
SiCong Li3a501662020-06-26 10:02:06 +0100302/** Validate zero padding tests
303 *
304 * A series of validation tests to check that no padding is added as part of configuration for 4 different scenarios.
305 *
306 * Checks performed in order:
307 * - No partial blocks in both x and y dimensions
308 * - Partial blocks in x dimension
309 * - Partial blocks in y dimension
310 * - Partial blocks in both x and y dimensions
311 */
312DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(zip(zip(zip(
313framework::dataset::make("M", { 24, 64, 101, 1 }),
314framework::dataset::make("N", { 48, 29, 16, 122 })),
315framework::dataset::make("M0", { 4, 8, 7, 2 })),
316framework::dataset::make("N0", { 4, 4, 16, 3 })),
317framework::dataset::make("export_to_cl_image", { false, true, true, false })),
318m_value, n_value, m0_value, n0_value, export_to_cl_image)
319{
320 constexpr DataType dt = DataType::F32;
321 // Disable export_to_cl_image if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
322 bool actual_export_to_cl_image = image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image;
323
324 bool status = validate_zero_padding(m_value, n_value, 23, 1, m0_value, n0_value, 4, 1, false, false, actual_export_to_cl_image, false, 0, 0, ActivationLayerInfo(), dt, dt, dt, dt, 1.0f, 1.0f);
325 ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
326}
327
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000328TEST_SUITE(Float)
329TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000330
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100331FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
332 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000333 m_values,
334 n_values),
335 k_values),
336 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100337 m0_values_precommit),
338 n0_values_precommit),
339 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100340 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000341 i_values_rhs),
342 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100343 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000344 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100345 a_values),
346 beta_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100347 broadcast_bias_values),
348 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000349{
350 // Validate output
351 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
352}
353
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100354FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
355 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
356 m_values,
357 n_values),
358 k_values),
359 b_values),
360 m0_values_nightly),
361 n0_values_nightly),
362 k0_values_nightly),
363 h0_values),
364 i_values_rhs),
365 t_values_rhs),
366 framework::dataset::make("export_to_cl_image_rhs", false)),
367 framework::dataset::make("DataType", DataType::F32)),
368 a_values),
369 beta_values),
370 broadcast_bias_values),
371 act_values))
372{
373 // Validate output
374 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
375}
376
377FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
378 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000379 m_w_values,
380 m_h_values),
381 n_values),
382 k_values),
383 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100384 m0_values_precommit),
385 n0_values_precommit),
386 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100387 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000388 i_values_rhs),
389 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100390 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000391 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100392 a_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100393 beta_values),
394 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000395{
396 // Validate output
397 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
398}
399
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100400FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
401 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
402 m_w_values,
403 m_h_values),
404 n_values),
405 k_values),
406 b_values),
407 m0_values_nightly),
408 n0_values_nightly),
409 k0_values_nightly),
410 h0_values),
411 i_values_rhs),
412 t_values_rhs),
413 framework::dataset::make("export_to_cl_image_rhs", false)),
414 framework::dataset::make("DataType", DataType::F32)),
415 a_values),
416 beta_values),
417 act_values))
418{
419 // Validate output
420 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
421}
422
423TEST_SUITE(ExportToCLImage)
424FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
425 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
426 m_values,
427 n_values),
428 k_values),
429 b_values),
430 m0_values_precommit),
431 n0_values_precommit),
432 k0_values_precommit),
433 h0_values),
434 i_values_rhs),
435 t_values_rhs),
436 framework::dataset::make("export_to_cl_image_rhs", true)),
437 framework::dataset::make("DataType", DataType::F32)),
438 a_values),
439 beta_values),
440 broadcast_bias_values),
441 act_values))
442{
443 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
444 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
445 {
446 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
447 }
448 else
449 {
450 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
451 framework::ARM_COMPUTE_PRINT_INFO();
452 }
453}
454
455FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
456 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
457 m_values,
458 n_values),
459 k_values),
460 b_values),
461 m0_values_nightly),
462 n0_values_nightly),
463 k0_values_nightly),
464 h0_values),
465 i_values_rhs),
466 t_values_rhs),
467 framework::dataset::make("export_to_cl_image_rhs", true)),
468 framework::dataset::make("DataType", DataType::F32)),
469 a_values),
470 beta_values),
471 broadcast_bias_values),
472 act_values))
473{
474 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
475 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
476 {
477 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
478 }
479 else
480 {
481 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
482 framework::ARM_COMPUTE_PRINT_INFO();
483 }
484}
485
486FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
487 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
488 m_w_values,
489 m_h_values),
490 n_values),
491 k_values),
492 b_values),
493 m0_values_precommit),
494 n0_values_precommit),
495 k0_values_precommit),
496 h0_values),
497 i_values_rhs),
498 t_values_rhs),
499 framework::dataset::make("export_to_cl_image_rhs", true)),
500 framework::dataset::make("DataType", DataType::F32)),
501 a_values),
502 beta_values),
503 act_values))
504{
505 // Validate output
506 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
507}
508
509FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
510 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
511 m_w_values,
512 m_h_values),
513 n_values),
514 k_values),
515 b_values),
516 m0_values_nightly),
517 n0_values_nightly),
518 k0_values_nightly),
519 h0_values),
520 i_values_rhs),
521 t_values_rhs),
522 framework::dataset::make("export_to_cl_image_rhs", true)),
523 framework::dataset::make("DataType", DataType::F32)),
524 a_values),
525 beta_values),
526 act_values))
527{
528 // Validate output
529 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
530}
531TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000532TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100533
534TEST_SUITE(FP16)
535FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
536 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
537 m_values,
538 n_values),
539 k_values),
540 b_values),
541 m0_values_precommit),
542 n0_values_precommit),
543 k0_values_precommit),
544 h0_values),
545 i_values_rhs),
546 t_values_rhs),
547 framework::dataset::make("export_to_cl_image_rhs", false)),
548 framework::dataset::make("DataType", DataType::F16)),
549 a_values),
550 beta_values),
551 broadcast_bias_values),
552 act_values))
553{
554 // Validate output
555 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
556}
557
558FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
559 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
560 m_values,
561 n_values),
562 k_values),
563 b_values),
564 m0_values_nightly),
565 n0_values_nightly),
566 k0_values_nightly),
567 h0_values),
568 i_values_rhs),
569 t_values_rhs),
570 framework::dataset::make("export_to_cl_image_rhs", false)),
571 framework::dataset::make("DataType", DataType::F16)),
572 a_values),
573 beta_values),
574 broadcast_bias_values),
575 act_values))
576{
577 // Validate output
578 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
579}
580
581FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
582 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
583 m_w_values,
584 m_h_values),
585 n_values),
586 k_values),
587 b_values),
588 m0_values_precommit),
589 n0_values_precommit),
590 k0_values_precommit),
591 h0_values),
592 i_values_rhs),
593 t_values_rhs),
594 framework::dataset::make("export_to_cl_image_rhs", false)),
595 framework::dataset::make("DataType", DataType::F16)),
596 a_values),
597 beta_values),
598 act_values))
599{
600 // Validate output
601 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
602}
603
604FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
605 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
606 m_w_values,
607 m_h_values),
608 n_values),
609 k_values),
610 b_values),
611 m0_values_nightly),
612 n0_values_nightly),
613 k0_values_nightly),
614 h0_values),
615 i_values_rhs),
616 t_values_rhs),
617 framework::dataset::make("export_to_cl_image_rhs", false)),
618 framework::dataset::make("DataType", DataType::F16)),
619 a_values),
620 beta_values),
621 act_values))
622{
623 // Validate output
624 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
625}
626
627TEST_SUITE_END() // FP16
628
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000629TEST_SUITE_END() // Float
630TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
631TEST_SUITE_END() // CL
632} // namespace validation
633} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100634} // namespace arm_compute