blob: a598780bf68c8d59f24910bb844be4d314195811 [file] [log] [blame]
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +00001/*
Georgios Pinitas856f66e2021-04-22 21:13:21 +01002 * Copyright (c) 2018-2021 Arm Limited.
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +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 Iodicebf9731e2018-12-12 10:18:04 +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"
SiCongLi1af54162021-10-06 15:25:57 +010029#include "src/core/experimental/PostOp.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010030#include "src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.h"
31#include "src/gpu/cl/kernels/ClGemmReshapeLhsMatrixKernel.h"
32#include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h"
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +000033#include "tests/CL/CLAccessor.h"
34#include "tests/CL/Helper.h"
35#include "tests/PaddingCalculator.h"
36#include "tests/datasets/ShapeDatasets.h"
37#include "tests/framework/Asserts.h"
38#include "tests/framework/Macros.h"
39#include "tests/framework/datasets/Datasets.h"
40#include "tests/validation/Validation.h"
41#include "tests/validation/fixtures/GEMMFixture.h"
42
43namespace arm_compute
44{
45namespace test
46{
47namespace validation
48{
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000049using namespace arm_compute::misc::shape_calculator;
Georgios Pinitas856f66e2021-04-22 21:13:21 +010050using namespace arm_compute::opencl::kernels;
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000051
Georgios Pinitas856f66e2021-04-22 21:13:21 +010052// Create function for ClGemmReshapeLhsMatrixKernel
53using CLGEMMReshapeLHSMatrix = CLSynthetizeOperator<ClGemmReshapeLhsMatrixKernel>;
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000054
Georgios Pinitas856f66e2021-04-22 21:13:21 +010055// Create function for ClGemmReshapeRhsMatrixKernel
56using CLGEMMReshapeRHSMatrix = CLSynthetizeOperator<ClGemmReshapeRhsMatrixKernel>;
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000057
Georgios Pinitas856f66e2021-04-22 21:13:21 +010058// Create function for ClGemmMatrixMultiplyReshapedKernel
59using CLGEMMMatrixMultiplyReshaped = CLSynthetizeOperator<ClGemmMatrixMultiplyReshapedKernel>;
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000060
61// Fixture for CLGEMMMatrixMultiplyReshaped
62template <typename T>
63using CLGEMMMatrixMultiplyReshapedFixture = GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>;
64
SiCongLi1af54162021-10-06 15:25:57 +010065// Fixture for CLGEMMMatrixMultiplyReshaped with post ops
66template <typename T>
67using CLGEMMMatrixMultiplyReshapedWithPostOpsFixture =
68 GEMMMatrixMultiplyReshapedWithPostOpsValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>;
69
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +010070// Fixture for CLGEMMMatrixMultiplyReshaped mixed precision
71template <typename T>
72using CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture =
73 GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>;
74
SiCongLi1af54162021-10-06 15:25:57 +010075// Fixture for CLGEMMMatrixMultiplyReshaped mixed precision with post ops
76template <typename T>
77using CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture =
78 GEMMMatrixMultiplyReshapedWithPostOpsValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>;
79
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000080// Fixture for CLGEMMMatrixMultiplyReshaped3D
81template <typename T>
82using CLGEMMMatrixMultiplyReshaped3DFixture = GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>;
83
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +010084// Fixture for CLGEMMMatrixMultiplyReshaped3D mixed precision
85template <typename T>
86using CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture =
87 GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>;
88
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +000089namespace
90{
91// *INDENT-OFF*
92// clang-format off
Gian Marco Iodice9382ab32018-12-17 15:12:07 +000093RelativeTolerance<float> rel_tolerance_f32(0.001f);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +000094constexpr float abs_tolerance_f32(0.0001f);
95
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +010096RelativeTolerance<float> rel_tolerance_f16_mixed_precision(0.001f);
97constexpr float abs_tolerance_f16_mixed_precision(0.01f);
98
Gian Marco Iodice05639f62019-09-24 12:05:06 +010099RelativeTolerance<float> rel_tolerance_f16(0.001f);
100constexpr float abs_tolerance_f16(0.01f);
101
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000102/** M values to test */
morgolockaba2f912020-05-05 16:28:19 +0100103const auto m_values = framework::dataset::make("M", 17);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000104
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000105/** M_W values to test */
106const auto m_w_values = framework::dataset::make("M_W", 5);
107
108/** M_H values to test */
109const auto m_h_values = framework::dataset::make("M_H", 7);
110
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000111/** N values to test */
morgolockaba2f912020-05-05 16:28:19 +0100112const auto n_values = framework::dataset::make("N", 21);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000113
114/** K values to test */
morgolockaba2f912020-05-05 16:28:19 +0100115const auto k_values = framework::dataset::make("K", 13);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000116
117/** Batch size values to test */
morgolockaba2f912020-05-05 16:28:19 +0100118const auto b_values = framework::dataset::make("batch_size", 2, 3);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000119
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100120/** Activation values to test */
121const auto act_values = framework::dataset::make("Activation",
122{
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100123 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f),
124});
125
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100126/** Alpha values to test - Precommit */
127const auto a_values_precommit = framework::dataset::make("alpha", {-0.75f} );
128
129/** Beta values to test - Precommit */
130const auto beta_values_precommit = framework::dataset::make("beta", {-0.35f} );
131
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000132/** M0 values to test - Precommit */
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100133const auto m0_values_precommit = framework::dataset::make("M0", { 4 });
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000134
135/** N0 values to test - Precommit */
Gian Marco Iodiced820db62019-08-05 14:23:23 +0100136const auto n0_values_precommit = framework::dataset::make("N0", { 4 });
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000137
138/** K0 values to test - Precommit */
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000139const auto k0_values_precommit = framework::dataset::make("K0", { 4 });
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000140
141/** V0 values to test - Precommit */
142const auto v0_values_precommit = framework::dataset::make("V0", 1, 3);
143
144/** H0 values to test - Precommit */
145const auto h0_values_precommit = framework::dataset::make("H0", 1, 3);
146
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100147/** Alpha values to test - Nightly */
148const auto a_values_nightly = framework::dataset::make("alpha", {1.0f} );
149
150/** Beta values to test - Nightly */
151const auto beta_values_nightly = framework::dataset::make("beta", {1.0f} );
152
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000153/** M0 values to test - Nightly */
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100154const auto m0_values_nightly = framework::dataset::make("M0", { 8 });
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000155
156/** N0 values to test - Nightly */
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100157const auto n0_values_nightly = framework::dataset::make("N0", { 8 });
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000158
159/** K0 values to test - Nightly */
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100160const auto k0_values_nightly = framework::dataset::make("K0", { 4 });
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000161
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100162/** N0 values to test with export to OpenCL image object - Nightly */
163const auto n0_export_to_cl_image_values_nightly = framework::dataset::make("N0", { 4, 8, 16 });
164
165/** K0 values to test with export to OpenCL image object - Nightly */
166const auto k0_export_to_cl_image_values_nightly = framework::dataset::make("K0", { 4, 8, 16 });
167
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000168/** V0 values to test - Nightly */
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100169const auto v0_values_nightly = framework::dataset::make("V0", 1, 3);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000170
171/** H0 values to test - Nightly */
Gian Marco Iodice6f931342020-09-15 14:17:41 +0100172const auto h0_values_nightly = framework::dataset::make("H0", 1, 3);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000173
174/** Interleave values to test with LHS matrix */
175const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false });
176
177/** Interleave values to test with RHS matrix */
178const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false });
179
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100180/** Broadcast bias from vector to matrix */
Gian Marco Iodiced820db62019-08-05 14:23:23 +0100181const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } );
Gian Marco Iodicee16c8902019-06-14 16:11:10 +0100182
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100183/** LHS transposed values */
184const auto lhs_transpose_values = framework::dataset::make("lhs_transpose", { false, true } );
Gian Marco Iodice088d63a2020-08-11 14:14:06 +0100185
SiCongLi1af54162021-10-06 15:25:57 +0100186/** Post Ops */
187using PostOpArgBroadcast = CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>::PostOpArgBroadcast;
SiCongLi1af54162021-10-06 15:25:57 +0100188experimental::PostOpList<PostOpArgBroadcast> post_ops_1()
189{
190 experimental::PostOpList<PostOpArgBroadcast> post_ops{};
191 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F});
192 post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>(
193 std::make_tuple(true, true, false), // If broadcast in dims 0, 1 and 2
194 0,
195 ConvertPolicy::SATURATE);
196 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F});
197 return post_ops;
198}
199experimental::PostOpList<PostOpArgBroadcast> post_ops_2()
200{
201 experimental::PostOpList<PostOpArgBroadcast> post_ops{};
202 post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>(
203 std::make_tuple(false, true, true), // If broadcast in dims 0, 1 and 2
204 1,
205 ConvertPolicy::SATURATE);
206 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F});
207 return post_ops;
208}
209experimental::PostOpList<PostOpArgBroadcast> post_ops_3()
210{
211 experimental::PostOpList<PostOpArgBroadcast> post_ops{};
212 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F});
213 post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>(
214 std::make_tuple(false, false, true), // If broadcast in dims 0, 1 and 2
215 1,
216 ConvertPolicy::SATURATE);
217 return post_ops;
218}
SiCongLi1af54162021-10-06 15:25:57 +0100219/** Different Post Op Lists */
220const auto post_op_lists = framework::dataset::make("post_op_lists", {
221 post_ops_1(),
222 post_ops_2(),
223 post_ops_3(),
224 } );
225
SiCongLieb8bd812021-10-29 15:05:49 +0100226bool is_post_op_list_valid(unsigned int m, unsigned int n, unsigned int k, unsigned int batch, DataType data_type, const experimental::PostOpList<ITensorInfo*>& post_ops)
227{
228 const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true);
229 const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false);
230
231 // Create TensorInfo for post op arguments
232 TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type);
233 TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type);
234 TensorInfo input2_info(TensorShape(n), 1, data_type);
235 TensorInfo output_info(TensorShape(n, m, batch), 1, data_type);
236
237 const TensorInfo reshaped_input0_info = input0_info.clone()->set_tensor_shape(misc::shape_calculator::compute_lhs_reshaped_shape(input0_info, lhs_info));
238 const TensorInfo reshaped_input1_info = input1_info.clone()->set_tensor_shape(misc::shape_calculator::compute_rhs_reshaped_shape(input1_info, rhs_info));
239
240 GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
241 false /**< reinterpret the input as 3D */,
242 true /**< Flag used to broadcast the bias addition */,
243 false /**< wider accumm */,
244 false /**< has pad y */,
245 ActivationLayerInfo::ActivationFunction::IDENTITY,
246 1 /**< Multiplication factor for the width of the 1xW transposed block */,
247 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
248 lhs_info,
249 rhs_info,
250 0 /**< Offset to be added to each element of the matrix A */,
251 0 /**< Offset to be added to each element of the matrix B */,
252 post_ops);
253 return bool(ClGemmMatrixMultiplyReshapedKernel::validate(&reshaped_input0_info.clone()->set_is_resizable(true),
254 &reshaped_input1_info.clone()->set_is_resizable(true),
255 &input2_info.clone()->set_is_resizable(true),
256 &output_info.clone()->set_is_resizable(true),1.f,1.f,
257 lhs_info,
258 rhs_info,
259 gemm_info));
260}
261
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000262} // namespace
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000263
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000264TEST_SUITE(CL)
265TEST_SUITE(GEMMMatrixMultiplyReshaped)
morgolockaba2f912020-05-05 16:28:19 +0100266
267// *INDENT-OFF*
268// clang-format off
269DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
270 framework::dataset::make("Input0Info", { TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // OK
271 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK
272 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), // Data type not supported
273 TensorInfo(TensorShape(10U, 5U, 2U), 1, DataType::F32), // Incorrect dimension bias
274 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // Mismatching shapes
275 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, do not broadcast bias
276 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, wider accummulation
277 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, RHS 4,4,2
278
279 }),
280 framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32),
281 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16),
282 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8),
283 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32),
284 TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
285 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16),
286 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16),
287 TensorInfo(TensorShape(128U, 3U, 2U), 1, DataType::F16),
288
289 })),
290 framework::dataset::make("Input2Info", { TensorInfo(TensorShape(21U), 1, DataType::F32),
291 TensorInfo(TensorShape(21U), 1, DataType::F16),
292 TensorInfo(TensorShape(21U), 1, DataType::QASYMM8),
293 TensorInfo(TensorShape(21U), 1, DataType::F32),
294 TensorInfo(TensorShape(21U), 1, DataType::F32),
295 TensorInfo(TensorShape(21U,17U), 1, DataType::F16),
296 TensorInfo(TensorShape(21U,17U), 1, DataType::F16),
297 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
298
299 })),
300 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32),
301 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
302 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::QASYMM8),
303 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32),
304 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32),
305 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
306 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
307 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
308
309 })),
310 framework::dataset::make("LHSMInfo",{
311 GEMMLHSMatrixInfo(4,4,1,false,true),
312 GEMMLHSMatrixInfo(4,4,1,false,true),
313 GEMMLHSMatrixInfo(4,4,1,false,true),
314 GEMMLHSMatrixInfo(4,2,4,false,false),
315 GEMMLHSMatrixInfo(4,2,4,false,false),
316 GEMMLHSMatrixInfo(4,4,1,false,true),
317 GEMMLHSMatrixInfo(4,4,1,false,true),
318 GEMMLHSMatrixInfo(4,4,1,false,true),
319
320 })),
321 framework::dataset::make("RHSMInfo",{
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100322 GEMMRHSMatrixInfo(4,4,1,true,true,false),
323 GEMMRHSMatrixInfo(4,4,1,true,true,false),
324 GEMMRHSMatrixInfo(4,4,1,true,true,false),
325 GEMMRHSMatrixInfo(2,2,1,true,false,false),
326 GEMMRHSMatrixInfo(2,2,1,true,false,false),
327 GEMMRHSMatrixInfo(4,4,1,true,true,false),
328 GEMMRHSMatrixInfo(4,4,1,true,true,false),
329 GEMMRHSMatrixInfo(4,4,2,true,false,false),
morgolockaba2f912020-05-05 16:28:19 +0100330
331
332 })),
333
334
335 framework::dataset::make("GEMMInfo",{
336 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
337 21 /**<N Number of RHS columns*/,
338 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
339 false /**< reinterpret the input as 3D */,
340 true /**< Flag used to broadcast the bias addition */,
341 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100342 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100343 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
344 1 /**< Multiplication factor for the width of the 1xW transposed block */,
345 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
346 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100347 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100348 0 /**< Offset to be added to each element of the matrix A */,
349 0 /**< Offset to be added to each element of the matrix B */),
350
351 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
352 21 /**<N Number of RHS columns*/,
353 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
354 false /**< reinterpret the input as 3D */,
355 true /**< Flag used to broadcast the bias addition */,
356 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100357 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100358 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
359 1 /**< Multiplication factor for the width of the 1xW transposed block */,
360 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
361 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100362 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100363 0 /**< Offset to be added to each element of the matrix A */,
364 0 /**< Offset to be added to each element of the matrix B */),
365 GEMMKernelInfo(),
366 GEMMKernelInfo(),
367 GEMMKernelInfo(),
368
369 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
370 21 /**<N Number of RHS columns*/,
371 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
372 false /**< reinterpret the input as 3D */,
373 false /**< Flag used to broadcast the bias addition */,
374 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100375 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100376 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
377 1 /**< Multiplication factor for the width of the 1xW transposed block */,
378 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
379 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100380 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100381 0 /**< Offset to be added to each element of the matrix A */,
382 0 /**< Offset to be added to each element of the matrix B */),
383
384
385 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
386 21 /**<N Number of RHS columns*/,
387 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
388 false /**< reinterpret the input as 3D */,
389 false /**< Flag used to broadcast the bias addition */,
390 true /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100391 true /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100392 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
393 1 /**< Multiplication factor for the width of the 1xW transposed block */,
394 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
395 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100396 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100397 0 /**< Offset to be added to each element of the matrix A */,
398 0 /**< Offset to be added to each element of the matrix B */),
399
400 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
401 21 /**<N Number of RHS columns*/,
402 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
403 false /**< reinterpret the input as 3D */,
404 false /**< Flag used to broadcast the bias addition */,
405 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100406 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100407 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
408 1 /**< Multiplication factor for the width of the 1xW transposed block */,
409 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
410 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100411 GEMMRHSMatrixInfo(4,4,2,true,false,false),
morgolockaba2f912020-05-05 16:28:19 +0100412 0 /**< Offset to be added to each element of the matrix A */,
413 0 /**< Offset to be added to each element of the matrix B */),
414 })),
415 framework::dataset::make("Expected", { true, true, false, false, false, true, true,true})),
416 input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected)
417{
SiCongLi1af54162021-10-06 15:25:57 +0100418 ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true),
morgolockaba2f912020-05-05 16:28:19 +0100419 &input1_info.clone()->set_is_resizable(true),
420 &input2_info.clone()->set_is_resizable(true),
421 &output_info.clone()->set_is_resizable(true),1.f,1.f,
422 lhs_info,
423 rhs_info,
424 gemm_info)) == expected, framework::LogLevel::ERRORS);
425}
SiCongLieb8bd812021-10-29 15:05:49 +0100426TEST_SUITE(ValidateFusedPostOpsConfigs)
427TEST_SUITE(Invalid)
428TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL)
SiCongLi1af54162021-10-06 15:25:57 +0100429{
SiCongLieb8bd812021-10-29 15:05:49 +0100430 const auto data_type = DataType::F32;
431 const unsigned int m = 17;
432 const unsigned int n = 1;
433 const unsigned int k = 13;
434 const unsigned int batch = 2;
435 TensorShape post_op_arg0_shape(n, m, batch);
436 TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type);
437 auto post_op_arg1_info = post_op_arg_info.clone();
438
439 // Unsupported sequence of post ops
440 experimental::PostOpList<ITensorInfo*> post_ops{};
441 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>(
442 &post_op_arg_info,
443 1,
444 ConvertPolicy::SATURATE);
445 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>(
446 post_op_arg1_info.get(),
447 0,
448 ConvertPolicy::SATURATE);
449
450 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS);
SiCongLi1af54162021-10-06 15:25:57 +0100451}
SiCongLieb8bd812021-10-29 15:05:49 +0100452TEST_CASE(OutputWidened, framework::DatasetMode::ALL)
453{
454 // Invalid broadcast: post op tensors "widen" the output tensor
455 const auto data_type = DataType::F32;
456 const unsigned int m = 17;
457 const unsigned int n = 1;
458 const unsigned int k = 13;
459 const unsigned int batch = 2;
460 TensorShape post_op_arg_shape(n + 4, m, batch); // output's X dimension (n) is "widened", which is not allowed
461 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
462 experimental::PostOpList<ITensorInfo*> post_ops{};
463 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
464
465 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS);
466}
467TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL)
468{
469 // Invalid broadcast: post op tensors broadcast in the first dimension (X) only
470 const auto data_type = DataType::F32;
471 const unsigned int m = 22;
472 const unsigned int n = 16;
473 const unsigned int k = 15;
474 const unsigned int batch = 3;
475 TensorShape post_op_arg_shape(1, m, batch);
476 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
477 experimental::PostOpList<ITensorInfo*> post_ops{};
478 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
479
480 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS);
481}
482TEST_SUITE_END() // Invalid
483TEST_SUITE(Valid)
484TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL)
485{
486 const auto data_type = DataType::F32;
487 const unsigned int m = 22;
488 const unsigned int n = 16;
489 const unsigned int k = 15;
490 const unsigned int batch = 3;
491 experimental::PostOpList<ITensorInfo*> post_ops{};
492
493 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
494}
495TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL)
496{
497 const auto data_type = DataType::F32;
498 const unsigned int m = 22;
499 const unsigned int n = 16;
500 const unsigned int k = 15;
501 const unsigned int batch = 3;
502 TensorShape post_op_arg_shape(n, 1, batch);
503 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
504 experimental::PostOpList<ITensorInfo*> post_ops{};
505 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
506
507 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
508}
509TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL)
510{
511 const auto data_type = DataType::F32;
512 const unsigned int m = 22;
513 const unsigned int n = 16;
514 const unsigned int k = 15;
515 const unsigned int batch = 3;
516 TensorShape post_op_arg_shape(1, 1, batch);
517 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
518 experimental::PostOpList<ITensorInfo*> post_ops{};
519 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
520
521 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
522}
523TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL)
524{
525 const auto data_type = DataType::F32;
526 const unsigned int m = 22;
527 const unsigned int n = 16;
528 const unsigned int k = 15;
529 const unsigned int batch = 3;
530 TensorShape post_op_arg_shape(1, 1, 1);
531 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
532 experimental::PostOpList<ITensorInfo*> post_ops{};
533 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
534
535 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
536}
537TEST_SUITE_END() // Valid
538TEST_SUITE_END() // ValidateFusedPostOps
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000539TEST_SUITE(Float)
540TEST_SUITE(FP32)
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000541
542FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100543 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000544 m_values,
545 n_values),
546 k_values),
547 b_values),
548 m0_values_precommit),
549 n0_values_precommit),
550 k0_values_precommit),
551 v0_values_precommit),
552 h0_values_precommit),
553 i_values_lhs),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000554 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100555 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000556 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100557 a_values_precommit),
558 beta_values_precommit),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100559 broadcast_bias_values),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100560 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100561 act_values))
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000562{
563 // Validate output
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000564 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000565}
566
Michalis Spyrou1d897772019-12-09 18:47:29 +0000567FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100568 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000569 m_values,
570 n_values),
571 k_values),
572 b_values),
573 m0_values_nightly),
574 n0_values_nightly),
575 k0_values_nightly),
576 v0_values_nightly),
577 h0_values_nightly),
578 i_values_lhs),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000579 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100580 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000581 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100582 a_values_nightly),
583 beta_values_nightly),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100584 broadcast_bias_values),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100585 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100586 act_values))
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000587{
588 // Validate output
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000589 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000590}
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000591
592FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100593 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000594 m_w_values,
595 m_h_values),
596 n_values),
597 k_values),
598 b_values),
599 m0_values_precommit),
600 n0_values_precommit),
601 k0_values_precommit),
602 v0_values_precommit),
603 h0_values_precommit),
604 i_values_lhs),
605 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100606 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000607 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100608 a_values_precommit),
609 beta_values_precommit),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100610 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100611 act_values))
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000612{
613 // Validate output
614 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
615}
616
Michalis Spyrou1d897772019-12-09 18:47:29 +0000617FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100618 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000619 m_w_values,
620 m_h_values),
621 n_values),
622 k_values),
623 b_values),
624 m0_values_nightly),
625 n0_values_nightly),
626 k0_values_nightly),
627 v0_values_nightly),
628 h0_values_nightly),
629 i_values_lhs),
630 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100631 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000632 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100633 a_values_nightly),
634 beta_values_nightly),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100635 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100636 act_values))
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000637{
638 // Validate output
639 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
640}
SiCongLi1af54162021-10-06 15:25:57 +0100641TEST_SUITE(FusedPostOps)
642
643FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>, framework::DatasetMode::ALL,
644 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
645 m_values,
646 n_values),
647 k_values),
648 b_values),
649 m0_values_precommit),
650 n0_values_precommit),
651 k0_values_precommit),
652 v0_values_precommit),
653 h0_values_precommit),
654 framework::dataset::make("interleave_lhs", { false })),
655 framework::dataset::make("interleave_rhs", { false })),
656 framework::dataset::make("export_to_cl_image_rhs", false)),
657 framework::dataset::make("DataType", DataType::F32)),
658 a_values_precommit),
659 beta_values_precommit),
660 framework::dataset::make("broadcast_bias", { true } )),
661 lhs_transpose_values),
662 act_values),
663 post_op_lists)
664 )
665{
666 // Validate output
667 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
668}
669
670TEST_SUITE_END() // FusedPostOps
671
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100672TEST_SUITE(ExportToCLImage)
673DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
674 framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported
675 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported
676 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported
677 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect k0
678 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect n0
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100679
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100680 }),
681 framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32),
682 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32),
683 TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F32),
684 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32),
685 TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F32),
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100686
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100687 })),
688 framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F32),
689 TensorInfo(TensorShape(64U), 1, DataType::F32),
690 TensorInfo(TensorShape(64U), 1, DataType::F32),
691 TensorInfo(TensorShape(64U), 1, DataType::F32),
692 TensorInfo(TensorShape(64U), 1, DataType::F32),
693
694 })),
695 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
696 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
697 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
698 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
699 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
700 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
701
702 })),
703 framework::dataset::make("LHSMInfo",{
704 GEMMLHSMatrixInfo(4, 4, 1, false, true),
705 GEMMLHSMatrixInfo(4, 8, 1, false, true),
706 GEMMLHSMatrixInfo(4, 4, 1, false, true),
707 GEMMLHSMatrixInfo(4, 2, 1, false, false),
708 GEMMLHSMatrixInfo(4, 4, 1, false, false),
709
710 })),
711 framework::dataset::make("RHSMInfo",{
712 GEMMRHSMatrixInfo(4, 4, 1, true, true, true),
713 GEMMRHSMatrixInfo(4, 8, 1, true, true, true),
714 GEMMRHSMatrixInfo(8, 4, 1, true, true, true),
715 GEMMRHSMatrixInfo(4, 2, 1, true, false, true),
716 GEMMRHSMatrixInfo(2, 4, 1, true, false, true),
717 })),
718 framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
719 64 /**<N Number of RHS columns*/,
720 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
721 false /**< reinterpret the input as 3D */,
722 true /**< Flag used to broadcast the bias addition */,
723 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100724 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100725 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
726 1 /**< Multiplication factor for the width of the 1xW transposed block */,
727 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
728 GEMMLHSMatrixInfo(),
729 GEMMRHSMatrixInfo(),
730 0 /**< Offset to be added to each element of the matrix A */,
731 0 /**< Offset to be added to each element of the matrix B */),
732 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
733 64 /**<N Number of RHS columns*/,
734 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
735 false /**< reinterpret the input as 3D */,
736 true /**< Flag used to broadcast the bias addition */,
737 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100738 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100739 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
740 1 /**< Multiplication factor for the width of the 1xW transposed block */,
741 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
742 GEMMLHSMatrixInfo(),
743 GEMMRHSMatrixInfo(),
744 0 /**< Offset to be added to each element of the matrix A */,
745 0 /**< Offset to be added to each element of the matrix B */),
746 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
747 64 /**<N Number of RHS columns*/,
748 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
749 false /**< reinterpret the input as 3D */,
750 true /**< Flag used to broadcast the bias addition */,
751 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100752 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100753 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
754 1 /**< Multiplication factor for the width of the 1xW transposed block */,
755 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
756 GEMMLHSMatrixInfo(),
757 GEMMRHSMatrixInfo(),
758 0 /**< Offset to be added to each element of the matrix A */,
759 0 /**< Offset to be added to each element of the matrix B */),
760
761 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
762 64 /**<N Number of RHS columns*/,
763 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
764 false /**< reinterpret the input as 3D */,
765 true /**< Flag used to broadcast the bias addition */,
766 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100767 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100768 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
769 1 /**< Multiplication factor for the width of the 1xW transposed block */,
770 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
771 GEMMLHSMatrixInfo(),
772 GEMMRHSMatrixInfo(),
773 0 /**< Offset to be added to each element of the matrix A */,
774 0 /**< Offset to be added to each element of the matrix B */),
775 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
776 64 /**<N Number of RHS columns*/,
777 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
778 false /**< reinterpret the input as 3D */,
779 true /**< Flag used to broadcast the bias addition */,
780 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100781 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100782 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
783 1 /**< Multiplication factor for the width of the 1xW transposed block */,
784 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
785 GEMMLHSMatrixInfo(),
786 GEMMRHSMatrixInfo(),
787 0 /**< Offset to be added to each element of the matrix A */,
788 0 /**< Offset to be added to each element of the matrix B */)
789 })),
790 framework::dataset::make("Expected", { true,
791 true,
792 true,
793 false,
794 false})),
795 input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected)
796{
Georgios Pinitas856f66e2021-04-22 21:13:21 +0100797 ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100798 &input1_info.clone()->set_is_resizable(true),
799 &input2_info.clone()->set_is_resizable(true),
800 &output_info.clone()->set_is_resizable(true),1.f,1.f,
801 lhs_info,
802 rhs_info,
803 gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS);
804}
805
806FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL,
807 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100808 m_values,
809 n_values),
810 k_values),
811 b_values),
812 m0_values_precommit),
813 n0_values_precommit),
814 k0_values_precommit),
815 v0_values_precommit),
816 h0_values_precommit),
817 i_values_lhs),
818 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100819 framework::dataset::make("export_to_cl_image_rhs", true)),
820 framework::dataset::make("DataType", DataType::F32)),
821 a_values_precommit),
822 beta_values_precommit),
823 broadcast_bias_values),
824 lhs_transpose_values),
825 act_values))
826{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000827 // Validate output only if validate() is successful
828 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100829 {
830 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
831 }
832 else
833 {
834 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
835 framework::ARM_COMPUTE_PRINT_INFO();
836 }
837
838}
839
840FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::NIGHTLY,
841 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
842 m_values,
843 n_values),
844 k_values),
845 b_values),
846 m0_values_nightly),
847 n0_export_to_cl_image_values_nightly),
848 k0_export_to_cl_image_values_nightly),
849 v0_values_nightly),
850 h0_values_nightly),
851 i_values_lhs),
852 i_values_rhs),
853 framework::dataset::make("export_to_cl_image_rhs", true)),
854 framework::dataset::make("DataType", DataType::F32)),
855 a_values_nightly),
856 beta_values_nightly),
857 broadcast_bias_values),
858 lhs_transpose_values),
859 act_values))
860{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000861 // Validate output only if validate() is successful
862 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100863 {
864 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
865 }
866 else
867 {
868 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
869 framework::ARM_COMPUTE_PRINT_INFO();
870 }
871}
872
873FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL,
874 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
875 m_w_values,
876 m_h_values),
877 n_values),
878 k_values),
879 b_values),
880 m0_values_precommit),
881 n0_values_precommit),
882 k0_values_precommit),
883 v0_values_precommit),
884 h0_values_precommit),
885 i_values_lhs),
886 i_values_rhs),
887 framework::dataset::make("export_to_cl_image_rhs", true)),
888 framework::dataset::make("DataType", DataType::F32)),
889 a_values_precommit),
890 beta_values_precommit),
891 lhs_transpose_values),
892 act_values))
893{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000894 // Validate output only if validate() is successful
895 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100896 {
897 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
898 }
899 else
900 {
901 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
902 framework::ARM_COMPUTE_PRINT_INFO();
903 }
904}
905
906FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::NIGHTLY,
907 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
908 m_w_values,
909 m_h_values),
910 n_values),
911 k_values),
912 b_values),
913 m0_values_nightly),
914 n0_export_to_cl_image_values_nightly),
915 k0_export_to_cl_image_values_nightly),
916 v0_values_nightly),
917 h0_values_nightly),
918 i_values_lhs),
919 i_values_rhs),
920 framework::dataset::make("export_to_cl_image_rhs", true)),
921 framework::dataset::make("DataType", DataType::F32)),
922 a_values_nightly),
923 beta_values_nightly),
924 lhs_transpose_values),
925 act_values))
926{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000927 // Validate output only if validate() is successful
928 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100929 {
930 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
931 }
932 else
933 {
934 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
935 framework::ARM_COMPUTE_PRINT_INFO();
936 }
937}
SiCongLi1af54162021-10-06 15:25:57 +0100938TEST_SUITE(FusedPostOps)
939
940FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>, framework::DatasetMode::ALL,
941 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
942 m_values,
943 n_values),
944 k_values),
945 b_values),
946 m0_values_precommit),
947 n0_values_precommit),
948 k0_values_precommit),
949 v0_values_precommit),
950 h0_values_precommit),
951 framework::dataset::make("interleave_lhs", { false })),
952 framework::dataset::make("interleave_rhs", { false })),
953 framework::dataset::make("export_to_cl_image_rhs", true)),
954 framework::dataset::make("DataType", DataType::F32)),
955 a_values_precommit),
956 beta_values_precommit),
957 framework::dataset::make("broadcast_bias", { true } )),
958 lhs_transpose_values),
959 act_values),
960 post_op_lists)
961 )
962{
963 // Validate output only if validate() is successful
964 if(validate_result)
965 {
966 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
967 }
968 else
969 {
970 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
971 framework::ARM_COMPUTE_PRINT_INFO();
972 }
973}
974
975TEST_SUITE_END() // FusedPostOps
976
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100977TEST_SUITE_END() // ExportToCLImage
978TEST_SUITE_END() // FP32
979
980TEST_SUITE(FP16)
981
982FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL,
983 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
984 m_values,
985 n_values),
986 k_values),
987 b_values),
988 m0_values_precommit),
989 n0_values_precommit),
990 k0_values_precommit),
991 v0_values_precommit),
992 h0_values_precommit),
993 i_values_lhs),
994 i_values_rhs),
995 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100996 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100997 a_values_precommit),
998 beta_values_precommit),
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100999 broadcast_bias_values),
1000 lhs_transpose_values),
1001 act_values))
1002{
1003 // Validate output
1004 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1005}
1006
Michalis Spyrou1d897772019-12-09 18:47:29 +00001007FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001008 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001009 m_values,
1010 n_values),
1011 k_values),
1012 b_values),
1013 m0_values_nightly),
1014 n0_values_nightly),
1015 k0_values_nightly),
1016 v0_values_nightly),
1017 h0_values_nightly),
1018 i_values_lhs),
1019 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001020 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001021 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001022 a_values_nightly),
1023 beta_values_nightly),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001024 broadcast_bias_values),
1025 lhs_transpose_values),
1026 act_values))
1027{
1028 // Validate output
1029 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1030}
1031
1032FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001033 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001034 m_w_values,
1035 m_h_values),
1036 n_values),
1037 k_values),
1038 b_values),
1039 m0_values_precommit),
1040 n0_values_precommit),
1041 k0_values_precommit),
1042 v0_values_precommit),
1043 h0_values_precommit),
1044 i_values_lhs),
1045 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001046 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001047 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001048 a_values_precommit),
1049 beta_values_precommit),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001050 lhs_transpose_values),
1051 act_values))
1052{
1053 // Validate output
1054 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1055}
1056
Michalis Spyrou1d897772019-12-09 18:47:29 +00001057FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001058 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001059 m_w_values,
1060 m_h_values),
1061 n_values),
1062 k_values),
1063 b_values),
1064 m0_values_nightly),
1065 n0_values_nightly),
1066 k0_values_nightly),
1067 v0_values_nightly),
1068 h0_values_nightly),
1069 i_values_lhs),
1070 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001071 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001072 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001073 a_values_nightly),
1074 beta_values_nightly),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001075 lhs_transpose_values),
1076 act_values))
1077{
1078 // Validate output
1079 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1080}
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001081
SiCongLi1af54162021-10-06 15:25:57 +01001082TEST_SUITE(FusedPostOps)
1083
1084FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<half>, framework::DatasetMode::ALL,
1085 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1086 m_values,
1087 n_values),
1088 k_values),
1089 b_values),
1090 m0_values_precommit),
1091 n0_values_precommit),
1092 k0_values_precommit),
1093 v0_values_precommit),
1094 h0_values_precommit),
1095 framework::dataset::make("interleave_lhs", { false })),
1096 framework::dataset::make("interleave_rhs", { false })),
1097 framework::dataset::make("export_to_cl_image_rhs", false)),
1098 framework::dataset::make("DataType", DataType::F16)),
1099 a_values_precommit),
1100 beta_values_precommit),
1101 framework::dataset::make("broadcast_bias", { true } )),
1102 lhs_transpose_values),
1103 act_values),
1104 post_op_lists)
1105 )
1106{
1107 // Validate output
1108 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1109}
1110
1111TEST_SUITE_END() // FusedPostOps
1112
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001113TEST_SUITE(ExportToCLImage)
1114DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
1115 framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported
1116 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported
1117 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported
1118 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect k0
1119 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect n0
1120
1121 }),
1122 framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16),
1123 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16),
1124 TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F16),
1125 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16),
1126 TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F16),
1127
1128 })),
1129 framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F16),
1130 TensorInfo(TensorShape(64U), 1, DataType::F16),
1131 TensorInfo(TensorShape(64U), 1, DataType::F16),
1132 TensorInfo(TensorShape(64U), 1, DataType::F16),
1133 TensorInfo(TensorShape(64U), 1, DataType::F16),
1134
1135 })),
1136 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1137 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1138 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1139 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1140 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1141 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1142
1143 })),
1144 framework::dataset::make("LHSMInfo",{
1145 GEMMLHSMatrixInfo(4, 4, 1, false, true),
1146 GEMMLHSMatrixInfo(4, 8, 1, false, true),
1147 GEMMLHSMatrixInfo(4, 4, 1, false, true),
1148 GEMMLHSMatrixInfo(4, 2, 1, false, false),
1149 GEMMLHSMatrixInfo(4, 4, 1, false, false),
1150
1151 })),
1152 framework::dataset::make("RHSMInfo",{
1153 GEMMRHSMatrixInfo(4, 4, 1, true, true, true),
1154 GEMMRHSMatrixInfo(4, 8, 1, true, true, true),
1155 GEMMRHSMatrixInfo(8, 4, 1, true, true, true),
1156 GEMMRHSMatrixInfo(4, 2, 1, true, false, true),
1157 GEMMRHSMatrixInfo(2, 4, 1, true, false, true),
1158 })),
1159 framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1160 64 /**<N Number of RHS columns*/,
1161 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1162 false /**< reinterpret the input as 3D */,
1163 true /**< Flag used to broadcast the bias addition */,
1164 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001165 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001166 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1167 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1168 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1169 GEMMLHSMatrixInfo(),
1170 GEMMRHSMatrixInfo(),
1171 0 /**< Offset to be added to each element of the matrix A */,
1172 0 /**< Offset to be added to each element of the matrix B */),
1173 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1174 64 /**<N Number of RHS columns*/,
1175 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1176 false /**< reinterpret the input as 3D */,
1177 true /**< Flag used to broadcast the bias addition */,
1178 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001179 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001180 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1181 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1182 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1183 GEMMLHSMatrixInfo(),
1184 GEMMRHSMatrixInfo(),
1185 0 /**< Offset to be added to each element of the matrix A */,
1186 0 /**< Offset to be added to each element of the matrix B */),
1187 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1188 64 /**<N Number of RHS columns*/,
1189 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1190 false /**< reinterpret the input as 3D */,
1191 true /**< Flag used to broadcast the bias addition */,
1192 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001193 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001194 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1195 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1196 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1197 GEMMLHSMatrixInfo(),
1198 GEMMRHSMatrixInfo(),
1199 0 /**< Offset to be added to each element of the matrix A */,
1200 0 /**< Offset to be added to each element of the matrix B */),
1201
1202 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1203 64 /**<N Number of RHS columns*/,
1204 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1205 false /**< reinterpret the input as 3D */,
1206 true /**< Flag used to broadcast the bias addition */,
1207 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001208 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001209 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1210 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1211 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1212 GEMMLHSMatrixInfo(),
1213 GEMMRHSMatrixInfo(),
1214 0 /**< Offset to be added to each element of the matrix A */,
1215 0 /**< Offset to be added to each element of the matrix B */),
1216 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1217 64 /**<N Number of RHS columns*/,
1218 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1219 false /**< reinterpret the input as 3D */,
1220 true /**< Flag used to broadcast the bias addition */,
1221 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001222 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001223 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1224 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1225 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1226 GEMMLHSMatrixInfo(),
1227 GEMMRHSMatrixInfo(),
1228 0 /**< Offset to be added to each element of the matrix A */,
1229 0 /**< Offset to be added to each element of the matrix B */)
1230 })),
1231 framework::dataset::make("Expected", { true,
1232 true,
1233 true,
1234 false,
1235 false})),
1236 input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected)
1237{
Georgios Pinitas856f66e2021-04-22 21:13:21 +01001238 ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true),
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001239 &input1_info.clone()->set_is_resizable(true),
1240 &input2_info.clone()->set_is_resizable(true),
1241 &output_info.clone()->set_is_resizable(true),1.f,1.f,
1242 lhs_info,
1243 rhs_info,
1244 gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS);
1245}
1246
1247FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL,
1248 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1249 m_values,
1250 n_values),
1251 k_values),
1252 b_values),
1253 m0_values_precommit),
1254 n0_values_precommit),
1255 k0_values_precommit),
1256 v0_values_precommit),
1257 h0_values_precommit),
1258 i_values_lhs),
1259 i_values_rhs),
1260 framework::dataset::make("export_to_cl_image_rhs", true)),
1261 framework::dataset::make("DataType", DataType::F16)),
1262 a_values_precommit),
1263 beta_values_precommit),
1264 broadcast_bias_values),
1265 lhs_transpose_values),
1266 act_values))
1267{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001268 // Validate output only if validate() is successful
1269 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001270 {
1271 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1272 }
1273 else
1274 {
1275 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1276 framework::ARM_COMPUTE_PRINT_INFO();
1277 }
1278
1279}
1280
1281FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::NIGHTLY,
1282 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1283 m_values,
1284 n_values),
1285 k_values),
1286 b_values),
1287 m0_values_nightly),
1288 n0_export_to_cl_image_values_nightly),
1289 k0_export_to_cl_image_values_nightly),
1290 v0_values_nightly),
1291 h0_values_nightly),
1292 i_values_lhs),
1293 i_values_rhs),
1294 framework::dataset::make("export_to_cl_image_rhs", true)),
1295 framework::dataset::make("DataType", DataType::F16)),
1296 a_values_nightly),
1297 beta_values_nightly),
1298 broadcast_bias_values),
1299 lhs_transpose_values),
1300 act_values))
1301{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001302 // Validate output only if validate() is successful
1303 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001304 {
1305 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1306 }
1307 else
1308 {
1309 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1310 framework::ARM_COMPUTE_PRINT_INFO();
1311 }
1312}
1313
1314FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL,
1315 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1316 m_w_values,
1317 m_h_values),
1318 n_values),
1319 k_values),
1320 b_values),
1321 m0_values_precommit),
1322 n0_values_precommit),
1323 k0_values_precommit),
1324 v0_values_precommit),
1325 h0_values_precommit),
1326 i_values_lhs),
1327 i_values_rhs),
1328 framework::dataset::make("export_to_cl_image_rhs", true)),
1329 framework::dataset::make("DataType", DataType::F16)),
1330 a_values_precommit),
1331 beta_values_precommit),
1332 lhs_transpose_values),
1333 act_values))
1334{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001335 // Validate output only if validate() is successful
1336 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001337 {
1338 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1339 }
1340 else
1341 {
1342 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1343 framework::ARM_COMPUTE_PRINT_INFO();
1344 }
1345}
1346
1347FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::NIGHTLY,
1348 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1349 m_w_values,
1350 m_h_values),
1351 n_values),
1352 k_values),
1353 b_values),
1354 m0_values_nightly),
1355 n0_export_to_cl_image_values_nightly),
1356 k0_export_to_cl_image_values_nightly),
1357 v0_values_nightly),
1358 h0_values_nightly),
1359 i_values_lhs),
1360 i_values_rhs),
1361 framework::dataset::make("export_to_cl_image_rhs", true)),
1362 framework::dataset::make("DataType", DataType::F16)),
1363 a_values_nightly),
1364 beta_values_nightly),
1365 lhs_transpose_values),
1366 act_values))
1367{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001368 // Validate output only if validate() is successful
1369 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001370 {
1371 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1372 }
1373 else
1374 {
1375 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1376 framework::ARM_COMPUTE_PRINT_INFO();
1377 }
1378}
SiCongLi1af54162021-10-06 15:25:57 +01001379TEST_SUITE(FusedPostOps)
1380
1381FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<half>, framework::DatasetMode::ALL,
1382 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1383 m_values,
1384 n_values),
1385 k_values),
1386 b_values),
1387 m0_values_precommit),
1388 n0_values_precommit),
1389 k0_values_precommit),
1390 v0_values_precommit),
1391 h0_values_precommit),
1392 framework::dataset::make("interleave_lhs", { false })),
1393 framework::dataset::make("interleave_rhs", { false })),
1394 framework::dataset::make("export_to_cl_image_rhs", true)),
1395 framework::dataset::make("DataType", DataType::F16)),
1396 a_values_precommit),
1397 beta_values_precommit),
1398 framework::dataset::make("broadcast_bias", { true } )),
1399 lhs_transpose_values),
1400 act_values),
1401 post_op_lists)
1402 )
1403{
1404 // Validate output only if validate() is successful
1405 if(validate_result)
1406 {
1407 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1408 }
1409 else
1410 {
1411 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1412 framework::ARM_COMPUTE_PRINT_INFO();
1413 }
1414}
1415
1416TEST_SUITE_END() // FusedPostOps
1417
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001418TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001419TEST_SUITE_END() // FP16
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001420
1421TEST_SUITE(MixedPrecision)
1422
1423FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001424 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001425 m_values,
1426 n_values),
1427 k_values),
1428 b_values),
1429 m0_values_precommit),
1430 n0_values_precommit),
1431 k0_values_precommit),
1432 v0_values_precommit),
1433 h0_values_precommit),
1434 i_values_lhs),
1435 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001436 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001437 framework::dataset::make("DataType", DataType::F16)),
1438 a_values_precommit),
1439 beta_values_precommit),
1440 broadcast_bias_values),
1441 lhs_transpose_values),
1442 act_values))
1443{
1444 // Validate output
1445 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1446}
1447
Michalis Spyrou1d897772019-12-09 18:47:29 +00001448FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001449 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001450 m_values,
1451 n_values),
1452 k_values),
1453 b_values),
1454 m0_values_nightly),
1455 n0_values_nightly),
1456 k0_values_nightly),
1457 v0_values_nightly),
1458 h0_values_nightly),
1459 i_values_lhs),
1460 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001461 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001462 framework::dataset::make("DataType", DataType::F16)),
1463 a_values_nightly),
1464 beta_values_nightly),
1465 broadcast_bias_values),
1466 lhs_transpose_values),
1467 act_values))
1468{
1469 // Validate output
1470 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1471}
1472
1473FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001474 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001475 m_w_values,
1476 m_h_values),
1477 n_values),
1478 k_values),
1479 b_values),
1480 m0_values_precommit),
1481 n0_values_precommit),
1482 k0_values_precommit),
1483 v0_values_precommit),
1484 h0_values_precommit),
1485 i_values_lhs),
1486 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001487 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001488 framework::dataset::make("DataType", DataType::F16)),
1489 a_values_precommit),
1490 beta_values_precommit),
1491 lhs_transpose_values),
1492 act_values))
1493{
1494 // Validate output
1495 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1496}
1497
Michalis Spyrou1d897772019-12-09 18:47:29 +00001498FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001499 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001500 m_w_values,
1501 m_h_values),
1502 n_values),
1503 k_values),
1504 b_values),
1505 m0_values_nightly),
1506 n0_values_nightly),
1507 k0_values_nightly),
1508 v0_values_nightly),
1509 h0_values_nightly),
1510 i_values_lhs),
1511 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001512 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001513 framework::dataset::make("DataType", DataType::F16)),
1514 a_values_nightly),
1515 beta_values_nightly),
1516 lhs_transpose_values),
1517 act_values))
1518{
1519 // Validate output
1520 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1521}
SiCongLi1af54162021-10-06 15:25:57 +01001522
1523TEST_SUITE(FusedPostOps)
1524
1525FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture<half>, framework::DatasetMode::ALL,
1526 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1527 m_values,
1528 n_values),
1529 k_values),
1530 b_values),
1531 m0_values_precommit),
1532 n0_values_precommit),
1533 k0_values_precommit),
1534 v0_values_precommit),
1535 h0_values_precommit),
1536 framework::dataset::make("interleave_lhs", { false })),
1537 framework::dataset::make("interleave_rhs", { false })),
1538 framework::dataset::make("export_to_cl_image_rhs", { true, false })),
1539 framework::dataset::make("DataType", DataType::F16)),
1540 a_values_precommit),
1541 beta_values_precommit),
1542 framework::dataset::make("broadcast_bias", { true } )),
1543 lhs_transpose_values),
1544 act_values),
1545 post_op_lists)
1546 )
1547{
1548 // Validate output
1549 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1550}
1551
1552TEST_SUITE_END() // FusedPostOps
1553
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001554TEST_SUITE_END() // MixedPrecision
Gian Marco Iodice9382ab32018-12-17 15:12:07 +00001555TEST_SUITE_END() // Float
Gian Marco Iodiced1f54762019-07-19 09:54:47 +01001556TEST_SUITE_END() // GEMMMatrixMultiplyReshaped
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +00001557TEST_SUITE_END() // CL
1558} // namespace validation
1559} // namespace test
Michele Di Giorgio2568c6b2019-09-17 12:08:46 +01001560} // namespace arm_compute