blob: 539af1c7198c140069c771e7a145d47a6e3b53b5 [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"
SiCongLi31778612021-11-12 17:33:45 +000026#include "arm_compute/core/experimental/PostOps.h"
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +000027#include "arm_compute/core/utils/misc/ShapeCalculator.h"
28#include "arm_compute/runtime/CL/CLTensor.h"
29#include "arm_compute/runtime/CL/CLTensorAllocator.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}
ramelg016049eda2021-10-29 10:52:53 +0100219// To test that the output of the main op is the first parameter in prelu post op
220experimental::PostOpList<PostOpArgBroadcast> post_ops_4()
221{
222 experimental::PostOpList<PostOpArgBroadcast> post_ops{};
223 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F});
224 post_ops.push_back_op<experimental::PostOpEltwisePRelu<PostOpArgBroadcast>>(
225 std::make_tuple(false, false, true), // If true, broadcast in corresponding dim: 0, 1 or 2
226 0,
227 ConvertPolicy::SATURATE);
228 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F});
229 return post_ops;
230}
231// To test that the output of the main op is the second parameter in prelu post op i.e. it is the alpha_param
232experimental::PostOpList<PostOpArgBroadcast> post_ops_5()
233{
234 experimental::PostOpList<PostOpArgBroadcast> post_ops{};
235 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F});
236 post_ops.push_back_op<experimental::PostOpEltwisePRelu<PostOpArgBroadcast>>(
237 std::make_tuple(false, false, false), // If true, broadcast in corresponding dim: 0, 1 or 2
238 1,
239 ConvertPolicy::SATURATE);
240 post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F});
241 return post_ops;
242}
SiCongLi1af54162021-10-06 15:25:57 +0100243/** Different Post Op Lists */
244const auto post_op_lists = framework::dataset::make("post_op_lists", {
245 post_ops_1(),
246 post_ops_2(),
247 post_ops_3(),
ramelg016049eda2021-10-29 10:52:53 +0100248 post_ops_4(),
249 post_ops_5()
SiCongLi1af54162021-10-06 15:25:57 +0100250 } );
251
SiCongLieb8bd812021-10-29 15:05:49 +0100252bool 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)
253{
254 const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true);
255 const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false);
256
257 // Create TensorInfo for post op arguments
258 TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type);
259 TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type);
260 TensorInfo input2_info(TensorShape(n), 1, data_type);
261 TensorInfo output_info(TensorShape(n, m, batch), 1, data_type);
262
263 const TensorInfo reshaped_input0_info = input0_info.clone()->set_tensor_shape(misc::shape_calculator::compute_lhs_reshaped_shape(input0_info, lhs_info));
264 const TensorInfo reshaped_input1_info = input1_info.clone()->set_tensor_shape(misc::shape_calculator::compute_rhs_reshaped_shape(input1_info, rhs_info));
265
266 GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
267 false /**< reinterpret the input as 3D */,
268 true /**< Flag used to broadcast the bias addition */,
269 false /**< wider accumm */,
270 false /**< has pad y */,
271 ActivationLayerInfo::ActivationFunction::IDENTITY,
272 1 /**< Multiplication factor for the width of the 1xW transposed block */,
273 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
274 lhs_info,
275 rhs_info,
276 0 /**< Offset to be added to each element of the matrix A */,
277 0 /**< Offset to be added to each element of the matrix B */,
278 post_ops);
279 return bool(ClGemmMatrixMultiplyReshapedKernel::validate(&reshaped_input0_info.clone()->set_is_resizable(true),
280 &reshaped_input1_info.clone()->set_is_resizable(true),
281 &input2_info.clone()->set_is_resizable(true),
282 &output_info.clone()->set_is_resizable(true),1.f,1.f,
283 lhs_info,
284 rhs_info,
285 gemm_info));
286}
287
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000288} // namespace
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000289
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000290TEST_SUITE(CL)
291TEST_SUITE(GEMMMatrixMultiplyReshaped)
morgolockaba2f912020-05-05 16:28:19 +0100292
293// *INDENT-OFF*
294// clang-format off
295DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
296 framework::dataset::make("Input0Info", { TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // OK
297 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK
298 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), // Data type not supported
299 TensorInfo(TensorShape(10U, 5U, 2U), 1, DataType::F32), // Incorrect dimension bias
300 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // Mismatching shapes
301 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, do not broadcast bias
302 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, wider accummulation
303 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, RHS 4,4,2
304
305 }),
306 framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32),
307 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16),
308 TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8),
309 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32),
310 TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
311 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16),
312 TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16),
313 TensorInfo(TensorShape(128U, 3U, 2U), 1, DataType::F16),
314
315 })),
316 framework::dataset::make("Input2Info", { TensorInfo(TensorShape(21U), 1, DataType::F32),
317 TensorInfo(TensorShape(21U), 1, DataType::F16),
318 TensorInfo(TensorShape(21U), 1, DataType::QASYMM8),
319 TensorInfo(TensorShape(21U), 1, DataType::F32),
320 TensorInfo(TensorShape(21U), 1, DataType::F32),
321 TensorInfo(TensorShape(21U,17U), 1, DataType::F16),
322 TensorInfo(TensorShape(21U,17U), 1, DataType::F16),
323 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
324
325 })),
326 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32),
327 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
328 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::QASYMM8),
329 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32),
330 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32),
331 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
332 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
333 TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16),
334
335 })),
336 framework::dataset::make("LHSMInfo",{
337 GEMMLHSMatrixInfo(4,4,1,false,true),
338 GEMMLHSMatrixInfo(4,4,1,false,true),
339 GEMMLHSMatrixInfo(4,4,1,false,true),
340 GEMMLHSMatrixInfo(4,2,4,false,false),
341 GEMMLHSMatrixInfo(4,2,4,false,false),
342 GEMMLHSMatrixInfo(4,4,1,false,true),
343 GEMMLHSMatrixInfo(4,4,1,false,true),
344 GEMMLHSMatrixInfo(4,4,1,false,true),
345
346 })),
347 framework::dataset::make("RHSMInfo",{
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100348 GEMMRHSMatrixInfo(4,4,1,true,true,false),
349 GEMMRHSMatrixInfo(4,4,1,true,true,false),
350 GEMMRHSMatrixInfo(4,4,1,true,true,false),
351 GEMMRHSMatrixInfo(2,2,1,true,false,false),
352 GEMMRHSMatrixInfo(2,2,1,true,false,false),
353 GEMMRHSMatrixInfo(4,4,1,true,true,false),
354 GEMMRHSMatrixInfo(4,4,1,true,true,false),
355 GEMMRHSMatrixInfo(4,4,2,true,false,false),
morgolockaba2f912020-05-05 16:28:19 +0100356
357
358 })),
359
360
361 framework::dataset::make("GEMMInfo",{
362 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
363 21 /**<N Number of RHS columns*/,
364 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
365 false /**< reinterpret the input as 3D */,
366 true /**< Flag used to broadcast the bias addition */,
367 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100368 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100369 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
370 1 /**< Multiplication factor for the width of the 1xW transposed block */,
371 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
372 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100373 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100374 0 /**< Offset to be added to each element of the matrix A */,
375 0 /**< Offset to be added to each element of the matrix B */),
376
377 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
378 21 /**<N Number of RHS columns*/,
379 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
380 false /**< reinterpret the input as 3D */,
381 true /**< Flag used to broadcast the bias addition */,
382 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100383 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100384 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
385 1 /**< Multiplication factor for the width of the 1xW transposed block */,
386 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
387 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100388 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100389 0 /**< Offset to be added to each element of the matrix A */,
390 0 /**< Offset to be added to each element of the matrix B */),
391 GEMMKernelInfo(),
392 GEMMKernelInfo(),
393 GEMMKernelInfo(),
394
395 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
396 21 /**<N Number of RHS columns*/,
397 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
398 false /**< reinterpret the input as 3D */,
399 false /**< Flag used to broadcast the bias addition */,
400 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100401 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100402 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
403 1 /**< Multiplication factor for the width of the 1xW transposed block */,
404 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
405 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100406 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100407 0 /**< Offset to be added to each element of the matrix A */,
408 0 /**< Offset to be added to each element of the matrix B */),
409
410
411 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
412 21 /**<N Number of RHS columns*/,
413 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
414 false /**< reinterpret the input as 3D */,
415 false /**< Flag used to broadcast the bias addition */,
416 true /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100417 true /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100418 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
419 1 /**< Multiplication factor for the width of the 1xW transposed block */,
420 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
421 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100422 GEMMRHSMatrixInfo(4,4,1,true,true,false),
morgolockaba2f912020-05-05 16:28:19 +0100423 0 /**< Offset to be added to each element of the matrix A */,
424 0 /**< Offset to be added to each element of the matrix B */),
425
426 GEMMKernelInfo( 17 /**<M Number of LHS rows*/,
427 21 /**<N Number of RHS columns*/,
428 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
429 false /**< reinterpret the input as 3D */,
430 false /**< Flag used to broadcast the bias addition */,
431 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100432 false /**< has pad y */,
morgolockaba2f912020-05-05 16:28:19 +0100433 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
434 1 /**< Multiplication factor for the width of the 1xW transposed block */,
435 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
436 GEMMLHSMatrixInfo(4,4,1,false,true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100437 GEMMRHSMatrixInfo(4,4,2,true,false,false),
morgolockaba2f912020-05-05 16:28:19 +0100438 0 /**< Offset to be added to each element of the matrix A */,
439 0 /**< Offset to be added to each element of the matrix B */),
440 })),
441 framework::dataset::make("Expected", { true, true, false, false, false, true, true,true})),
442 input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected)
443{
SiCongLi1af54162021-10-06 15:25:57 +0100444 ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true),
morgolockaba2f912020-05-05 16:28:19 +0100445 &input1_info.clone()->set_is_resizable(true),
446 &input2_info.clone()->set_is_resizable(true),
447 &output_info.clone()->set_is_resizable(true),1.f,1.f,
448 lhs_info,
449 rhs_info,
450 gemm_info)) == expected, framework::LogLevel::ERRORS);
451}
SiCongLieb8bd812021-10-29 15:05:49 +0100452TEST_SUITE(ValidateFusedPostOpsConfigs)
453TEST_SUITE(Invalid)
454TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL)
SiCongLi1af54162021-10-06 15:25:57 +0100455{
SiCongLieb8bd812021-10-29 15:05:49 +0100456 const auto data_type = DataType::F32;
457 const unsigned int m = 17;
458 const unsigned int n = 1;
459 const unsigned int k = 13;
460 const unsigned int batch = 2;
461 TensorShape post_op_arg0_shape(n, m, batch);
462 TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type);
463 auto post_op_arg1_info = post_op_arg_info.clone();
464
465 // Unsupported sequence of post ops
466 experimental::PostOpList<ITensorInfo*> post_ops{};
467 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>(
468 &post_op_arg_info,
469 1,
470 ConvertPolicy::SATURATE);
471 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>(
472 post_op_arg1_info.get(),
473 0,
474 ConvertPolicy::SATURATE);
475
476 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 +0100477}
SiCongLieb8bd812021-10-29 15:05:49 +0100478TEST_CASE(OutputWidened, framework::DatasetMode::ALL)
479{
480 // Invalid broadcast: post op tensors "widen" the output tensor
481 const auto data_type = DataType::F32;
482 const unsigned int m = 17;
483 const unsigned int n = 1;
484 const unsigned int k = 13;
485 const unsigned int batch = 2;
486 TensorShape post_op_arg_shape(n + 4, m, batch); // output's X dimension (n) is "widened", which is not allowed
487 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
488 experimental::PostOpList<ITensorInfo*> post_ops{};
489 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
490
491 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS);
492}
493TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL)
494{
495 // Invalid broadcast: post op tensors broadcast in the first dimension (X) only
496 const auto data_type = DataType::F32;
497 const unsigned int m = 22;
498 const unsigned int n = 16;
499 const unsigned int k = 15;
500 const unsigned int batch = 3;
501 TensorShape post_op_arg_shape(1, m, batch);
502 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
503 experimental::PostOpList<ITensorInfo*> post_ops{};
504 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
505
506 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS);
507}
ramelg016049eda2021-10-29 10:52:53 +0100508TEST_SUITE_END() // Invalid
SiCongLieb8bd812021-10-29 15:05:49 +0100509TEST_SUITE(Valid)
510TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL)
511{
512 const auto data_type = DataType::F32;
513 const unsigned int m = 22;
514 const unsigned int n = 16;
515 const unsigned int k = 15;
516 const unsigned int batch = 3;
517 experimental::PostOpList<ITensorInfo*> post_ops{};
518
519 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
520}
521TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL)
522{
523 const auto data_type = DataType::F32;
524 const unsigned int m = 22;
525 const unsigned int n = 16;
526 const unsigned int k = 15;
527 const unsigned int batch = 3;
528 TensorShape post_op_arg_shape(n, 1, batch);
529 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
530 experimental::PostOpList<ITensorInfo*> post_ops{};
531 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
532
533 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
534}
535TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL)
536{
537 const auto data_type = DataType::F32;
538 const unsigned int m = 22;
539 const unsigned int n = 16;
540 const unsigned int k = 15;
541 const unsigned int batch = 3;
542 TensorShape post_op_arg_shape(1, 1, batch);
543 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
544 experimental::PostOpList<ITensorInfo*> post_ops{};
545 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
546
547 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
548}
549TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL)
550{
551 const auto data_type = DataType::F32;
552 const unsigned int m = 22;
553 const unsigned int n = 16;
554 const unsigned int k = 15;
555 const unsigned int batch = 3;
556 TensorShape post_op_arg_shape(1, 1, 1);
557 TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type);
558 experimental::PostOpList<ITensorInfo*> post_ops{};
559 post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE);
560
561 ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS);
562}
563TEST_SUITE_END() // Valid
564TEST_SUITE_END() // ValidateFusedPostOps
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000565TEST_SUITE(Float)
566TEST_SUITE(FP32)
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000567
568FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100569 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 +0000570 m_values,
571 n_values),
572 k_values),
573 b_values),
574 m0_values_precommit),
575 n0_values_precommit),
576 k0_values_precommit),
577 v0_values_precommit),
578 h0_values_precommit),
579 i_values_lhs),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000580 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100581 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000582 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100583 a_values_precommit),
584 beta_values_precommit),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100585 broadcast_bias_values),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100586 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100587 act_values))
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000588{
589 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +0000590 if(validate_result)
591 {
592 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
593 }
594 else
595 {
596 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
597 framework::ARM_COMPUTE_PRINT_INFO();
598 }
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000599}
600
Michalis Spyrou1d897772019-12-09 18:47:29 +0000601FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100602 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 +0000603 m_values,
604 n_values),
605 k_values),
606 b_values),
607 m0_values_nightly),
608 n0_values_nightly),
609 k0_values_nightly),
610 v0_values_nightly),
611 h0_values_nightly),
612 i_values_lhs),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000613 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100614 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000615 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100616 a_values_nightly),
617 beta_values_nightly),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100618 broadcast_bias_values),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100619 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100620 act_values))
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000621{
622 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +0000623 if(validate_result)
624 {
625 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
626 }
627 else
628 {
629 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
630 framework::ARM_COMPUTE_PRINT_INFO();
631 }
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000632}
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000633
634FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100635 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 +0000636 m_w_values,
637 m_h_values),
638 n_values),
639 k_values),
640 b_values),
641 m0_values_precommit),
642 n0_values_precommit),
643 k0_values_precommit),
644 v0_values_precommit),
645 h0_values_precommit),
646 i_values_lhs),
647 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100648 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000649 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100650 a_values_precommit),
651 beta_values_precommit),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100652 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100653 act_values))
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000654{
655 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +0000656 if(validate_result)
657 {
658 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
659 }
660 else
661 {
662 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
663 framework::ARM_COMPUTE_PRINT_INFO();
664 }
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000665}
666
Michalis Spyrou1d897772019-12-09 18:47:29 +0000667FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100668 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 +0000669 m_w_values,
670 m_h_values),
671 n_values),
672 k_values),
673 b_values),
674 m0_values_nightly),
675 n0_values_nightly),
676 k0_values_nightly),
677 v0_values_nightly),
678 h0_values_nightly),
679 i_values_lhs),
680 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100681 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000682 framework::dataset::make("DataType", DataType::F32)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +0100683 a_values_nightly),
684 beta_values_nightly),
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100685 lhs_transpose_values),
Gian Marco Iodiceca1f4602019-07-16 15:46:48 +0100686 act_values))
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000687{
688 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +0000689 if(validate_result)
690 {
691 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
692 }
693 else
694 {
695 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
696 framework::ARM_COMPUTE_PRINT_INFO();
697 }
Gian Marco Iodice9382ab32018-12-17 15:12:07 +0000698}
SiCongLi1af54162021-10-06 15:25:57 +0100699TEST_SUITE(FusedPostOps)
700
701FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>, framework::DatasetMode::ALL,
702 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
703 m_values,
704 n_values),
705 k_values),
706 b_values),
707 m0_values_precommit),
708 n0_values_precommit),
709 k0_values_precommit),
710 v0_values_precommit),
711 h0_values_precommit),
712 framework::dataset::make("interleave_lhs", { false })),
713 framework::dataset::make("interleave_rhs", { false })),
714 framework::dataset::make("export_to_cl_image_rhs", false)),
715 framework::dataset::make("DataType", DataType::F32)),
716 a_values_precommit),
717 beta_values_precommit),
718 framework::dataset::make("broadcast_bias", { true } )),
719 lhs_transpose_values),
720 act_values),
721 post_op_lists)
722 )
723{
724 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +0000725 if(validate_result)
726 {
727 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
728 }
729 else
730 {
731 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
732 framework::ARM_COMPUTE_PRINT_INFO();
733 }
SiCongLi1af54162021-10-06 15:25:57 +0100734}
735
736TEST_SUITE_END() // FusedPostOps
737
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100738TEST_SUITE(ExportToCLImage)
739DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
740 framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported
741 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported
742 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported
743 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect k0
744 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect n0
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100745
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100746 }),
747 framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32),
748 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32),
749 TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F32),
750 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32),
751 TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F32),
Gian Marco Iodice05639f62019-09-24 12:05:06 +0100752
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100753 })),
754 framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F32),
755 TensorInfo(TensorShape(64U), 1, DataType::F32),
756 TensorInfo(TensorShape(64U), 1, DataType::F32),
757 TensorInfo(TensorShape(64U), 1, DataType::F32),
758 TensorInfo(TensorShape(64U), 1, DataType::F32),
759
760 })),
761 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
762 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
763 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
764 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
765 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
766 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32),
767
768 })),
769 framework::dataset::make("LHSMInfo",{
770 GEMMLHSMatrixInfo(4, 4, 1, false, true),
771 GEMMLHSMatrixInfo(4, 8, 1, false, true),
772 GEMMLHSMatrixInfo(4, 4, 1, false, true),
773 GEMMLHSMatrixInfo(4, 2, 1, false, false),
774 GEMMLHSMatrixInfo(4, 4, 1, false, false),
775
776 })),
777 framework::dataset::make("RHSMInfo",{
778 GEMMRHSMatrixInfo(4, 4, 1, true, true, true),
779 GEMMRHSMatrixInfo(4, 8, 1, true, true, true),
780 GEMMRHSMatrixInfo(8, 4, 1, true, true, true),
781 GEMMRHSMatrixInfo(4, 2, 1, true, false, true),
782 GEMMRHSMatrixInfo(2, 4, 1, true, false, true),
783 })),
784 framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
785 64 /**<N Number of RHS columns*/,
786 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
787 false /**< reinterpret the input as 3D */,
788 true /**< Flag used to broadcast the bias addition */,
789 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100790 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100791 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
792 1 /**< Multiplication factor for the width of the 1xW transposed block */,
793 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
794 GEMMLHSMatrixInfo(),
795 GEMMRHSMatrixInfo(),
796 0 /**< Offset to be added to each element of the matrix A */,
797 0 /**< Offset to be added to each element of the matrix B */),
798 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
799 64 /**<N Number of RHS columns*/,
800 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
801 false /**< reinterpret the input as 3D */,
802 true /**< Flag used to broadcast the bias addition */,
803 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100804 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100805 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
806 1 /**< Multiplication factor for the width of the 1xW transposed block */,
807 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
808 GEMMLHSMatrixInfo(),
809 GEMMRHSMatrixInfo(),
810 0 /**< Offset to be added to each element of the matrix A */,
811 0 /**< Offset to be added to each element of the matrix B */),
812 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
813 64 /**<N Number of RHS columns*/,
814 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
815 false /**< reinterpret the input as 3D */,
816 true /**< Flag used to broadcast the bias addition */,
817 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100818 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100819 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
820 1 /**< Multiplication factor for the width of the 1xW transposed block */,
821 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
822 GEMMLHSMatrixInfo(),
823 GEMMRHSMatrixInfo(),
824 0 /**< Offset to be added to each element of the matrix A */,
825 0 /**< Offset to be added to each element of the matrix B */),
826
827 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
828 64 /**<N Number of RHS columns*/,
829 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
830 false /**< reinterpret the input as 3D */,
831 true /**< Flag used to broadcast the bias addition */,
832 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100833 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100834 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
835 1 /**< Multiplication factor for the width of the 1xW transposed block */,
836 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
837 GEMMLHSMatrixInfo(),
838 GEMMRHSMatrixInfo(),
839 0 /**< Offset to be added to each element of the matrix A */,
840 0 /**< Offset to be added to each element of the matrix B */),
841 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
842 64 /**<N Number of RHS columns*/,
843 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
844 false /**< reinterpret the input as 3D */,
845 true /**< Flag used to broadcast the bias addition */,
846 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +0100847 false /**< has pad y */,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100848 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
849 1 /**< Multiplication factor for the width of the 1xW transposed block */,
850 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
851 GEMMLHSMatrixInfo(),
852 GEMMRHSMatrixInfo(),
853 0 /**< Offset to be added to each element of the matrix A */,
854 0 /**< Offset to be added to each element of the matrix B */)
855 })),
856 framework::dataset::make("Expected", { true,
857 true,
858 true,
859 false,
Gian Marco Iodice047e5d02022-08-25 15:14:23 +0100860 true})),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100861 input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected)
862{
Georgios Pinitas856f66e2021-04-22 21:13:21 +0100863 ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100864 &input1_info.clone()->set_is_resizable(true),
865 &input2_info.clone()->set_is_resizable(true),
866 &output_info.clone()->set_is_resizable(true),1.f,1.f,
867 lhs_info,
868 rhs_info,
869 gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS);
870}
871
872FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL,
873 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 +0100874 m_values,
875 n_values),
876 k_values),
877 b_values),
878 m0_values_precommit),
879 n0_values_precommit),
880 k0_values_precommit),
881 v0_values_precommit),
882 h0_values_precommit),
883 i_values_lhs),
884 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100885 framework::dataset::make("export_to_cl_image_rhs", true)),
886 framework::dataset::make("DataType", DataType::F32)),
887 a_values_precommit),
888 beta_values_precommit),
889 broadcast_bias_values),
890 lhs_transpose_values),
891 act_values))
892{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000893 // Validate output only if validate() is successful
894 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100895 {
896 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
897 }
898 else
899 {
900 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
901 framework::ARM_COMPUTE_PRINT_INFO();
902 }
903
904}
905
906FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::NIGHTLY,
907 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
908 m_values,
909 n_values),
910 k_values),
911 b_values),
912 m0_values_nightly),
913 n0_export_to_cl_image_values_nightly),
914 k0_export_to_cl_image_values_nightly),
915 v0_values_nightly),
916 h0_values_nightly),
917 i_values_lhs),
918 i_values_rhs),
919 framework::dataset::make("export_to_cl_image_rhs", true)),
920 framework::dataset::make("DataType", DataType::F32)),
921 a_values_nightly),
922 beta_values_nightly),
923 broadcast_bias_values),
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}
938
939FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL,
940 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
941 m_w_values,
942 m_h_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 i_values_lhs),
952 i_values_rhs),
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 lhs_transpose_values),
958 act_values))
959{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000960 // Validate output only if validate() is successful
961 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100962 {
963 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
964 }
965 else
966 {
967 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
968 framework::ARM_COMPUTE_PRINT_INFO();
969 }
970}
971
972FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::NIGHTLY,
973 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
974 m_w_values,
975 m_h_values),
976 n_values),
977 k_values),
978 b_values),
979 m0_values_nightly),
980 n0_export_to_cl_image_values_nightly),
981 k0_export_to_cl_image_values_nightly),
982 v0_values_nightly),
983 h0_values_nightly),
984 i_values_lhs),
985 i_values_rhs),
986 framework::dataset::make("export_to_cl_image_rhs", true)),
987 framework::dataset::make("DataType", DataType::F32)),
988 a_values_nightly),
989 beta_values_nightly),
990 lhs_transpose_values),
991 act_values))
992{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +0000993 // Validate output only if validate() is successful
994 if(validate_result)
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +0100995 {
996 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
997 }
998 else
999 {
1000 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1001 framework::ARM_COMPUTE_PRINT_INFO();
1002 }
1003}
SiCongLi1af54162021-10-06 15:25:57 +01001004TEST_SUITE(FusedPostOps)
1005
1006FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>, framework::DatasetMode::ALL,
1007 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1008 m_values,
1009 n_values),
1010 k_values),
1011 b_values),
1012 m0_values_precommit),
1013 n0_values_precommit),
1014 k0_values_precommit),
1015 v0_values_precommit),
1016 h0_values_precommit),
1017 framework::dataset::make("interleave_lhs", { false })),
1018 framework::dataset::make("interleave_rhs", { false })),
1019 framework::dataset::make("export_to_cl_image_rhs", true)),
1020 framework::dataset::make("DataType", DataType::F32)),
1021 a_values_precommit),
1022 beta_values_precommit),
1023 framework::dataset::make("broadcast_bias", { true } )),
1024 lhs_transpose_values),
1025 act_values),
1026 post_op_lists)
1027 )
1028{
1029 // Validate output only if validate() is successful
1030 if(validate_result)
1031 {
1032 validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32);
1033 }
1034 else
1035 {
1036 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1037 framework::ARM_COMPUTE_PRINT_INFO();
1038 }
1039}
1040
1041TEST_SUITE_END() // FusedPostOps
1042
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001043TEST_SUITE_END() // ExportToCLImage
1044TEST_SUITE_END() // FP32
1045
1046TEST_SUITE(FP16)
1047
1048FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL,
1049 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1050 m_values,
1051 n_values),
1052 k_values),
1053 b_values),
1054 m0_values_precommit),
1055 n0_values_precommit),
1056 k0_values_precommit),
1057 v0_values_precommit),
1058 h0_values_precommit),
1059 i_values_lhs),
1060 i_values_rhs),
1061 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001062 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001063 a_values_precommit),
1064 beta_values_precommit),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001065 broadcast_bias_values),
1066 lhs_transpose_values),
1067 act_values))
1068{
1069 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001070 if(validate_result)
1071 {
1072 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1073 }
1074 else
1075 {
1076 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1077 framework::ARM_COMPUTE_PRINT_INFO();
1078 }
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001079}
1080
Michalis Spyrou1d897772019-12-09 18:47:29 +00001081FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001082 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 +01001083 m_values,
1084 n_values),
1085 k_values),
1086 b_values),
1087 m0_values_nightly),
1088 n0_values_nightly),
1089 k0_values_nightly),
1090 v0_values_nightly),
1091 h0_values_nightly),
1092 i_values_lhs),
1093 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001094 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001095 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001096 a_values_nightly),
1097 beta_values_nightly),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001098 broadcast_bias_values),
1099 lhs_transpose_values),
1100 act_values))
1101{
1102 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001103 if(validate_result)
1104 {
1105 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1106 }
1107 else
1108 {
1109 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1110 framework::ARM_COMPUTE_PRINT_INFO();
1111 }
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001112}
1113
1114FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001115 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 +01001116 m_w_values,
1117 m_h_values),
1118 n_values),
1119 k_values),
1120 b_values),
1121 m0_values_precommit),
1122 n0_values_precommit),
1123 k0_values_precommit),
1124 v0_values_precommit),
1125 h0_values_precommit),
1126 i_values_lhs),
1127 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001128 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001129 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001130 a_values_precommit),
1131 beta_values_precommit),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001132 lhs_transpose_values),
1133 act_values))
1134{
1135 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001136 if(validate_result)
1137 {
1138 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1139 }
1140 else
1141 {
1142 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1143 framework::ARM_COMPUTE_PRINT_INFO();
1144 }
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001145}
1146
Michalis Spyrou1d897772019-12-09 18:47:29 +00001147FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001148 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 +01001149 m_w_values,
1150 m_h_values),
1151 n_values),
1152 k_values),
1153 b_values),
1154 m0_values_nightly),
1155 n0_values_nightly),
1156 k0_values_nightly),
1157 v0_values_nightly),
1158 h0_values_nightly),
1159 i_values_lhs),
1160 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001161 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001162 framework::dataset::make("DataType", DataType::F16)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001163 a_values_nightly),
1164 beta_values_nightly),
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001165 lhs_transpose_values),
1166 act_values))
1167{
1168 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001169 if(validate_result)
1170 {
1171 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1172 }
1173 else
1174 {
1175 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1176 framework::ARM_COMPUTE_PRINT_INFO();
1177 }
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001178}
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001179
SiCongLi1af54162021-10-06 15:25:57 +01001180TEST_SUITE(FusedPostOps)
1181
1182FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<half>, framework::DatasetMode::ALL,
1183 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1184 m_values,
1185 n_values),
1186 k_values),
1187 b_values),
1188 m0_values_precommit),
1189 n0_values_precommit),
1190 k0_values_precommit),
1191 v0_values_precommit),
1192 h0_values_precommit),
1193 framework::dataset::make("interleave_lhs", { false })),
1194 framework::dataset::make("interleave_rhs", { false })),
1195 framework::dataset::make("export_to_cl_image_rhs", false)),
1196 framework::dataset::make("DataType", DataType::F16)),
1197 a_values_precommit),
1198 beta_values_precommit),
1199 framework::dataset::make("broadcast_bias", { true } )),
1200 lhs_transpose_values),
1201 act_values),
1202 post_op_lists)
1203 )
1204{
1205 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001206 if(validate_result)
1207 {
1208 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1209 }
1210 else
1211 {
1212 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1213 framework::ARM_COMPUTE_PRINT_INFO();
1214 }
SiCongLi1af54162021-10-06 15:25:57 +01001215}
1216
1217TEST_SUITE_END() // FusedPostOps
1218
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001219TEST_SUITE(ExportToCLImage)
1220DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(
1221 framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported
1222 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported
1223 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported
1224 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect k0
1225 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect n0
1226
1227 }),
1228 framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16),
1229 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16),
1230 TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F16),
1231 TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16),
1232 TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F16),
1233
1234 })),
1235 framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F16),
1236 TensorInfo(TensorShape(64U), 1, DataType::F16),
1237 TensorInfo(TensorShape(64U), 1, DataType::F16),
1238 TensorInfo(TensorShape(64U), 1, DataType::F16),
1239 TensorInfo(TensorShape(64U), 1, DataType::F16),
1240
1241 })),
1242 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1243 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1244 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1245 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1246 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1247 TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16),
1248
1249 })),
1250 framework::dataset::make("LHSMInfo",{
1251 GEMMLHSMatrixInfo(4, 4, 1, false, true),
1252 GEMMLHSMatrixInfo(4, 8, 1, false, true),
1253 GEMMLHSMatrixInfo(4, 4, 1, false, true),
1254 GEMMLHSMatrixInfo(4, 2, 1, false, false),
1255 GEMMLHSMatrixInfo(4, 4, 1, false, false),
1256
1257 })),
1258 framework::dataset::make("RHSMInfo",{
1259 GEMMRHSMatrixInfo(4, 4, 1, true, true, true),
1260 GEMMRHSMatrixInfo(4, 8, 1, true, true, true),
1261 GEMMRHSMatrixInfo(8, 4, 1, true, true, true),
1262 GEMMRHSMatrixInfo(4, 2, 1, true, false, true),
1263 GEMMRHSMatrixInfo(2, 4, 1, true, false, true),
1264 })),
1265 framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1266 64 /**<N Number of RHS columns*/,
1267 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1268 false /**< reinterpret the input as 3D */,
1269 true /**< Flag used to broadcast the bias addition */,
1270 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001271 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001272 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1273 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1274 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1275 GEMMLHSMatrixInfo(),
1276 GEMMRHSMatrixInfo(),
1277 0 /**< Offset to be added to each element of the matrix A */,
1278 0 /**< Offset to be added to each element of the matrix B */),
1279 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1280 64 /**<N Number of RHS columns*/,
1281 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1282 false /**< reinterpret the input as 3D */,
1283 true /**< Flag used to broadcast the bias addition */,
1284 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001285 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001286 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1287 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1288 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1289 GEMMLHSMatrixInfo(),
1290 GEMMRHSMatrixInfo(),
1291 0 /**< Offset to be added to each element of the matrix A */,
1292 0 /**< Offset to be added to each element of the matrix B */),
1293 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1294 64 /**<N Number of RHS columns*/,
1295 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1296 false /**< reinterpret the input as 3D */,
1297 true /**< Flag used to broadcast the bias addition */,
1298 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001299 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001300 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1301 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1302 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1303 GEMMLHSMatrixInfo(),
1304 GEMMRHSMatrixInfo(),
1305 0 /**< Offset to be added to each element of the matrix A */,
1306 0 /**< Offset to be added to each element of the matrix B */),
1307
1308 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1309 64 /**<N Number of RHS columns*/,
1310 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1311 false /**< reinterpret the input as 3D */,
1312 true /**< Flag used to broadcast the bias addition */,
1313 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001314 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001315 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1316 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1317 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1318 GEMMLHSMatrixInfo(),
1319 GEMMRHSMatrixInfo(),
1320 0 /**< Offset to be added to each element of the matrix A */,
1321 0 /**< Offset to be added to each element of the matrix B */),
1322 GEMMKernelInfo( 64 /**<M Number of LHS rows*/,
1323 64 /**<N Number of RHS columns*/,
1324 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */,
1325 false /**< reinterpret the input as 3D */,
1326 true /**< Flag used to broadcast the bias addition */,
1327 false /**< wider accumm */,
Gian Marco Iodice9ae06d42020-10-22 16:37:12 +01001328 false /**< has pad y */,
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001329 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU,
1330 1 /**< Multiplication factor for the width of the 1xW transposed block */,
1331 1 /**< Multiplication factor for the height of the 4x4 interleaved block */,
1332 GEMMLHSMatrixInfo(),
1333 GEMMRHSMatrixInfo(),
1334 0 /**< Offset to be added to each element of the matrix A */,
1335 0 /**< Offset to be added to each element of the matrix B */)
1336 })),
1337 framework::dataset::make("Expected", { true,
1338 true,
1339 true,
1340 false,
Gian Marco Iodice047e5d02022-08-25 15:14:23 +01001341 true})),
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001342 input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected)
1343{
Georgios Pinitas856f66e2021-04-22 21:13:21 +01001344 ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true),
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001345 &input1_info.clone()->set_is_resizable(true),
1346 &input2_info.clone()->set_is_resizable(true),
1347 &output_info.clone()->set_is_resizable(true),1.f,1.f,
1348 lhs_info,
1349 rhs_info,
1350 gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS);
1351}
1352
1353FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL,
1354 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1355 m_values,
1356 n_values),
1357 k_values),
1358 b_values),
1359 m0_values_precommit),
1360 n0_values_precommit),
1361 k0_values_precommit),
1362 v0_values_precommit),
1363 h0_values_precommit),
1364 i_values_lhs),
1365 i_values_rhs),
1366 framework::dataset::make("export_to_cl_image_rhs", true)),
1367 framework::dataset::make("DataType", DataType::F16)),
1368 a_values_precommit),
1369 beta_values_precommit),
1370 broadcast_bias_values),
1371 lhs_transpose_values),
1372 act_values))
1373{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001374 // Validate output only if validate() is successful
1375 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001376 {
1377 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1378 }
1379 else
1380 {
1381 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1382 framework::ARM_COMPUTE_PRINT_INFO();
1383 }
1384
1385}
1386
1387FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::NIGHTLY,
1388 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1389 m_values,
1390 n_values),
1391 k_values),
1392 b_values),
1393 m0_values_nightly),
1394 n0_export_to_cl_image_values_nightly),
1395 k0_export_to_cl_image_values_nightly),
1396 v0_values_nightly),
1397 h0_values_nightly),
1398 i_values_lhs),
1399 i_values_rhs),
1400 framework::dataset::make("export_to_cl_image_rhs", true)),
1401 framework::dataset::make("DataType", DataType::F16)),
1402 a_values_nightly),
1403 beta_values_nightly),
1404 broadcast_bias_values),
1405 lhs_transpose_values),
1406 act_values))
1407{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001408 // Validate output only if validate() is successful
1409 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001410 {
1411 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1412 }
1413 else
1414 {
1415 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1416 framework::ARM_COMPUTE_PRINT_INFO();
1417 }
1418}
1419
1420FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL,
1421 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1422 m_w_values,
1423 m_h_values),
1424 n_values),
1425 k_values),
1426 b_values),
1427 m0_values_precommit),
1428 n0_values_precommit),
1429 k0_values_precommit),
1430 v0_values_precommit),
1431 h0_values_precommit),
1432 i_values_lhs),
1433 i_values_rhs),
1434 framework::dataset::make("export_to_cl_image_rhs", true)),
1435 framework::dataset::make("DataType", DataType::F16)),
1436 a_values_precommit),
1437 beta_values_precommit),
1438 lhs_transpose_values),
1439 act_values))
1440{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001441 // Validate output only if validate() is successful
1442 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001443 {
1444 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1445 }
1446 else
1447 {
1448 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1449 framework::ARM_COMPUTE_PRINT_INFO();
1450 }
1451}
1452
1453FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::NIGHTLY,
1454 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1455 m_w_values,
1456 m_h_values),
1457 n_values),
1458 k_values),
1459 b_values),
1460 m0_values_nightly),
1461 n0_export_to_cl_image_values_nightly),
1462 k0_export_to_cl_image_values_nightly),
1463 v0_values_nightly),
1464 h0_values_nightly),
1465 i_values_lhs),
1466 i_values_rhs),
1467 framework::dataset::make("export_to_cl_image_rhs", true)),
1468 framework::dataset::make("DataType", DataType::F16)),
1469 a_values_nightly),
1470 beta_values_nightly),
1471 lhs_transpose_values),
1472 act_values))
1473{
Sheri Zhangcc3e53c2020-11-16 21:17:28 +00001474 // Validate output only if validate() is successful
1475 if(validate_result)
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001476 {
1477 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1478 }
1479 else
1480 {
1481 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1482 framework::ARM_COMPUTE_PRINT_INFO();
1483 }
1484}
SiCongLi1af54162021-10-06 15:25:57 +01001485TEST_SUITE(FusedPostOps)
1486
1487FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<half>, framework::DatasetMode::ALL,
1488 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1489 m_values,
1490 n_values),
1491 k_values),
1492 b_values),
1493 m0_values_precommit),
1494 n0_values_precommit),
1495 k0_values_precommit),
1496 v0_values_precommit),
1497 h0_values_precommit),
1498 framework::dataset::make("interleave_lhs", { false })),
1499 framework::dataset::make("interleave_rhs", { false })),
1500 framework::dataset::make("export_to_cl_image_rhs", true)),
1501 framework::dataset::make("DataType", DataType::F16)),
1502 a_values_precommit),
1503 beta_values_precommit),
1504 framework::dataset::make("broadcast_bias", { true } )),
1505 lhs_transpose_values),
1506 act_values),
1507 post_op_lists)
1508 )
1509{
1510 // Validate output only if validate() is successful
1511 if(validate_result)
1512 {
1513 validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16);
1514 }
1515 else
1516 {
1517 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1518 framework::ARM_COMPUTE_PRINT_INFO();
1519 }
1520}
1521
1522TEST_SUITE_END() // FusedPostOps
1523
Gian Marco Iodice6f931342020-09-15 14:17:41 +01001524TEST_SUITE_END() // ExportToCLImage
Gian Marco Iodice05639f62019-09-24 12:05:06 +01001525TEST_SUITE_END() // FP16
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001526
1527TEST_SUITE(MixedPrecision)
1528
1529FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001530 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 +01001531 m_values,
1532 n_values),
1533 k_values),
1534 b_values),
1535 m0_values_precommit),
1536 n0_values_precommit),
1537 k0_values_precommit),
1538 v0_values_precommit),
1539 h0_values_precommit),
1540 i_values_lhs),
1541 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001542 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001543 framework::dataset::make("DataType", DataType::F16)),
1544 a_values_precommit),
1545 beta_values_precommit),
1546 broadcast_bias_values),
1547 lhs_transpose_values),
1548 act_values))
1549{
1550 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001551 if(validate_result)
1552 {
1553 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1554 }
1555 else
1556 {
1557 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1558 framework::ARM_COMPUTE_PRINT_INFO();
1559 }
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001560}
1561
Michalis Spyrou1d897772019-12-09 18:47:29 +00001562FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001563 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 +01001564 m_values,
1565 n_values),
1566 k_values),
1567 b_values),
1568 m0_values_nightly),
1569 n0_values_nightly),
1570 k0_values_nightly),
1571 v0_values_nightly),
1572 h0_values_nightly),
1573 i_values_lhs),
1574 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001575 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001576 framework::dataset::make("DataType", DataType::F16)),
1577 a_values_nightly),
1578 beta_values_nightly),
1579 broadcast_bias_values),
1580 lhs_transpose_values),
1581 act_values))
1582{
1583 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001584 if(validate_result)
1585 {
1586 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1587 }
1588 else
1589 {
1590 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1591 framework::ARM_COMPUTE_PRINT_INFO();
1592 }
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001593}
1594
1595FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::ALL,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001596 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 +01001597 m_w_values,
1598 m_h_values),
1599 n_values),
1600 k_values),
1601 b_values),
1602 m0_values_precommit),
1603 n0_values_precommit),
1604 k0_values_precommit),
1605 v0_values_precommit),
1606 h0_values_precommit),
1607 i_values_lhs),
1608 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001609 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001610 framework::dataset::make("DataType", DataType::F16)),
1611 a_values_precommit),
1612 beta_values_precommit),
1613 lhs_transpose_values),
1614 act_values))
1615{
1616 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001617 if(validate_result)
1618 {
1619 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1620 }
1621 else
1622 {
1623 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1624 framework::ARM_COMPUTE_PRINT_INFO();
1625 }
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001626}
1627
Michalis Spyrou1d897772019-12-09 18:47:29 +00001628FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED,
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001629 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 +01001630 m_w_values,
1631 m_h_values),
1632 n_values),
1633 k_values),
1634 b_values),
1635 m0_values_nightly),
1636 n0_values_nightly),
1637 k0_values_nightly),
1638 v0_values_nightly),
1639 h0_values_nightly),
1640 i_values_lhs),
1641 i_values_rhs),
Gian Marco Iodicee3a849a2020-06-10 17:59:30 +01001642 framework::dataset::make("export_to_cl_image_rhs", false)),
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001643 framework::dataset::make("DataType", DataType::F16)),
1644 a_values_nightly),
1645 beta_values_nightly),
1646 lhs_transpose_values),
1647 act_values))
1648{
1649 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001650 if(validate_result)
1651 {
1652 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1653 }
1654 else
1655 {
1656 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1657 framework::ARM_COMPUTE_PRINT_INFO();
1658 }
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001659}
SiCongLi1af54162021-10-06 15:25:57 +01001660
1661TEST_SUITE(FusedPostOps)
1662
1663FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture<half>, framework::DatasetMode::ALL,
1664 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
1665 m_values,
1666 n_values),
1667 k_values),
1668 b_values),
1669 m0_values_precommit),
1670 n0_values_precommit),
1671 k0_values_precommit),
1672 v0_values_precommit),
1673 h0_values_precommit),
1674 framework::dataset::make("interleave_lhs", { false })),
1675 framework::dataset::make("interleave_rhs", { false })),
1676 framework::dataset::make("export_to_cl_image_rhs", { true, false })),
1677 framework::dataset::make("DataType", DataType::F16)),
1678 a_values_precommit),
1679 beta_values_precommit),
1680 framework::dataset::make("broadcast_bias", { true } )),
1681 lhs_transpose_values),
1682 act_values),
1683 post_op_lists)
1684 )
1685{
1686 // Validate output
Giorgio Arenaa3b13b52021-11-08 17:52:26 +00001687 if(validate_result)
1688 {
1689 validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision);
1690 }
1691 else
1692 {
1693 ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped");
1694 framework::ARM_COMPUTE_PRINT_INFO();
1695 }
SiCongLi1af54162021-10-06 15:25:57 +01001696}
1697
1698TEST_SUITE_END() // FusedPostOps
1699
Gian Marco Iodice0c17aa22019-09-27 09:23:15 +01001700TEST_SUITE_END() // MixedPrecision
Gian Marco Iodice9382ab32018-12-17 15:12:07 +00001701TEST_SUITE_END() // Float
Gian Marco Iodiced1f54762019-07-19 09:54:47 +01001702TEST_SUITE_END() // GEMMMatrixMultiplyReshaped
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +00001703TEST_SUITE_END() // CL
1704} // namespace validation
1705} // namespace test
Michele Di Giorgio2568c6b2019-09-17 12:08:46 +01001706} // namespace arm_compute