Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 1 | /* |
Dana Zlotnik | 256ac62 | 2022-02-02 15:06:11 +0200 | [diff] [blame] | 2 | * Copyright (c) 2017-2022 Arm Limited. |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 3 | * |
| 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" |
| 25 | #include "arm_compute/runtime/NEON/functions/NEGEMM.h" |
| 26 | #include "arm_compute/runtime/Tensor.h" |
| 27 | #include "arm_compute/runtime/TensorAllocator.h" |
Michele Di Giorgio | 4dfc553 | 2021-06-30 12:05:34 +0100 | [diff] [blame] | 28 | #include "src/core/helpers/MemoryHelpers.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 29 | #include "src/cpu/kernels/CpuGemmInterleave4x4Kernel.h" |
| 30 | #include "src/cpu/kernels/CpuGemmMatrixMultiplyKernel.h" |
| 31 | #include "src/cpu/kernels/CpuGemmTranspose1xWKernel.h" |
| 32 | #include "src/cpu/operators/CpuGemm.h" |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 33 | #include "tests/NEON/Accessor.h" |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 34 | #include "tests/NEON/Helper.h" |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 35 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 36 | #include "tests/datasets/LargeGEMMDataset.h" |
| 37 | #include "tests/datasets/SmallGEMMDataset.h" |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 38 | #include "tests/datasets/TinyGEMMDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 39 | #include "tests/framework/Asserts.h" |
| 40 | #include "tests/framework/Macros.h" |
| 41 | #include "tests/framework/datasets/Datasets.h" |
| 42 | #include "tests/validation/Validation.h" |
| 43 | #include "tests/validation/fixtures/GEMMFixture.h" |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 44 | #include "tests/validation/fixtures/GEMMInterleave4x4Fixture.h" |
Pablo Tello | 088cc7f | 2017-12-07 15:20:55 +0000 | [diff] [blame] | 45 | #include "tests/validation/fixtures/GEMMTranspose1xWFixture.h" |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 46 | |
| 47 | namespace arm_compute |
| 48 | { |
| 49 | namespace test |
| 50 | { |
| 51 | namespace validation |
| 52 | { |
| 53 | namespace |
| 54 | { |
Gian Marco Iodice | fbf3ecc | 2018-08-23 17:26:21 +0100 | [diff] [blame] | 55 | constexpr AbsoluteTolerance<float> tolerance_f(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for FP32 data types */ |
| 56 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 57 | RelativeTolerance<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 */ |
| 58 | const AbsoluteTolerance<float> abs_tolerance_f16(0.2f); /**< Absolute tolerance value for comparing reference's output against implementation's output for FP16 data types */ |
| 59 | constexpr float tolerance_num = 0.07f; /**< Tolerance number for FP16 data types */ |
| 60 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 61 | /** CNN data types */ |
| 62 | const auto CNNDataTypes = framework::dataset::make("DataType", |
| 63 | { |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 64 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 65 | DataType::F16, |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 66 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 67 | DataType::F32, |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 68 | }); |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 69 | |
| 70 | const auto data_interleave = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12); |
Pablo Tello | 088cc7f | 2017-12-07 15:20:55 +0000 | [diff] [blame] | 71 | const auto data_transpose = framework::dataset::make("M", 8, 14) * framework::dataset::make("N", 7, 14); |
| 72 | |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 73 | /** Zero padding test */ |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 74 | template <typename FunctionType> |
| 75 | bool validate_zero_padding(unsigned int dim0_value, unsigned int dim1_value) |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 76 | { |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 77 | const TensorShape in_shape(dim0_value, dim1_value); |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 78 | TensorInfo in(in_shape, 1, DataType::U32); |
| 79 | TensorInfo dst; |
| 80 | |
| 81 | ARM_COMPUTE_EXPECT(in.is_resizable(), framework::LogLevel::ERRORS); |
| 82 | |
| 83 | // Validate zero-padding |
| 84 | FunctionType func; |
| 85 | |
| 86 | func.configure(&in, &dst); |
| 87 | |
| 88 | return in.padding().empty(); |
| 89 | } |
| 90 | |
Michele Di Giorgio | cf9e29e | 2020-10-08 11:54:42 +0100 | [diff] [blame] | 91 | /* Zero padding test for GEMM kernels */ |
| 92 | bool validate_gemm_zero_padding(const TensorShape shape0, const TensorShape shape1) |
| 93 | { |
| 94 | // Create tensors |
Michele Di Giorgio | 53832b2 | 2021-06-21 14:45:44 +0100 | [diff] [blame] | 95 | TensorInfo in0(shape0, 1, DataType::F32); |
| 96 | TensorInfo in1(shape1, 1, DataType::F32); |
| 97 | TensorInfo dst; |
Michele Di Giorgio | cf9e29e | 2020-10-08 11:54:42 +0100 | [diff] [blame] | 98 | |
| 99 | // Validate zero-padding |
Michele Di Giorgio | 53832b2 | 2021-06-21 14:45:44 +0100 | [diff] [blame] | 100 | cpu::kernels::CpuGemmMatrixMultiplyKernel gemm; |
Michele Di Giorgio | cf9e29e | 2020-10-08 11:54:42 +0100 | [diff] [blame] | 101 | gemm.configure(&in0, &in1, &dst, 1.0, false); |
| 102 | |
Michele Di Giorgio | 53832b2 | 2021-06-21 14:45:44 +0100 | [diff] [blame] | 103 | return in0.padding().empty() && in1.padding().empty() && dst.padding().empty(); |
Michele Di Giorgio | cf9e29e | 2020-10-08 11:54:42 +0100 | [diff] [blame] | 104 | } |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 105 | } // namespace |
| 106 | |
| 107 | TEST_SUITE(NEON) |
| 108 | TEST_SUITE(GEMM) |
| 109 | |
Michele Di Giorgio | 4dfc553 | 2021-06-30 12:05:34 +0100 | [diff] [blame] | 110 | /** Test case for memory injection in @ref cpu::CpuGemm. |
| 111 | * |
| 112 | * Configure the operator once and inject memory at run-time in multiple executions. |
| 113 | * |
| 114 | * Checks performed in order: |
| 115 | * - Both runs compute the same output |
| 116 | */ |
| 117 | TEST_CASE(MemoryInjection, framework::DatasetMode::ALL) |
| 118 | { |
| 119 | auto gemm = std::make_unique<cpu::CpuGemm>(); |
| 120 | const auto lhs_info = TensorInfo(TensorShape(3U, 3U), 1, DataType::F32); |
| 121 | const auto rhs_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32); |
| 122 | const auto c_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32); |
| 123 | auto dst_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32); |
| 124 | const auto gemm_info = GEMMInfo{}; |
| 125 | gemm->configure(&lhs_info, &rhs_info, &c_info, &dst_info, 1.f, 1.f, gemm_info); |
| 126 | |
| 127 | // telhs are newly created every call of this lambda function |
| 128 | auto lhs = create_tensor<Tensor>(lhs_info); |
| 129 | auto rhs = create_tensor<Tensor>(rhs_info); |
| 130 | auto c = create_tensor<Tensor>(c_info); |
| 131 | lhs.allocator()->allocate(); |
| 132 | rhs.allocator()->allocate(); |
| 133 | c.allocator()->allocate(); |
| 134 | |
| 135 | ITensorPack run_pack{ { TensorType::ACL_SRC_0, &lhs }, { TensorType::ACL_SRC_1, &rhs }, { TensorType::ACL_SRC_2, &c } }; |
| 136 | ITensorPack prep_pack{ { TensorType::ACL_SRC_1, &rhs }, { TensorType::ACL_SRC_2, &c } }; |
| 137 | |
| 138 | auto mg = MemoryGroup{}; |
| 139 | auto ws = manage_workspace<Tensor>(gemm->workspace(), mg, run_pack, prep_pack); |
| 140 | |
| 141 | auto run_conv = [&]() -> Tensor |
| 142 | { |
| 143 | auto dst = create_tensor<Tensor>(dst_info); |
| 144 | dst.allocator()->allocate(); |
| 145 | run_pack.add_tensor(TensorType::ACL_DST, &dst); |
| 146 | |
| 147 | library->fill_tensor_value(Accessor(lhs), 1.f); |
| 148 | library->fill_tensor_value(Accessor(rhs), 2.f); |
| 149 | library->fill_tensor_value(Accessor(c), 3.f); |
| 150 | // This operator is configured once and captured by this lambda. |
| 151 | gemm->prepare(prep_pack); |
| 152 | gemm->run(run_pack); |
| 153 | return dst; |
| 154 | }; |
| 155 | auto result_0 = run_conv(); |
| 156 | auto result_1 = run_conv(); |
| 157 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 158 | { |
| 159 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** Test case for memory injection in @ref NEGEMM. |
| 164 | * |
| 165 | * Make sure @ref NEGEMM still works through injecting the memory at configure time using the old API. |
| 166 | * |
| 167 | * Checks performed in order: |
| 168 | * - Both runs compute the same output |
| 169 | */ |
| 170 | TEST_CASE(MultipleExecutionWithConfigure, framework::DatasetMode::ALL) |
| 171 | { |
| 172 | auto gemm = std::make_unique<NEGEMM>(); |
| 173 | const auto lhs_info = TensorInfo(TensorShape(3U, 3U), 1, DataType::F32); |
| 174 | const auto rhs_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32); |
| 175 | const auto c_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32); |
| 176 | auto dst_info = TensorInfo(TensorShape(4U, 3U), 1, DataType::F32); |
| 177 | const auto gemm_info = GEMMInfo{}; |
| 178 | auto run_conv = [&]() |
| 179 | { |
| 180 | auto lhs = create_tensor<Tensor>(lhs_info); |
| 181 | auto rhs = create_tensor<Tensor>(rhs_info); |
| 182 | auto c = create_tensor<Tensor>(c_info); |
| 183 | auto dst = create_tensor<Tensor>(dst_info); |
| 184 | gemm->configure(&lhs, &rhs, &c, &dst, 1.f, 1.f, gemm_info); |
| 185 | lhs.allocator()->allocate(); |
| 186 | rhs.allocator()->allocate(); |
| 187 | c.allocator()->allocate(); |
| 188 | dst.allocator()->allocate(); |
| 189 | library->fill_tensor_value(Accessor(lhs), 1.f); |
| 190 | library->fill_tensor_value(Accessor(rhs), 2.f); |
| 191 | library->fill_tensor_value(Accessor(c), 3.f); |
| 192 | gemm->run(); |
| 193 | return dst; |
| 194 | }; |
| 195 | auto result_0 = run_conv(); |
| 196 | auto result_1 = run_conv(); |
| 197 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 198 | { |
| 199 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 200 | } |
| 201 | } |
| 202 | |
Dana Zlotnik | 256ac62 | 2022-02-02 15:06:11 +0200 | [diff] [blame] | 203 | TEST_SUITE(KERNEL_SELECTION) |
| 204 | DATA_TEST_CASE(KernelSelection_mul_and_add, framework::DatasetMode::ALL, |
| 205 | combine(framework::dataset::make("CpuExt", std::string("NEON")), |
| 206 | framework::dataset::make("DataType", { DataType::F32, |
| 207 | DataType::F16 |
| 208 | })), |
| 209 | cpu_ext, data_type) |
| 210 | { |
| 211 | using namespace cpu::kernels; |
| 212 | |
| 213 | cpuinfo::CpuIsaInfo cpu_isa{}; |
| 214 | cpu_isa.neon = (cpu_ext == "NEON"); |
| 215 | cpu_isa.fp16 = (data_type == DataType::F16); |
| 216 | |
| 217 | const auto *selected_impl_mul = CpuGemmMatrixMultiplyKernel::get_implementation(DataTypeISASelectorData{ data_type, cpu_isa }, cpu::KernelSelectionType::Preferred); |
| 218 | |
| 219 | ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl_mul); |
| 220 | |
| 221 | std::string expected = lower_string(cpu_ext) + "_" + cpu_impl_dt(data_type) + "_gemm_matrix_mul"; |
| 222 | std::string actual = selected_impl_mul->name; |
| 223 | |
| 224 | ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS); |
| 225 | |
| 226 | const auto *selected_impl_add = CpuGemmMatrixAdditionKernel::get_implementation(DataTypeISASelectorData{ data_type, cpu_isa }, cpu::KernelSelectionType::Preferred); |
| 227 | |
| 228 | ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl_add); |
| 229 | |
| 230 | expected = lower_string(cpu_ext) + "_" + cpu_impl_dt(data_type) + "_gemm_matrix_add"; |
| 231 | actual = selected_impl_add->name; |
| 232 | |
| 233 | ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS); |
| 234 | } |
| 235 | TEST_SUITE_END() // KERNEL_SELECTION |
| 236 | |
Pablo Tello | 088cc7f | 2017-12-07 15:20:55 +0000 | [diff] [blame] | 237 | TEST_SUITE(TRANSPOSE_1XW) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 238 | using CpuGemmTranspose1xW = NESynthetizeFunctionWithZeroConstantKernelBorder<cpu::kernels::CpuGemmTranspose1xWKernel>; |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 239 | DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip( |
| 240 | framework::dataset::make("N", { 1, 23, 63, 101 }), |
| 241 | framework::dataset::make("K", { 1, 47, 29, 27 })), |
| 242 | n_value, k_value) |
| 243 | { |
Michele Di Giorgio | 4dfc553 | 2021-06-30 12:05:34 +0100 | [diff] [blame] | 244 | bool status = validate_zero_padding<CpuGemmTranspose1xW>(n_value, k_value); |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 245 | ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS); |
| 246 | } |
| 247 | |
| 248 | TEST_SUITE(U32) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 249 | using CpuGemmTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, CpuGemmTranspose1xW, uint32_t>; |
| 250 | FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::U32)) |
Pablo Tello | 088cc7f | 2017-12-07 15:20:55 +0000 | [diff] [blame] | 251 | { |
| 252 | // Validate output |
| 253 | validate(Accessor(_target), _reference); |
| 254 | } |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 255 | TEST_SUITE_END() // U32 |
| 256 | |
| 257 | TEST_SUITE(U16) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 258 | using CpuGemmTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, CpuGemmTranspose1xW, uint16_t>; |
| 259 | FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::U16)) |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 260 | { |
| 261 | // Validate output |
| 262 | validate(Accessor(_target), _reference); |
| 263 | } |
| 264 | TEST_SUITE_END() // U16 |
| 265 | |
| 266 | TEST_SUITE(U8) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 267 | using CpuGemmTranspose1xWFixture = GEMMTranspose1xWValidationFixture<Tensor, Accessor, CpuGemmTranspose1xW, uint8_t>; |
| 268 | FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmTranspose1xWFixture, framework::DatasetMode::PRECOMMIT, data_transpose * framework::dataset::make("DataType", DataType::U8)) |
Gian Marco Iodice | b3182b1 | 2020-09-04 08:44:52 +0100 | [diff] [blame] | 269 | { |
| 270 | // Validate output |
| 271 | validate(Accessor(_target), _reference); |
| 272 | } |
| 273 | TEST_SUITE_END() // U8 |
Pablo Tello | 088cc7f | 2017-12-07 15:20:55 +0000 | [diff] [blame] | 274 | |
Pablo Tello | 088cc7f | 2017-12-07 15:20:55 +0000 | [diff] [blame] | 275 | TEST_SUITE_END() // TRANSPOSE_1XW |
| 276 | |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 277 | TEST_SUITE(INTERLEAVE_4X4) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 278 | using CpuGemmInterleave4x4 = NESynthetizeFunctionWithZeroConstantKernelBorder<cpu::kernels::CpuGemmInterleave4x4Kernel>; |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 279 | |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 280 | DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip( |
| 281 | framework::dataset::make("M", { 1, 23, 63, 101 }), |
| 282 | framework::dataset::make("K", { 1, 47, 29, 27 })), |
| 283 | m_value, k_value) |
| 284 | { |
Michele Di Giorgio | 4dfc553 | 2021-06-30 12:05:34 +0100 | [diff] [blame] | 285 | bool status = validate_zero_padding<cpu::kernels::CpuGemmInterleave4x4Kernel>(m_value, k_value); |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 286 | ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS); |
| 287 | } |
| 288 | |
| 289 | TEST_SUITE(U32) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 290 | using CpuGemmInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, CpuGemmInterleave4x4, uint32_t>; |
| 291 | FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::U32)) |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 292 | { |
| 293 | // Validate output |
| 294 | validate(Accessor(_target), _reference); |
| 295 | } |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 296 | TEST_SUITE_END() // U32 |
| 297 | |
| 298 | TEST_SUITE(U16) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 299 | using CpuGemmInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, CpuGemmInterleave4x4, uint16_t>; |
| 300 | FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::U16)) |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 301 | { |
| 302 | // Validate output |
| 303 | validate(Accessor(_target), _reference); |
| 304 | } |
| 305 | TEST_SUITE_END() // U16 |
| 306 | |
| 307 | TEST_SUITE(U8) |
Michele Di Giorgio | 93b75e0 | 2021-06-21 12:00:43 +0100 | [diff] [blame] | 308 | using CpuGemmInterleave4x4Fixture = GEMMInterleave4x4ValidationFixture<Tensor, Accessor, CpuGemmInterleave4x4, uint8_t>; |
| 309 | FIXTURE_DATA_TEST_CASE(RunSmall, CpuGemmInterleave4x4Fixture, framework::DatasetMode::PRECOMMIT, data_interleave * framework::dataset::make("DataType", DataType::QASYMM8)) |
Gian Marco Iodice | feaea10 | 2020-09-03 13:20:34 +0100 | [diff] [blame] | 310 | { |
| 311 | // Validate output |
| 312 | validate(Accessor(_target), _reference); |
| 313 | } |
| 314 | TEST_SUITE_END() // U8 |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 315 | |
Pablo Tello | 2fdc409 | 2017-11-23 15:50:08 +0000 | [diff] [blame] | 316 | TEST_SUITE_END() // INTERLEAVE_4X4 |
| 317 | |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 318 | template <typename T> |
| 319 | using NEGEMMFixture = GEMMValidationFixture<Tensor, Accessor, NEGEMM, T>; |
| 320 | |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 321 | template <typename T> |
Adnan AlSinan | 26c9d1a | 2022-09-07 13:54:53 +0100 | [diff] [blame] | 322 | using NEBatchedMatMulFixture = GEMMValidationFixture<Tensor, Accessor, NEGEMM, T, true, false, false, false, false, true>; |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 323 | |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 324 | TEST_SUITE(Float) |
Michele Di Giorgio | cf9e29e | 2020-10-08 11:54:42 +0100 | [diff] [blame] | 325 | DATA_TEST_CASE(ValidateZeroPadding, framework::DatasetMode::ALL, zip(framework::dataset::make("In0", { TensorShape(21U, 13U), |
| 326 | TensorShape(31U, 1U), |
| 327 | TensorShape(31U, 1U), |
| 328 | TensorShape(8U, 2U), |
| 329 | TensorShape(38U, 12U), |
| 330 | TensorShape(32U, 1U) |
| 331 | }), |
| 332 | framework::dataset::make("In1", { TensorShape(33U, 21U), |
| 333 | TensorShape(23U, 31U), |
| 334 | TensorShape(23U, 31U), |
| 335 | TensorShape(16U, 8U), |
| 336 | TensorShape(21U, 38U), |
| 337 | TensorShape(17U, 32U) |
| 338 | })), |
| 339 | shape0, shape1) |
| 340 | { |
| 341 | bool status = validate_gemm_zero_padding(shape0, shape1); |
| 342 | ARM_COMPUTE_EXPECT(status, framework::LogLevel::ERRORS); |
| 343 | } |
| 344 | |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 345 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 346 | TEST_SUITE(FP16) |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 347 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), |
| 348 | framework::dataset::make("ReshapeWeights", { true, false })), |
| 349 | framework::dataset::make("DataType", DataType::F16))) |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 350 | { |
| 351 | // Validate output |
Gian Marco Iodice | fbf3ecc | 2018-08-23 17:26:21 +0100 | [diff] [blame] | 352 | validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 353 | } |
Adnan AlSinan | 304dfdb | 2022-09-21 13:20:45 +0100 | [diff] [blame] | 354 | |
| 355 | TEST_SUITE(BATCHED_MATMUL) |
| 356 | |
| 357 | FIXTURE_DATA_TEST_CASE(RunSmall, NEBatchedMatMulFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedMatMulDataset(), |
| 358 | framework::dataset::make("ReshapeWeights", { false })), |
| 359 | framework::dataset::make("DataType", DataType::F16))) |
| 360 | { |
| 361 | // Validate output |
| 362 | validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); |
| 363 | } |
| 364 | TEST_SUITE_END() |
| 365 | |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 366 | FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), |
| 367 | framework::dataset::make("ReshapeWeights", { true, false })), |
| 368 | |
| 369 | framework::dataset::make("DataType", DataType::F16))) |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 370 | { |
| 371 | // Validate output |
Gian Marco Iodice | fbf3ecc | 2018-08-23 17:26:21 +0100 | [diff] [blame] | 372 | validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 373 | } |
| 374 | TEST_SUITE_END() |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 375 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 376 | |
| 377 | TEST_SUITE(FP32) |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 378 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), |
| 379 | framework::dataset::make("ReshapeWeights", { true, false })), |
| 380 | |
| 381 | framework::dataset::make("DataType", DataType::F32))) |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 382 | { |
| 383 | // Validate output |
| 384 | validate(Accessor(_target), _reference, tolerance_f); |
| 385 | } |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 386 | FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), |
| 387 | framework::dataset::make("ReshapeWeights", { true, false })), |
| 388 | |
| 389 | framework::dataset::make("DataType", DataType::F32))) |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 390 | { |
| 391 | // Validate output |
| 392 | validate(Accessor(_target), _reference, tolerance_f); |
| 393 | } |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 394 | |
Adnan AlSinan | 26c9d1a | 2022-09-07 13:54:53 +0100 | [diff] [blame] | 395 | TEST_SUITE(BATCHED_MATMUL) |
| 396 | |
| 397 | TEST_SUITE(FP32) |
| 398 | FIXTURE_DATA_TEST_CASE(RunSmall, NEBatchedMatMulFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallBatchedMatMulDataset(), |
| 399 | framework::dataset::make("ReshapeWeights", { false })), |
Pablo Tello | 0e37b5c | 2018-10-30 11:18:37 +0000 | [diff] [blame] | 400 | framework::dataset::make("DataType", DataType::F32))) |
| 401 | { |
| 402 | // Validate output |
| 403 | validate(Accessor(_target), _reference, tolerance_f); |
| 404 | } |
| 405 | TEST_SUITE_END() |
| 406 | |
Adnan AlSinan | 26c9d1a | 2022-09-07 13:54:53 +0100 | [diff] [blame] | 407 | TEST_SUITE_END() |
Gian Marco Iodice | 37a4611 | 2021-08-04 15:22:28 +0100 | [diff] [blame] | 408 | |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 409 | TEST_SUITE_END() |
| 410 | TEST_SUITE_END() |
| 411 | |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 412 | TEST_SUITE_END() |
| 413 | TEST_SUITE_END() |
| 414 | } // namespace validation |
| 415 | } // namespace test |
| 416 | } // namespace arm_compute |