blob: 789b77377db6c7dc579c15ff3c85ae285c3dcaee [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 */
Gian Marco Iodice7026b302019-06-26 17:18:11 +010024#include "arm_compute/core/KernelDescriptors.h"
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000025#include "arm_compute/core/Types.h"
26#include "arm_compute/core/utils/misc/ShapeCalculator.h"
27#include "arm_compute/runtime/CL/CLTensor.h"
28#include "arm_compute/runtime/CL/CLTensorAllocator.h"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010029#include "src/core/CL/kernels/CLGEMMMatrixMultiplyReshapedOnlyRHSKernel.h"
30#include "src/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h"
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000031#include "tests/CL/CLAccessor.h"
32#include "tests/CL/Helper.h"
33#include "tests/PaddingCalculator.h"
34#include "tests/datasets/ShapeDatasets.h"
35#include "tests/framework/Asserts.h"
36#include "tests/framework/Macros.h"
37#include "tests/framework/datasets/Datasets.h"
38#include "tests/validation/Validation.h"
39#include "tests/validation/fixtures/GEMMFixture.h"
40
41namespace arm_compute
42{
43namespace test
44{
45namespace validation
46{
47using namespace arm_compute::misc::shape_calculator;
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 Iodice6f931342020-09-15 14:17:41 +010077const auto beta_values = framework::dataset::make("beta", {-0.35f} );
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 */
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +010095const auto b_values = framework::dataset::make("batch_size", 2);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +000096
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +010097/** Activation values to test */
98const auto act_values = framework::dataset::make("Activation",
99{
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100100 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, -0.8f, 10.f),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100101});
102
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100103/** M0 values to test - precommit */
104const auto m0_values_precommit = framework::dataset::make("M0", { 4 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000105
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100106/** N0 values to test - precommit*/
107const auto n0_values_precommit = framework::dataset::make("N0", { 4 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000108
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100109/** K0 values to test - precommit*/
110const auto k0_values_precommit = framework::dataset::make("K0", { 4 });
111
112/** M0 values to test - nightly */
113const auto m0_values_nightly = framework::dataset::make("M0", { 8 });
114
115/** N0 values to test - nightly */
116const auto n0_values_nightly = framework::dataset::make("N0", { 16 });
117
118/** K0 values to test - nightly */
119const auto k0_values_nightly = framework::dataset::make("K0", { 16 });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000120
Sheri Zhang1a378102020-04-30 12:59:39 +0100121/** H0 values to test */
122const auto h0_values = framework::dataset::make("H0", 1, 3);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000123
124/** Interleave values to test with RHS matrix */
125const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false });
126
127/** Transpose values to test with RHS matrix */
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000128const auto t_values_rhs = framework::dataset::make("transpose_rhs", { true, false });
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000129
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100130/** Broadcast bias from vector to matrix */
Gian Marco Iodiced820db62019-08-05 14:23:23 +0100131const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } );
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100132
SiCong Lib972ae62020-08-03 15:39:45 +0100133/** Boundary handling cases for testing partial/non-partial (full) block dimensions, resulting from different combinations
134 * of M, M0, N and N0 values.
135 * M0 and N0 are kept constant, while the different test cases need to vary M and N.
136 *
137 * Eg. M = 64 and N = 33 result in a block dimension that has no partial blocks (all full blocks) in Y dimension and
138 * parital blocks in X dimension.
139 */
140const auto boundary_handling_cases = combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
141 // Large k to force potential out-of-bound reads on input0
142 framework::dataset::make("K", 315),
143 // Batch size == 1 to force potential out-of-bound reads on input0
144 framework::dataset::make("batch_size", 1)),
145 framework::dataset::make("M0", 4)),
146 framework::dataset::make("N0", 4)),
147 framework::dataset::make("K0", 4)),
148 framework::dataset::make("H0", 3)),
149 i_values_rhs),
150 t_values_rhs),
151 framework::dataset::make("export_to_cl_image_rhs", {true, false})),
152 // Only need to test F32 as F16 shares identical boundary handling logics
153 framework::dataset::make("DataType", DataType::F32)),
154 framework::dataset::make("alpha", -0.75f )),
155 framework::dataset::make("beta", -0.35f )),
156 broadcast_bias_values),
157 framework::dataset::make("Activation", ActivationLayerInfo()));
158
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000159/** Configuration test */
Sheri Zhang1a378102020-04-30 12:59:39 +0100160bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value,
161 unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value,
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100162 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 +0100163 DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000164{
165 const unsigned int M = m_value;
166 const unsigned int N = n_value;
167 const unsigned int K = k_value;
168
169 GEMMLHSMatrixInfo lhs_info;
170 lhs_info.m0 = m0_value;
171 lhs_info.k0 = k0_value;
172
173 GEMMRHSMatrixInfo rhs_info;
174 rhs_info.n0 = n0_value;
175 rhs_info.k0 = k0_value;
176 rhs_info.h0 = h0_value;
177 rhs_info.interleave = i_value_rhs;
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000178 rhs_info.transpose = t_value_rhs;
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100179 rhs_info.export_to_cl_image = export_to_cl_image;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000180
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100181 GEMMKernelInfo kernel_info;
182 kernel_info.m = M;
183 kernel_info.n = N;
184 kernel_info.k = K;
Sheri Zhang1a378102020-04-30 12:59:39 +0100185 kernel_info.depth_output_gemm3d = depth_output_gemm3d;
186 kernel_info.reinterpret_input_as_3d = input_as_3d;
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100187 kernel_info.broadcast_bias = broadcast_bias;
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100188 kernel_info.activation_info = act_info;
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000189
190 const TensorShape lhs_shape(K, M, b_value);
191 const TensorShape rhs_shape(N, K, b_value);
Sheri Zhang1a378102020-04-30 12:59:39 +0100192 const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000193 rhs_info);
194
Sheri Zhang1a378102020-04-30 12:59:39 +0100195 const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0),
196 TensorInfo(rhs_shape_reshaped, 1, dt_input1),
Gian Marco Iodice7026b302019-06-26 17:18:11 +0100197 kernel_info);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000198
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100199 const TensorShape bias_shape(N,
Sheri Zhang1a378102020-04-30 12:59:39 +0100200 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 +0100201 broadcast_bias? 1 : b_value);
202
Sheri Zhang1a378102020-04-30 12:59:39 +0100203 // Create tensor info
204 TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0);
205 TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1);
206 TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2);
207 TensorInfo dst = TensorInfo(dst_shape, 1, dt_output);
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000208
209 // Create and configure function
210 CLGEMMMatrixMultiplyReshapedOnlyRHS gemm;
Sheri Zhang1a378102020-04-30 12:59:39 +0100211 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 +0000212}
213} // namespace
214
215TEST_SUITE(CL)
216TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS)
Sheri Zhang1a378102020-04-30 12:59:39 +0100217
218/** Validate tests
219 *
220 * A series of validation tests on configurations which according to the API specification
221 * the function should fail against.
222 *
223 * Checks performed in order:
224 * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16.
225 * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8
226 * - Unsupported N0: NO can only be 2,3,4,8,16
227 * - Unsupported K0: KO can only be 2,3,4,8,16
228 * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D
229 * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m)
230 * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100231 * - Correct support for creating an OpenCL image object from buffer
232 * - 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 +0100233 * - Correct F16 support for creating an OpenCL image object from buffer.
Sheri Zhang1a378102020-04-30 12:59:39 +0100234 */
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100235DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(
236framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }),
237framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })),
238framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })),
239framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })),
240framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })),
241framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })),
242framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })),
243framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })),
244framework::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})),
245framework::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})),
246framework::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})),
247framework::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})),
248framework::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 +0100249framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, true })),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100250b_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 +0100251{
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100252 bool expected_value = expected;
253
254 // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension
255 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image)
256 {
257 expected_value = false;
258 }
259
260 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);
261 ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS);
Sheri Zhang1a378102020-04-30 12:59:39 +0100262}
263
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000264TEST_SUITE(Float)
265TEST_SUITE(FP32)
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000266
SiCong Lib972ae62020-08-03 15:39:45 +0100267FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
268 combine(combine(
269 framework::dataset::make("M", 3),
270 framework::dataset::make("N", 1)),
271 boundary_handling_cases))
272{
273 // Validate output
274 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
275}
276
277FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
278 combine(combine(
279 framework::dataset::make("M", 64),
280 framework::dataset::make("N", 43)),
281 boundary_handling_cases))
282{
283 // Validate output
284 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
285}
286
287FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
288 combine(combine(
289 framework::dataset::make("M", 64),
290 framework::dataset::make("N", 32)),
291 boundary_handling_cases))
292{
293 // Validate output
294 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
295}
296
297FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
298 combine(combine(
299 framework::dataset::make("M", 37),
300 framework::dataset::make("N", 32)),
301 boundary_handling_cases))
302{
303 // Validate output
304 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
305}
306
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100307FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
308 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000309 m_values,
310 n_values),
311 k_values),
312 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100313 m0_values_precommit),
314 n0_values_precommit),
315 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100316 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000317 i_values_rhs),
318 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100319 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000320 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100321 a_values),
322 beta_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100323 broadcast_bias_values),
324 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000325{
326 // Validate output
327 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
328}
329
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100330FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
331 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
332 m_values,
333 n_values),
334 k_values),
335 b_values),
336 m0_values_nightly),
337 n0_values_nightly),
338 k0_values_nightly),
339 h0_values),
340 i_values_rhs),
341 t_values_rhs),
342 framework::dataset::make("export_to_cl_image_rhs", false)),
343 framework::dataset::make("DataType", DataType::F32)),
344 a_values),
345 beta_values),
346 broadcast_bias_values),
347 act_values))
348{
349 // Validate output
350 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
351}
352
353FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100354 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000355 m_w_values,
356 m_h_values),
357 n_values),
358 k_values),
359 b_values),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100360 m0_values_precommit),
361 n0_values_precommit),
362 k0_values_precommit),
Sheri Zhang1a378102020-04-30 12:59:39 +0100363 h0_values),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000364 i_values_rhs),
365 t_values_rhs),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100366 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100367 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000368 framework::dataset::make("DataType", DataType::F32)),
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100369 a_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100370 beta_values),
371 act_values))
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000372{
373 // Validate output
374 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
375}
376
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100377FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100378 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100379 m_w_values,
380 m_h_values),
381 n_values),
382 k_values),
383 b_values),
384 m0_values_nightly),
385 n0_values_nightly),
386 k0_values_nightly),
387 h0_values),
388 i_values_rhs),
389 t_values_rhs),
390 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100391 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100392 framework::dataset::make("DataType", DataType::F32)),
393 a_values),
394 beta_values),
395 act_values))
396{
397 // Validate output
398 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
399}
400
401TEST_SUITE(ExportToCLImage)
402FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT,
403 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
404 m_values,
405 n_values),
406 k_values),
407 b_values),
408 m0_values_precommit),
409 n0_values_precommit),
410 k0_values_precommit),
411 h0_values),
412 i_values_rhs),
413 t_values_rhs),
414 framework::dataset::make("export_to_cl_image_rhs", true)),
415 framework::dataset::make("DataType", DataType::F32)),
416 a_values),
417 beta_values),
418 broadcast_bias_values),
419 act_values))
420{
421 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
422 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
423 {
424 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
425 }
426 else
427 {
428 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
429 framework::ARM_COMPUTE_PRINT_INFO();
430 }
431}
432
433FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY,
434 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
435 m_values,
436 n_values),
437 k_values),
438 b_values),
439 m0_values_nightly),
440 n0_values_nightly),
441 k0_values_nightly),
442 h0_values),
443 i_values_rhs),
444 t_values_rhs),
445 framework::dataset::make("export_to_cl_image_rhs", true)),
446 framework::dataset::make("DataType", DataType::F32)),
447 a_values),
448 beta_values),
449 broadcast_bias_values),
450 act_values))
451{
452 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
453 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
454 {
455 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
456 }
457 else
458 {
459 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
460 framework::ARM_COMPUTE_PRINT_INFO();
461 }
462}
463
464FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100465 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100466 m_w_values,
467 m_h_values),
468 n_values),
469 k_values),
470 b_values),
471 m0_values_precommit),
472 n0_values_precommit),
473 k0_values_precommit),
474 h0_values),
475 i_values_rhs),
476 t_values_rhs),
477 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100478 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100479 framework::dataset::make("DataType", DataType::F32)),
480 a_values),
481 beta_values),
482 act_values))
483{
484 // Validate output
485 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
486}
487
488FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100489 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100490 m_w_values,
491 m_h_values),
492 n_values),
493 k_values),
494 b_values),
495 m0_values_nightly),
496 n0_values_nightly),
497 k0_values_nightly),
498 h0_values),
499 i_values_rhs),
500 t_values_rhs),
501 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100502 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100503 framework::dataset::make("DataType", DataType::F32)),
504 a_values),
505 beta_values),
506 act_values))
507{
508 // Validate output
509 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
510}
511TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000512TEST_SUITE_END() // FP32
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100513
514TEST_SUITE(FP16)
515FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
516 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
517 m_values,
518 n_values),
519 k_values),
520 b_values),
521 m0_values_precommit),
522 n0_values_precommit),
523 k0_values_precommit),
524 h0_values),
525 i_values_rhs),
526 t_values_rhs),
527 framework::dataset::make("export_to_cl_image_rhs", false)),
528 framework::dataset::make("DataType", DataType::F16)),
529 a_values),
530 beta_values),
531 broadcast_bias_values),
532 act_values))
533{
534 // Validate output
535 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
536}
537
538FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
539 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
540 m_values,
541 n_values),
542 k_values),
543 b_values),
544 m0_values_nightly),
545 n0_values_nightly),
546 k0_values_nightly),
547 h0_values),
548 i_values_rhs),
549 t_values_rhs),
550 framework::dataset::make("export_to_cl_image_rhs", false)),
551 framework::dataset::make("DataType", DataType::F16)),
552 a_values),
553 beta_values),
554 broadcast_bias_values),
555 act_values))
556{
557 // Validate output
558 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
559}
560
561FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100562 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100563 m_w_values,
564 m_h_values),
565 n_values),
566 k_values),
567 b_values),
568 m0_values_precommit),
569 n0_values_precommit),
570 k0_values_precommit),
571 h0_values),
572 i_values_rhs),
573 t_values_rhs),
574 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100575 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100576 framework::dataset::make("DataType", DataType::F16)),
577 a_values),
578 beta_values),
579 act_values))
580{
581 // Validate output
582 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
583}
584
585FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100586 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100587 m_w_values,
588 m_h_values),
589 n_values),
590 k_values),
591 b_values),
592 m0_values_nightly),
593 n0_values_nightly),
594 k0_values_nightly),
595 h0_values),
596 i_values_rhs),
597 t_values_rhs),
598 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100599 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100600 framework::dataset::make("DataType", DataType::F16)),
601 a_values),
602 beta_values),
603 act_values))
604{
605 // Validate output
606 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
607}
608
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100609TEST_SUITE(ExportToCLImage)
610FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT,
611 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
612 m_values,
613 n_values),
614 k_values),
615 b_values),
616 m0_values_precommit),
617 n0_values_precommit),
618 k0_values_precommit),
619 h0_values),
620 i_values_rhs),
621 t_values_rhs),
622 framework::dataset::make("export_to_cl_image_rhs", true)),
623 framework::dataset::make("DataType", DataType::F16)),
624 a_values),
625 beta_values),
626 broadcast_bias_values),
627 act_values))
628{
629 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
630 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
631 {
632 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
633 }
634 else
635 {
636 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
637 framework::ARM_COMPUTE_PRINT_INFO();
638 }
639}
640
641FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY,
642 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
643 m_values,
644 n_values),
645 k_values),
646 b_values),
647 m0_values_nightly),
648 n0_values_nightly),
649 k0_values_nightly),
650 h0_values),
651 i_values_rhs),
652 t_values_rhs),
653 framework::dataset::make("export_to_cl_image_rhs", true)),
654 framework::dataset::make("DataType", DataType::F16)),
655 a_values),
656 beta_values),
657 broadcast_bias_values),
658 act_values))
659{
660 // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension
661 if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
662 {
663 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
664 }
665 else
666 {
667 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
668 framework::ARM_COMPUTE_PRINT_INFO();
669 }
670}
671
672FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100673 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100674 m_w_values,
675 m_h_values),
676 n_values),
677 k_values),
678 b_values),
679 m0_values_precommit),
680 n0_values_precommit),
681 k0_values_precommit),
682 h0_values),
683 i_values_rhs),
684 t_values_rhs),
685 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100686 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100687 framework::dataset::make("DataType", DataType::F16)),
688 a_values),
689 beta_values),
690 act_values))
691{
692 // Validate output
693 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
694}
695
696FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100697 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100698 m_w_values,
699 m_h_values),
700 n_values),
701 k_values),
702 b_values),
703 m0_values_nightly),
704 n0_values_nightly),
705 k0_values_nightly),
706 h0_values),
707 i_values_rhs),
708 t_values_rhs),
709 framework::dataset::make("export_to_cl_image_rhs", true)),
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100710 framework::dataset::make("has_pad_y", {false, true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100711 framework::dataset::make("DataType", DataType::F16)),
712 a_values),
713 beta_values),
714 act_values))
715{
716 // Validate output
717 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
718}
719TEST_SUITE_END() // ExportToCLImage
720
Gian Marco Iodice781cba72020-06-19 16:56:57 +0100721TEST_SUITE_END() // FP16
722
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000723TEST_SUITE_END() // Float
724TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS
725TEST_SUITE_END() // CL
726} // namespace validation
727} // namespace test
Georgios Pinitasb0f342e2019-05-21 13:32:43 +0100728} // namespace arm_compute