blob: afb2807d01d21804743ddaf3f495a94ce5913ff6 [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
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}
SiCong Li3a501662020-06-26 10:02:06 +0100214
215/** Zero padding test */
216bool validate_zero_padding(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
217 unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
218 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,
219 DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
220{
221 const unsigned int M = m_value;
222 const unsigned int N = n_value;
223 const unsigned int K = k_value;
224
225 GEMMLHSMatrixInfo lhs_info;
226 lhs_info.m0 = m0_value;
227 lhs_info.k0 = k0_value;
228
229 GEMMRHSMatrixInfo rhs_info;
230 rhs_info.n0 = n0_value;
231 rhs_info.k0 = k0_value;
232 rhs_info.h0 = h0_value;
233 rhs_info.interleave = i_value_rhs;
234 rhs_info.transpose = t_value_rhs;
235 rhs_info.export_to_cl_image = export_to_cl_image;
236
237 GEMMKernelInfo kernel_info;
238 kernel_info.m = M;
239 kernel_info.n = N;
240 kernel_info.k = K;
241 kernel_info.depth_output_gemm3d = depth_output_gemm3d;
242 kernel_info.reinterpret_input_as_3d = input_as_3d;
243 kernel_info.broadcast_bias = broadcast_bias;
244 kernel_info.activation_info = act_info;
245
246 const TensorShape lhs_shape(K, M, b_value);
247 const TensorShape rhs_shape(N, K, b_value);
248 const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
249 rhs_info);
250
251 const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
252 TensorInfo(rhs_shape_reshaped, 1, dt_input1),
253 kernel_info);
254
255 const TensorShape bias_shape(N,
256 M, // Correct calculation should be: broadcast_bias? 1 : M, it's wrong here on purpose just for validation test
257 broadcast_bias? 1 : b_value);
258
259 // Create tensors
260 CLTensor lhs = create_tensor<CLTensor>(lhs_shape, dt_input0);
261 CLTensor rhs_reshaped = create_tensor<CLTensor>(rhs_shape_reshaped, dt_input1);
262 CLTensor bias = create_tensor<CLTensor>(bias_shape, dt_input2);
263 CLTensor dst = create_tensor<CLTensor>(dst_shape, dt_output);
264
265 ARM_COMPUTE_EXPECT(lhs.info()->is_resizable(), framework::LogLevel::ERRORS);
266 ARM_COMPUTE_EXPECT(rhs_reshaped.info()->is_resizable(), framework::LogLevel::ERRORS);
267 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
268 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
269
270 // Validate zero-padding
271 CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
272
273 gemm.configure(&lhs, &rhs_reshaped, &bias, &dst, alpha, beta, lhs_info, rhs_info, kernel_info);
274
SiCong Li406a13f2020-07-15 12:09:58 +0100275 // Padding can be added along rhs and bias's X dimension
276 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 +0100277}
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000278} // namespace
279
280TEST_SUITE(CL)
281TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100282
283/** Validate tests
284 *
285 * A series of validation tests on configurations which according to the API specification
286 * the function should fail against.
287 *
288 * Checks performed in order:
289 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
290 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
291 * - Unsupported N0: NO can only be 2,3,4,8,16
292 * - Unsupported K0: KO can only be 2,3,4,8,16
293 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
294 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
295 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100296 * - Correct support for creating an OpenCL image object from buffer
297 * - 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 +0100298 * - Correct F16 support for creating an OpenCL image object from buffer.
Sheri Zhang1a378102020-04-30 12:59:39 +0100299 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100300DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
301framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
302framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
303framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
304framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
305framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
306framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
307framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
308framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
309framework::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})),
310framework::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})),
311framework::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})),
312framework::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})),
313framework::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 +0100314framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, true })),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100315b_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 +0100316{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100317 bool expected_value = expected;
318
319 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
320 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
321 {
322 expected_value = false;
323 }
324
325 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);
326 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100327}
328
SiCong Li3a501662020-06-26 10:02:06 +0100329/** Validate zero padding tests
330 *
331 * A series of validation tests to check that no padding is added as part of configuration for 4 different scenarios.
332 *
333 * Checks performed in order:
334 * - No partial blocks in both x and y dimensions
335 * - Partial blocks in x dimension
336 * - Partial blocks in y dimension
337 * - Partial blocks in both x and y dimensions
SiCong Li3b64e3e2020-07-28 09:01:28 +0100338 * - Special case: partial_n0 == 9 (vstore1 should be invoked instead of vstore_partial_1)
SiCong Li3a501662020-06-26 10:02:06 +0100339 */
340DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(zip(zip(zip(
SiCong Li3b64e3e2020-07-28 09:01:28 +0100341framework::dataset::make("M", { 24, 64, 101, 1, 100 }),
342framework::dataset::make("N", { 48, 29, 16, 122, 41 })),
343framework::dataset::make("M0", { 4, 8, 7, 2, 1 })),
344framework::dataset::make("N0", { 4, 4, 16, 3, 16 })),
345framework::dataset::make("export_to_cl_image", { false, true, true, false, false })),
SiCong Li3a501662020-06-26 10:02:06 +0100346m_value, n_value, m0_value, n0_value, export_to_cl_image)
347{
348 constexpr DataType dt = DataType::F32;
349 // Disable export_to_cl_image if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
350 bool actual_export_to_cl_image = image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image;
351
352 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);
353 ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
354}
355
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000356TEST_SUITE(Float)
357TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000358
SiCong Lib972ae62020-08-03 15:39:45 +0100359FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
360 combine(combine(
361 framework::dataset::make("M", 3),
362 framework::dataset::make("N", 1)),
363 boundary_handling_cases))
364{
365 // Validate output
366 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
367}
368
369FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
370 combine(combine(
371 framework::dataset::make("M", 64),
372 framework::dataset::make("N", 43)),
373 boundary_handling_cases))
374{
375 // Validate output
376 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
377}
378
379FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
380 combine(combine(
381 framework::dataset::make("M", 64),
382 framework::dataset::make("N", 32)),
383 boundary_handling_cases))
384{
385 // Validate output
386 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
387}
388
389FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
390 combine(combine(
391 framework::dataset::make("M", 37),
392 framework::dataset::make("N", 32)),
393 boundary_handling_cases))
394{
395 // Validate output
396 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
397}
398
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100399FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
400 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000401 m_values,
402 n_values),
403 k_values),
404 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100405 m0_values_precommit),
406 n0_values_precommit),
407 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100408 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000409 i_values_rhs),
410 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100411 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000412 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100413 a_values),
414 beta_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100415 broadcast_bias_values),
416 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000417{
418 // Validate output
419 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
420}
421
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100422FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
423 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
424 m_values,
425 n_values),
426 k_values),
427 b_values),
428 m0_values_nightly),
429 n0_values_nightly),
430 k0_values_nightly),
431 h0_values),
432 i_values_rhs),
433 t_values_rhs),
434 framework::dataset::make("export_to_cl_image_rhs", false)),
435 framework::dataset::make("DataType", DataType::F32)),
436 a_values),
437 beta_values),
438 broadcast_bias_values),
439 act_values))
440{
441 // Validate output
442 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
443}
444
445FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
446 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000447 m_w_values,
448 m_h_values),
449 n_values),
450 k_values),
451 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100452 m0_values_precommit),
453 n0_values_precommit),
454 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100455 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000456 i_values_rhs),
457 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100458 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000459 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100460 a_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100461 beta_values),
462 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000463{
464 // Validate output
465 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
466}
467
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100468FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
469 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
470 m_w_values,
471 m_h_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::F32)),
483 a_values),
484 beta_values),
485 act_values))
486{
487 // Validate output
488 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
489}
490
491TEST_SUITE(ExportToCLImage)
492FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
493 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
494 m_values,
495 n_values),
496 k_values),
497 b_values),
498 m0_values_precommit),
499 n0_values_precommit),
500 k0_values_precommit),
501 h0_values),
502 i_values_rhs),
503 t_values_rhs),
504 framework::dataset::make("export_to_cl_image_rhs", true)),
505 framework::dataset::make("DataType", DataType::F32)),
506 a_values),
507 beta_values),
508 broadcast_bias_values),
509 act_values))
510{
511 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
512 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
513 {
514 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
515 }
516 else
517 {
518 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
519 framework::ARM_COMPUTE_PRINT_INFO();
520 }
521}
522
523FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
524 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
525 m_values,
526 n_values),
527 k_values),
528 b_values),
529 m0_values_nightly),
530 n0_values_nightly),
531 k0_values_nightly),
532 h0_values),
533 i_values_rhs),
534 t_values_rhs),
535 framework::dataset::make("export_to_cl_image_rhs", true)),
536 framework::dataset::make("DataType", DataType::F32)),
537 a_values),
538 beta_values),
539 broadcast_bias_values),
540 act_values))
541{
542 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
543 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
544 {
545 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
546 }
547 else
548 {
549 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
550 framework::ARM_COMPUTE_PRINT_INFO();
551 }
552}
553
554FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
555 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
556 m_w_values,
557 m_h_values),
558 n_values),
559 k_values),
560 b_values),
561 m0_values_precommit),
562 n0_values_precommit),
563 k0_values_precommit),
564 h0_values),
565 i_values_rhs),
566 t_values_rhs),
567 framework::dataset::make("export_to_cl_image_rhs", true)),
568 framework::dataset::make("DataType", DataType::F32)),
569 a_values),
570 beta_values),
571 act_values))
572{
573 // Validate output
574 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
575}
576
577FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
578 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
579 m_w_values,
580 m_h_values),
581 n_values),
582 k_values),
583 b_values),
584 m0_values_nightly),
585 n0_values_nightly),
586 k0_values_nightly),
587 h0_values),
588 i_values_rhs),
589 t_values_rhs),
590 framework::dataset::make("export_to_cl_image_rhs", true)),
591 framework::dataset::make("DataType", DataType::F32)),
592 a_values),
593 beta_values),
594 act_values))
595{
596 // Validate output
597 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
598}
599TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000600TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100601
602TEST_SUITE(FP16)
603FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
604 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
605 m_values,
606 n_values),
607 k_values),
608 b_values),
609 m0_values_precommit),
610 n0_values_precommit),
611 k0_values_precommit),
612 h0_values),
613 i_values_rhs),
614 t_values_rhs),
615 framework::dataset::make("export_to_cl_image_rhs", false)),
616 framework::dataset::make("DataType", DataType::F16)),
617 a_values),
618 beta_values),
619 broadcast_bias_values),
620 act_values))
621{
622 // Validate output
623 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
624}
625
626FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
627 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
628 m_values,
629 n_values),
630 k_values),
631 b_values),
632 m0_values_nightly),
633 n0_values_nightly),
634 k0_values_nightly),
635 h0_values),
636 i_values_rhs),
637 t_values_rhs),
638 framework::dataset::make("export_to_cl_image_rhs", false)),
639 framework::dataset::make("DataType", DataType::F16)),
640 a_values),
641 beta_values),
642 broadcast_bias_values),
643 act_values))
644{
645 // Validate output
646 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
647}
648
649FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
650 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
651 m_w_values,
652 m_h_values),
653 n_values),
654 k_values),
655 b_values),
656 m0_values_precommit),
657 n0_values_precommit),
658 k0_values_precommit),
659 h0_values),
660 i_values_rhs),
661 t_values_rhs),
662 framework::dataset::make("export_to_cl_image_rhs", false)),
663 framework::dataset::make("DataType", DataType::F16)),
664 a_values),
665 beta_values),
666 act_values))
667{
668 // Validate output
669 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
670}
671
672FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
673 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
674 m_w_values,
675 m_h_values),
676 n_values),
677 k_values),
678 b_values),
679 m0_values_nightly),
680 n0_values_nightly),
681 k0_values_nightly),
682 h0_values),
683 i_values_rhs),
684 t_values_rhs),
685 framework::dataset::make("export_to_cl_image_rhs", false)),
686 framework::dataset::make("DataType", DataType::F16)),
687 a_values),
688 beta_values),
689 act_values))
690{
691 // Validate output
692 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
693}
694
695TEST_SUITE_END() // FP16
696
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000697TEST_SUITE_END() // Float
698TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
699TEST_SUITE_END() // CL
700} // namespace validation
701} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100702} // namespace arm_compute