blob: 6a1d495576959732f61c6e11e33df6f047477516 [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
SiCong Li406a13f2020-07-15 12:09:58 +0100249 // Padding can be added along rhs and bias's X dimension
250 return dst.info()->padding().empty() && lhs.info()->padding().empty() && bias.info()->padding().bottom == 0 && bias.info()->padding().top == 0;
SiCong Li3a501662020-06-26 10:02:06 +0100251}
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000252} // namespace
253
254TEST_SUITE(CL)
255TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100256
257/** Validate tests
258 *
259 * A series of validation tests on configurations which according to the API specification
260 * the function should fail against.
261 *
262 * Checks performed in order:
263 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
264 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
265 * - Unsupported N0: NO can only be 2,3,4,8,16
266 * - Unsupported K0: KO can only be 2,3,4,8,16
267 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
268 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
269 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100270 * - Correct support for creating an OpenCL image object from buffer
271 * - Incorrect support for creating an OpenCL image object from buffer. N0 is 2 but it can only be 4,8 and 16
272 * - 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 +0100273 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100274DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
275framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
276framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
277framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
278framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
279framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
280framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
281framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
282framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
283framework::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})),
284framework::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})),
285framework::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})),
286framework::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})),
287framework::dataset::make("Beta", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f , 1.0f})),
288framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, false })),
289b_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 +0100290{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100291 bool expected_value = expected;
292
293 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
294 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
295 {
296 expected_value = false;
297 }
298
299 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);
300 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100301}
302
SiCong Li3a501662020-06-26 10:02:06 +0100303/** Validate zero padding tests
304 *
305 * A series of validation tests to check that no padding is added as part of configuration for 4 different scenarios.
306 *
307 * Checks performed in order:
308 * - No partial blocks in both x and y dimensions
309 * - Partial blocks in x dimension
310 * - Partial blocks in y dimension
311 * - Partial blocks in both x and y dimensions
SiCong Li3b64e3e2020-07-28 09:01:28 +0100312 * - Special case: partial_n0 == 9 (vstore1 should be invoked instead of vstore_partial_1)
SiCong Li3a501662020-06-26 10:02:06 +0100313 */
314DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(zip(zip(zip(
SiCong Li3b64e3e2020-07-28 09:01:28 +0100315framework::dataset::make("M", { 24, 64, 101, 1, 100 }),
316framework::dataset::make("N", { 48, 29, 16, 122, 41 })),
317framework::dataset::make("M0", { 4, 8, 7, 2, 1 })),
318framework::dataset::make("N0", { 4, 4, 16, 3, 16 })),
319framework::dataset::make("export_to_cl_image", { false, true, true, false, false })),
SiCong Li3a501662020-06-26 10:02:06 +0100320m_value, n_value, m0_value, n0_value, export_to_cl_image)
321{
322 constexpr DataType dt = DataType::F32;
323 // Disable export_to_cl_image if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
324 bool actual_export_to_cl_image = image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image;
325
326 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);
327 ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
328}
329
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000330TEST_SUITE(Float)
331TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000332
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100333FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
334 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000335 m_values,
336 n_values),
337 k_values),
338 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100339 m0_values_precommit),
340 n0_values_precommit),
341 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100342 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000343 i_values_rhs),
344 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100345 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000346 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100347 a_values),
348 beta_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100349 broadcast_bias_values),
350 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000351{
352 // Validate output
353 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
354}
355
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100356FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
357 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
358 m_values,
359 n_values),
360 k_values),
361 b_values),
362 m0_values_nightly),
363 n0_values_nightly),
364 k0_values_nightly),
365 h0_values),
366 i_values_rhs),
367 t_values_rhs),
368 framework::dataset::make("export_to_cl_image_rhs", false)),
369 framework::dataset::make("DataType", DataType::F32)),
370 a_values),
371 beta_values),
372 broadcast_bias_values),
373 act_values))
374{
375 // Validate output
376 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
377}
378
379FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
380 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000381 m_w_values,
382 m_h_values),
383 n_values),
384 k_values),
385 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100386 m0_values_precommit),
387 n0_values_precommit),
388 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100389 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000390 i_values_rhs),
391 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100392 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000393 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100394 a_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100395 beta_values),
396 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000397{
398 // Validate output
399 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
400}
401
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100402FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
403 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
404 m_w_values,
405 m_h_values),
406 n_values),
407 k_values),
408 b_values),
409 m0_values_nightly),
410 n0_values_nightly),
411 k0_values_nightly),
412 h0_values),
413 i_values_rhs),
414 t_values_rhs),
415 framework::dataset::make("export_to_cl_image_rhs", false)),
416 framework::dataset::make("DataType", DataType::F32)),
417 a_values),
418 beta_values),
419 act_values))
420{
421 // Validate output
422 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
423}
424
425TEST_SUITE(ExportToCLImage)
426FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
427 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
428 m_values,
429 n_values),
430 k_values),
431 b_values),
432 m0_values_precommit),
433 n0_values_precommit),
434 k0_values_precommit),
435 h0_values),
436 i_values_rhs),
437 t_values_rhs),
438 framework::dataset::make("export_to_cl_image_rhs", true)),
439 framework::dataset::make("DataType", DataType::F32)),
440 a_values),
441 beta_values),
442 broadcast_bias_values),
443 act_values))
444{
445 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
446 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
447 {
448 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
449 }
450 else
451 {
452 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
453 framework::ARM_COMPUTE_PRINT_INFO();
454 }
455}
456
457FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
458 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
459 m_values,
460 n_values),
461 k_values),
462 b_values),
463 m0_values_nightly),
464 n0_values_nightly),
465 k0_values_nightly),
466 h0_values),
467 i_values_rhs),
468 t_values_rhs),
469 framework::dataset::make("export_to_cl_image_rhs", true)),
470 framework::dataset::make("DataType", DataType::F32)),
471 a_values),
472 beta_values),
473 broadcast_bias_values),
474 act_values))
475{
476 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
477 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
478 {
479 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
480 }
481 else
482 {
483 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
484 framework::ARM_COMPUTE_PRINT_INFO();
485 }
486}
487
488FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
489 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
490 m_w_values,
491 m_h_values),
492 n_values),
493 k_values),
494 b_values),
495 m0_values_precommit),
496 n0_values_precommit),
497 k0_values_precommit),
498 h0_values),
499 i_values_rhs),
500 t_values_rhs),
501 framework::dataset::make("export_to_cl_image_rhs", true)),
502 framework::dataset::make("DataType", DataType::F32)),
503 a_values),
504 beta_values),
505 act_values))
506{
507 // Validate output
508 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
509}
510
511FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
512 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
513 m_w_values,
514 m_h_values),
515 n_values),
516 k_values),
517 b_values),
518 m0_values_nightly),
519 n0_values_nightly),
520 k0_values_nightly),
521 h0_values),
522 i_values_rhs),
523 t_values_rhs),
524 framework::dataset::make("export_to_cl_image_rhs", true)),
525 framework::dataset::make("DataType", DataType::F32)),
526 a_values),
527 beta_values),
528 act_values))
529{
530 // Validate output
531 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
532}
533TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000534TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100535
536TEST_SUITE(FP16)
537FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
538 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
539 m_values,
540 n_values),
541 k_values),
542 b_values),
543 m0_values_precommit),
544 n0_values_precommit),
545 k0_values_precommit),
546 h0_values),
547 i_values_rhs),
548 t_values_rhs),
549 framework::dataset::make("export_to_cl_image_rhs", false)),
550 framework::dataset::make("DataType", DataType::F16)),
551 a_values),
552 beta_values),
553 broadcast_bias_values),
554 act_values))
555{
556 // Validate output
557 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
558}
559
560FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
561 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
562 m_values,
563 n_values),
564 k_values),
565 b_values),
566 m0_values_nightly),
567 n0_values_nightly),
568 k0_values_nightly),
569 h0_values),
570 i_values_rhs),
571 t_values_rhs),
572 framework::dataset::make("export_to_cl_image_rhs", false)),
573 framework::dataset::make("DataType", DataType::F16)),
574 a_values),
575 beta_values),
576 broadcast_bias_values),
577 act_values))
578{
579 // Validate output
580 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
581}
582
583FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
584 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
585 m_w_values,
586 m_h_values),
587 n_values),
588 k_values),
589 b_values),
590 m0_values_precommit),
591 n0_values_precommit),
592 k0_values_precommit),
593 h0_values),
594 i_values_rhs),
595 t_values_rhs),
596 framework::dataset::make("export_to_cl_image_rhs", false)),
597 framework::dataset::make("DataType", DataType::F16)),
598 a_values),
599 beta_values),
600 act_values))
601{
602 // Validate output
603 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
604}
605
606FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
607 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
608 m_w_values,
609 m_h_values),
610 n_values),
611 k_values),
612 b_values),
613 m0_values_nightly),
614 n0_values_nightly),
615 k0_values_nightly),
616 h0_values),
617 i_values_rhs),
618 t_values_rhs),
619 framework::dataset::make("export_to_cl_image_rhs", false)),
620 framework::dataset::make("DataType", DataType::F16)),
621 a_values),
622 beta_values),
623 act_values))
624{
625 // Validate output
626 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
627}
628
629TEST_SUITE_END() // FP16
630
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000631TEST_SUITE_END() // Float
632TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
633TEST_SUITE_END() // CL
634} // namespace validation
635} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100636} // namespace arm_compute