blob: f956cdfeda85a3f0e8ceb1dbda59011b864a499c [file] [log] [blame]
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +01001/*
SiCong Li13bab712023-01-13 15:29:39 +00002 * Copyright (c) 2017-2023 Arm Limited.
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
Matthew Bentham314d3e22023-06-23 10:53:52 +000025#include "arm_compute/core/utils/StringUtils.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010026#include "arm_compute/runtime/NEON/functions/NEGEMM.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
Michele Di Giorgio4dfc5532021-06-30 12:05:34 +010029#include "src/core/helpers/MemoryHelpers.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010030#include "src/cpu/kernels/CpuGemmInterleave4x4Kernel.h"
31#include "src/cpu/kernels/CpuGemmMatrixMultiplyKernel.h"
32#include "src/cpu/kernels/CpuGemmTranspose1xWKernel.h"
33#include "src/cpu/operators/CpuGemm.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010034#include "tests/NEON/Accessor.h"
Pablo Tello2fdc4092017-11-23 15:50:08 +000035#include "tests/NEON/Helper.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010036#include "tests/PaddingCalculator.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010037#include "tests/datasets/LargeGEMMDataset.h"
38#include "tests/datasets/SmallGEMMDataset.h"
Anthony Barbier1c0d0ff2018-01-31 13:05:09 +000039#include "tests/datasets/TinyGEMMDataset.h"
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010040#include "tests/framework/Asserts.h"
41#include "tests/framework/Macros.h"
42#include "tests/framework/datasets/Datasets.h"
43#include "tests/validation/Validation.h"
44#include "tests/validation/fixtures/GEMMFixture.h"
Pablo Tello2fdc4092017-11-23 15:50:08 +000045#include "tests/validation/fixtures/GEMMInterleave4x4Fixture.h"
Pablo Tello088cc7f2017-12-07 15:20:55 +000046#include "tests/validation/fixtures/GEMMTranspose1xWFixture.h"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010047
48namespace arm_compute
49{
50namespace test
51{
52namespace validation
53{
54namespace
55{
Gian Marco Iodicefbf3ecc2018-08-23 17:26:21 +010056constexpr AbsoluteTolerance<float> tolerance_f(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for FP32 data types */
57#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
58RelativeTolerance<half_float::half> rel_tolerance_f16(half(0.2)); /**< Relative tolerance value for comparing reference's output against implementation's output for FP16 data types */
59const AbsoluteTolerance<float> abs_tolerance_f16(0.2f); /**< Absolute tolerance value for comparing reference's output against implementation's output for FP16 data types */
60constexpr float tolerance_num = 0.07f; /**< Tolerance number for FP16 data types */
61#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010062/** CNN data types */
63const auto CNNDataTypes = framework::dataset::make("DataType",
64{
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +000065#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010066 DataType::F16,
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +000067#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010068 DataType::F32,
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010069});
Pablo Tello2fdc4092017-11-23 15:50:08 +000070
71const auto data_interleave = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12);
Pablo Tello088cc7f2017-12-07 15:20:55 +000072const auto data_transpose = framework::dataset::make("M", 8, 14) * framework::dataset::make("N", 7, 14);
73
Gian Marco Iodicefeaea102020-09-03 13:20:34 +010074/** Zero padding test */
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +010075template <typename FunctionType>
76bool validate_zero_padding(unsigned int dim0_value, unsigned int dim1_value)
Gian Marco Iodicefeaea102020-09-03 13:20:34 +010077{
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +010078 const TensorShape in_shape(dim0_value, dim1_value);
Michele Di Giorgio93b75e02021-06-21 12:00:43 +010079 TensorInfo in(in_shape, 1, DataType::U32);
80 TensorInfo dst;
81
82 ARM_COMPUTE_EXPECT(in.is_resizable(), framework::LogLevel::ERRORS);
83
84 // Validate zero-padding
85 FunctionType func;
86
87 func.configure(&in, &dst);
88
89 return in.padding().empty();
90}
91
Michele Di Giorgiocf9e29e2020-10-08 11:54:42 +010092/* Zero padding test for GEMM kernels */
93bool validate_gemm_zero_padding(const TensorShape shape0, const TensorShape shape1)
94{
95 // Create tensors
Michele Di Giorgio53832b22021-06-21 14:45:44 +010096 TensorInfo in0(shape0, 1, DataType::F32);
97 TensorInfo in1(shape1, 1, DataType::F32);
98 TensorInfo dst;
Michele Di Giorgiocf9e29e2020-10-08 11:54:42 +010099
100 // Validate zero-padding
Michele Di Giorgio53832b22021-06-21 14:45:44 +0100101 cpu::kernels::CpuGemmMatrixMultiplyKernel gemm;
Michele Di Giorgiocf9e29e2020-10-08 11:54:42 +0100102 gemm.configure(&in0, &in1, &dst, 1.0, false);
103
Michele Di Giorgio53832b22021-06-21 14:45:44 +0100104 return in0.padding().empty() && in1.padding().empty() && dst.padding().empty();
Michele Di Giorgiocf9e29e2020-10-08 11:54:42 +0100105}
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100106} // namespace
107
108TEST_SUITE(NEON)
109TEST_SUITE(GEMM)
110
Michele Di Giorgio4dfc5532021-06-30 12:05:34 +0100111/** Test case for memory injection in @ref cpu::CpuGemm.
112 *
113 * Configure the operator once and inject memory at run-time in multiple executions.
114 *
115 * Checks performed in order:
116 * - Both runs compute the same output
117 */
118TEST_CASE(MemoryInjection, framework::DatasetMode::ALL)
119{
120 auto gemm = std::make_unique<cpu::CpuGemm>();
121 const auto lhs_info = TensorInfo(TensorShape(3U, 3U), 1, DataType::F32);
122 const auto rhs_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
123 const auto c_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
124 auto dst_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
125 const auto gemm_info = GEMMInfo{};
126 gemm->configure(&lhs_info, &rhs_info, &c_info, &dst_info, 1.f, 1.f, gemm_info);
127
128 // telhs are newly created every call of this lambda function
129 auto lhs = create_tensor<Tensor>(lhs_info);
130 auto rhs = create_tensor<Tensor>(rhs_info);
131 auto c = create_tensor<Tensor>(c_info);
132 lhs.allocator()->allocate();
133 rhs.allocator()->allocate();
134 c.allocator()->allocate();
135
136 ITensorPack run_pack{ { TensorType::ACL_SRC_0, &lhs }, { TensorType::ACL_SRC_1, &rhs }, { TensorType::ACL_SRC_2, &c } };
137 ITensorPack prep_pack{ { TensorType::ACL_SRC_1, &rhs }, { TensorType::ACL_SRC_2, &c } };
138
139 auto mg = MemoryGroup{};
140 auto ws = manage_workspace<Tensor>(gemm->workspace(), mg, run_pack, prep_pack);
141
142 auto run_conv = [&]() -> Tensor
143 {
144 auto dst = create_tensor<Tensor>(dst_info);
145 dst.allocator()->allocate();
146 run_pack.add_tensor(TensorType::ACL_DST, &dst);
147
148 library->fill_tensor_value(Accessor(lhs), 1.f);
149 library->fill_tensor_value(Accessor(rhs), 2.f);
150 library->fill_tensor_value(Accessor(c), 3.f);
151 // This operator is configured once and captured by this lambda.
152 gemm->prepare(prep_pack);
153 gemm->run(run_pack);
154 return dst;
155 };
156 auto result_0 = run_conv();
157 auto result_1 = run_conv();
158 for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
159 {
160 ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS);
161 }
162}
163
164/** Test case for memory injection in @ref NEGEMM.
165 *
166 * Make sure @ref NEGEMM still works through injecting the memory at configure time using the old API.
167 *
168 * Checks performed in order:
169 * - Both runs compute the same output
170 */
171TEST_CASE(MultipleExecutionWithConfigure, framework::DatasetMode::ALL)
172{
173 auto gemm = std::make_unique<NEGEMM>();
174 const auto lhs_info = TensorInfo(TensorShape(3U, 3U), 1, DataType::F32);
175 const auto rhs_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
176 const auto c_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
177 auto dst_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32);
178 const auto gemm_info = GEMMInfo{};
179 auto run_conv = [&]()
180 {
181 auto lhs = create_tensor<Tensor>(lhs_info);
182 auto rhs = create_tensor<Tensor>(rhs_info);
183 auto c = create_tensor<Tensor>(c_info);
184 auto dst = create_tensor<Tensor>(dst_info);
185 gemm->configure(&lhs, &rhs, &c, &dst, 1.f, 1.f, gemm_info);
186 lhs.allocator()->allocate();
187 rhs.allocator()->allocate();
188 c.allocator()->allocate();
189 dst.allocator()->allocate();
190 library->fill_tensor_value(Accessor(lhs), 1.f);
191 library->fill_tensor_value(Accessor(rhs), 2.f);
192 library->fill_tensor_value(Accessor(c), 3.f);
193 gemm->run();
194 return dst;
195 };
196 auto result_0 = run_conv();
197 auto result_1 = run_conv();
198 for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i)
199 {
200 ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS);
201 }
202}
203
SiCong Li13bab712023-01-13 15:29:39 +0000204// *INDENT-OFF*
205// clang-format off
206DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
207 framework::dataset::make("LhsInfo", { TensorInfo(TensorShape(27U, 13U), 1, DataType::S32), // Unsupported data type
208 TensorInfo(TensorShape(27U, 13U), 1, DataType::F32),
209 }),
210 framework::dataset::make("RhsInfo",{ TensorInfo(TensorShape(8U, 27U), 1, DataType::S32),
211 TensorInfo(TensorShape(8U, 27U), 1, DataType::F32),
212 })),
213 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(8U, 13U), 1, DataType::S32),
214 TensorInfo(TensorShape(8U, 13U), 1, DataType::F32),
215 })),
216 framework::dataset::make("Expected", { false, true })),
217 lhs_info, rhs_info, output_info, expected)
218{
219 constexpr float alpha = 1.0;
220 constexpr float beta = 0.0;
221 const auto gemm_info = GEMMInfo();
222 bool is_valid = bool(NEGEMM::validate(&lhs_info.clone()->set_is_resizable(true), &rhs_info.clone()->set_is_resizable(true), nullptr, &output_info.clone()->set_is_resizable(true), alpha, beta, gemm_info));
223 ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
224}
225// clang-format on
226// *INDENT-ON*
Dana Zlotnik256ac622022-02-02 15:06:11 +0200227TEST_SUITE(KERNEL_SELECTION)
228DATA_TEST_CASE(KernelSelection_mul_and_add, framework::DatasetMode::ALL,
229 combine(framework::dataset::make("CpuExt", std::string("NEON")),
230 framework::dataset::make("DataType", { DataType::F32,
231 DataType::F16
232 })),
233 cpu_ext, data_type)
234{
235 using namespace cpu::kernels;
236
237 cpuinfo::CpuIsaInfo cpu_isa{};
238 cpu_isa.neon = (cpu_ext == "NEON");
239 cpu_isa.fp16 = (data_type == DataType::F16);
240
241 const auto *selected_impl_mul = CpuGemmMatrixMultiplyKernel::get_implementation(DataTypeISASelectorData{ data_type, cpu_isa }, cpu::KernelSelectionType::Preferred);
242
243 ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl_mul);
244
245 std::string expected = lower_string(cpu_ext) + "_" + cpu_impl_dt(data_type) + "_gemm_matrix_mul";
246 std::string actual = selected_impl_mul->name;
247
248 ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS);
249
250 const auto *selected_impl_add = CpuGemmMatrixAdditionKernel::get_implementation(DataTypeISASelectorData{ data_type, cpu_isa }, cpu::KernelSelectionType::Preferred);
251
252 ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl_add);
253
254 expected = lower_string(cpu_ext) + "_" + cpu_impl_dt(data_type) + "_gemm_matrix_add";
255 actual = selected_impl_add->name;
256
257 ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS);
258}
259TEST_SUITE_END() // KERNEL_SELECTION
260
Pablo Tello088cc7f2017-12-07 15:20:55 +0000261TEST_SUITE(TRANSPOSE_1XW)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100262using CpuGemmTranspose1xW = NESynthetizeFunctionWithZeroConstantKernelBorder<cpu::kernels::CpuGemmTranspose1xWKernel>;
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +0100263DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(
264 framework::dataset::make("N", { 1, 23, 63, 101 }),
265 framework::dataset::make("K", { 1, 47, 29, 27 })),
266 n_value, k_value)
267{
Michele Di Giorgio4dfc5532021-06-30 12:05:34 +0100268 bool status = validate_zero_padding<CpuGemmTranspose1xW>(n_value, k_value);
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +0100269 ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
270}
271
272TEST_SUITE(U32)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100273using CpuGemmTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, CpuGemmTranspose1xW, uint32_t>;
274FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::U32))
Pablo Tello088cc7f2017-12-07 15:20:55 +0000275{
276 // Validate output
277 validate(Accessor(_target), _reference);
278}
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +0100279TEST_SUITE_END() // U32
280
281TEST_SUITE(U16)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100282using CpuGemmTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, CpuGemmTranspose1xW, uint16_t>;
283FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::U16))
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +0100284{
285 // Validate output
286 validate(Accessor(_target), _reference);
287}
288TEST_SUITE_END() // U16
289
290TEST_SUITE(U8)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100291using CpuGemmTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, CpuGemmTranspose1xW, uint8_t>;
292FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::U8))
Gian Marco Iodiceb3182b12020-09-04 08:44:52 +0100293{
294 // Validate output
295 validate(Accessor(_target), _reference);
296}
297TEST_SUITE_END() // U8
Pablo Tello088cc7f2017-12-07 15:20:55 +0000298
Pablo Tello088cc7f2017-12-07 15:20:55 +0000299TEST_SUITE_END() // TRANSPOSE_1XW
300
Pablo Tello2fdc4092017-11-23 15:50:08 +0000301TEST_SUITE(INTERLEAVE_4X4)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100302using CpuGemmInterleave4x4 = NESynthetizeFunctionWithZeroConstantKernelBorder<cpu::kernels::CpuGemmInterleave4x4Kernel>;
Pablo Tello2fdc4092017-11-23 15:50:08 +0000303
Gian Marco Iodicefeaea102020-09-03 13:20:34 +0100304DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(
305 framework::dataset::make("M", { 1, 23, 63, 101 }),
306 framework::dataset::make("K", { 1, 47, 29, 27 })),
307 m_value, k_value)
308{
Michele Di Giorgio4dfc5532021-06-30 12:05:34 +0100309 bool status = validate_zero_padding<cpu::kernels::CpuGemmInterleave4x4Kernel>(m_value, k_value);
Gian Marco Iodicefeaea102020-09-03 13:20:34 +0100310 ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
311}
312
313TEST_SUITE(U32)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100314using CpuGemmInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, CpuGemmInterleave4x4, uint32_t>;
315FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::U32))
Pablo Tello2fdc4092017-11-23 15:50:08 +0000316{
317 // Validate output
318 validate(Accessor(_target), _reference);
319}
Gian Marco Iodicefeaea102020-09-03 13:20:34 +0100320TEST_SUITE_END() // U32
321
322TEST_SUITE(U16)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100323using CpuGemmInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, CpuGemmInterleave4x4, uint16_t>;
324FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::U16))
Gian Marco Iodicefeaea102020-09-03 13:20:34 +0100325{
326 // Validate output
327 validate(Accessor(_target), _reference);
328}
329TEST_SUITE_END() // U16
330
331TEST_SUITE(U8)
Michele Di Giorgio93b75e02021-06-21 12:00:43 +0100332using CpuGemmInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, CpuGemmInterleave4x4, uint8_t>;
333FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::QASYMM8))
Gian Marco Iodicefeaea102020-09-03 13:20:34 +0100334{
335 // Validate output
336 validate(Accessor(_target), _reference);
337}
338TEST_SUITE_END() // U8
Pablo Tello2fdc4092017-11-23 15:50:08 +0000339
Pablo Tello2fdc4092017-11-23 15:50:08 +0000340TEST_SUITE_END() // INTERLEAVE_4X4
341
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100342template <typename T>
343using NEGEMMFixture = GEMMValidationFixture<Tensor, Accessor, NEGEMM, T>;
344
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000345template <typename T>
Adnan AlSinan26c9d1a2022-09-07 13:54:53 +0100346using NEBatchedMatMulFixture = GEMMValidationFixture<Tensor, Accessor, NEGEMM, T, true, false, false, false, false, true>;
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000347
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100348TEST_SUITE(Float)
Michele Di Giorgiocf9e29e2020-10-08 11:54:42 +0100349DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(framework::dataset::make("In0", { TensorShape(21U, 13U),
350 TensorShape(31U, 1U),
351 TensorShape(31U, 1U),
352 TensorShape(8U, 2U),
353 TensorShape(38U, 12U),
354 TensorShape(32U, 1U)
355 }),
356 framework::dataset::make("In1", { TensorShape(33U, 21U),
357 TensorShape(23U, 31U),
358 TensorShape(23U, 31U),
359 TensorShape(16U, 8U),
360 TensorShape(21U, 38U),
361 TensorShape(17U, 32U)
362 })),
363 shape0, shape1)
364{
365 bool status = validate_gemm_zero_padding(shape0, shape1);
366 ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS);
367}
368
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000369#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100370TEST_SUITE(FP16)
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000371FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(),
372 framework::dataset::make("ReshapeWeights", { true, false })),
373 framework::dataset::make("DataType", DataType::F16)))
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100374{
375 // Validate output
Gian Marco Iodicefbf3ecc2018-08-23 17:26:21 +0100376 validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16);
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100377}
Adnan AlSinan304dfdb2022-09-21 13:20:45 +0100378
379TEST_SUITE(BATCHED_MATMUL)
380
381FIXTURE_DATA_TEST_CASE(RunSmall, NEBatchedMatMulFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedMatMulDataset(),
382 framework::dataset::make("ReshapeWeights", { false })),
383 framework::dataset::make("DataType", DataType::F16)))
384{
385 // Validate output
386 validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16);
387}
388TEST_SUITE_END()
389
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000390FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(),
391 framework::dataset::make("ReshapeWeights", { true, false })),
392
393 framework::dataset::make("DataType", DataType::F16)))
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100394{
395 // Validate output
Gian Marco Iodicefbf3ecc2018-08-23 17:26:21 +0100396 validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16);
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100397}
398TEST_SUITE_END()
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000399#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100400
401TEST_SUITE(FP32)
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000402FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(),
403 framework::dataset::make("ReshapeWeights", { true, false })),
404
405 framework::dataset::make("DataType", DataType::F32)))
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100406{
407 // Validate output
408 validate(Accessor(_target), _reference, tolerance_f);
409}
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000410FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(),
411 framework::dataset::make("ReshapeWeights", { true, false })),
412
413 framework::dataset::make("DataType", DataType::F32)))
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100414{
415 // Validate output
416 validate(Accessor(_target), _reference, tolerance_f);
417}
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000418
Adnan AlSinan26c9d1a2022-09-07 13:54:53 +0100419TEST_SUITE(BATCHED_MATMUL)
420
421TEST_SUITE(FP32)
422FIXTURE_DATA_TEST_CASE(RunSmall, NEBatchedMatMulFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedMatMulDataset(),
423 framework::dataset::make("ReshapeWeights", { false })),
Pablo Tello0e37b5c2018-10-30 11:18:37 +0000424 framework::dataset::make("DataType", DataType::F32)))
425{
426 // Validate output
427 validate(Accessor(_target), _reference, tolerance_f);
428}
429TEST_SUITE_END()
430
Adnan AlSinan26c9d1a2022-09-07 13:54:53 +0100431TEST_SUITE_END()
Gian Marco Iodice37a46112021-08-04 15:22:28 +0100432
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100433TEST_SUITE_END()
434TEST_SUITE_END()
435
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +0100436TEST_SUITE_END()
437TEST_SUITE_END()
438} // namespace validation
439} // namespace test
440} // namespace arm_compute