Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1 | /* |
Mohammed Suhail Munshi | 8050d22 | 2024-02-04 17:55:40 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2024 Arm Limited. |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +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/NEConvolutionLayer.h" |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 26 | #include "arm_compute/runtime/NEON/functions/NEGEMMConv2d.h" |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 27 | #include "arm_compute/runtime/NEON/functions/NEGEMMConvolutionLayer.h" |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 28 | #include "arm_compute/runtime/NEON/functions/NEWinogradConvolutionLayer.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 29 | #include "arm_compute/runtime/Tensor.h" |
| 30 | #include "arm_compute/runtime/TensorAllocator.h" |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 31 | |
| 32 | #include "src/core/CPP/Validate.h" |
Michele Di Giorgio | d7316eb | 2021-06-16 11:14:41 +0100 | [diff] [blame] | 33 | #include "src/core/helpers/MemoryHelpers.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 34 | #include "src/cpu/operators/CpuGemmConv2d.h" |
| 35 | #include "src/cpu/operators/CpuGemmDirectConv2d.h" |
| 36 | #include "src/cpu/operators/CpuWinogradConv2d.h" |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 37 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 38 | #include "tests/NEON/Accessor.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 39 | #include "tests/datasets/LargeConvolutionLayerDataset.h" |
| 40 | #include "tests/datasets/SmallConvolutionLayerDataset.h" |
| 41 | #include "tests/framework/Asserts.h" |
| 42 | #include "tests/framework/Macros.h" |
| 43 | #include "tests/framework/datasets/Datasets.h" |
| 44 | #include "tests/validation/Validation.h" |
| 45 | #include "tests/validation/fixtures/ConvolutionLayerFixture.h" |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 46 | #include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 47 | |
| 48 | namespace arm_compute |
| 49 | { |
| 50 | namespace test |
| 51 | { |
| 52 | namespace validation |
| 53 | { |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 54 | using framework::dataset::make; |
| 55 | |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 56 | namespace detail |
| 57 | { |
| 58 | template <> |
| 59 | void configure_conv_function<NEGEMMConv2d, Tensor>(NEGEMMConv2d &func, |
| 60 | Tensor *src, const Tensor *weights, const Tensor *bias, Tensor *dst, |
| 61 | const PadStrideInfo &info, const WeightsInfo &weights_info, |
| 62 | const Size2D &dilation, const ActivationLayerInfo &act_info, unsigned int num_groups) |
| 63 | { |
| 64 | ARM_COMPUTE_UNUSED(weights_info); |
| 65 | |
| 66 | Conv2dInfo conv_info(info, dilation, act_info, false, num_groups); |
| 67 | func.configure(src, weights, bias, dst, conv_info); |
| 68 | } |
| 69 | } // namespace detail |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 70 | namespace |
| 71 | { |
Pablo Tello | af7e600 | 2018-10-08 15:53:14 +0100 | [diff] [blame] | 72 | const RelativeTolerance<float> rel_tolerance_f32(0.01f); /**< Relative tolerance for FP32 types */ |
| 73 | const RelativeTolerance<float> rel_tolerance_winograd_3x3_f32(0.05f); /**< Relative tolerance for FP32 types */ |
| 74 | const AbsoluteTolerance<float> abs_tolerance_f32(0.002f); /**< Absolute tolerance for FP32 types */ |
| 75 | const AbsoluteTolerance<float> abs_tolerance_1xN_f32(0.0041f); /**< Absolute tolerance for FP32 types */ |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 76 | |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 77 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Georgios Pinitas | 5ce897f | 2020-04-29 11:44:10 +0100 | [diff] [blame] | 78 | const AbsoluteTolerance<half> tolerance_convolution_layer_f16(half(0.4f)); |
| 79 | constexpr float tolerance_num_f16 = 0.15f; |
| 80 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 81 | |
| 82 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Gian Marco Iodice | 41acb76 | 2018-08-23 10:25:06 +0100 | [diff] [blame] | 83 | const RelativeTolerance<half_float::half> rel_tolerance_f16(half_float::half(0.2f)); /**< Relative tolerance value for FP16 types */ |
| 84 | const AbsoluteTolerance<float> abs_tolerance_f16(0.2f); /**< Absolute tolerance for FP16 types */ |
| 85 | constexpr float tolerance_num = 0.07f; /**< Tolerance number for the FP16 implementation */ |
| 86 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Viet-Hoa Do | 4e84f24 | 2023-04-06 14:48:58 +0100 | [diff] [blame] | 87 | |
| 88 | #ifdef ARM_COMPUTE_ENABLE_SME |
| 89 | // TODO(COMPMID-6011): SME kernels and the reference model use different rounding mode. |
| 90 | // Temporarily increase the tolerance for quantized data. |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 91 | constexpr AbsoluteTolerance<float> tolerance_qasymm8(1.0); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */ |
| 92 | #else // ARM_COMPUTE_ENABLE_SME |
| 93 | constexpr AbsoluteTolerance<float> tolerance_qasymm8(0.0); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */ |
| 94 | #endif // ARM_COMPUTE_ENABLE_SME |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 95 | |
| 96 | /** CNN data types */ |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 97 | const auto CNNDataTypes = make("DataType", |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 98 | { |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 99 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 100 | DataType::F16, |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 101 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 102 | DataType::F32, |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 103 | DataType::QASYMM8, |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 104 | }); |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 105 | const auto ActivationFunctionsDataset = make("ActivationInfo", |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 106 | { |
| 107 | ActivationLayerInfo(), |
| 108 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 109 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f) |
| 110 | }); |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 111 | |
Gunes Bayir | 9167c9c | 2024-03-06 09:58:40 +0000 | [diff] [blame] | 112 | const auto NoActivation = make("ActivationInfo", |
| 113 | { |
| 114 | ActivationLayerInfo(), |
| 115 | }); |
| 116 | |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 117 | const auto ActivationFunctionsDatasetNightly = make("ActivationInfo", |
| 118 | { |
| 119 | ActivationLayerInfo(), |
| 120 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 121 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f), |
| 122 | |
| 123 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f, -0.5f), |
| 124 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LEAKY_RELU, 0.1f), |
| 125 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SOFT_RELU), |
| 126 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ELU), |
| 127 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS), |
| 128 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), |
| 129 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), |
| 130 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQUARE), |
| 131 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SWISH), |
| 132 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::HARD_SWISH), |
| 133 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LINEAR, 2.f, 1.f), |
| 134 | #ifdef __aarch64__ |
| 135 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::GELU), |
| 136 | #endif // __aarch64__ |
| 137 | }); |
| 138 | |
| 139 | const auto QuantizationData = make("QuantizationInfo", |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 140 | { |
| 141 | QuantizationInfo(0.5f, 10), |
| 142 | QuantizationInfo(0.3f, 3), |
| 143 | QuantizationInfo(1.f, 10), |
Michele Di Giorgio | f29d1b7 | 2019-10-29 10:58:13 +0000 | [diff] [blame] | 144 | QuantizationInfo(1.1f, 10), |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 145 | }); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 146 | } // namespace |
| 147 | |
| 148 | TEST_SUITE(NEON) |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 149 | TEST_SUITE(ConvolutionLayer) |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 150 | |
| 151 | // *INDENT-OFF* |
| 152 | // clang-format off |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 153 | DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 154 | make("InputInfo", { TensorInfo(TensorShape(18U, 18U, 32U), 1, DataType::F32), |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 155 | TensorInfo(TensorShape(23U, 27U, 32U, 4U), 1, DataType::F32), |
| 156 | TensorInfo(TensorShape(3U, 3U, 2U, 1U), 1, DataType::F32), |
| 157 | TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) |
| 158 | }), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 159 | make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 32U, 21U), 1, DataType::F32), |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 160 | TensorInfo(TensorShape(5U, 5U, 32U, 21U), 1, DataType::F32), |
| 161 | TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32), |
| 162 | TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16) |
| 163 | })), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 164 | make("OutputInfo", { TensorInfo(TensorShape(16U, 16U, 21U), 1, DataType::F32), |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 165 | TensorInfo(TensorShape(19U, 23U, 21U, 4U), 1, DataType::F32), |
| 166 | TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), |
| 167 | TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32) |
| 168 | })), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 169 | make("ConvInfo", { PadStrideInfo(1, 1, 0, 0), |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 170 | PadStrideInfo(1, 1, 0, 0), |
| 171 | PadStrideInfo(2, 1, 0, 0), |
| 172 | PadStrideInfo(3, 2, 1, 0) |
| 173 | })), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 174 | make("FastMath", { true, |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 175 | true, |
| 176 | false, |
| 177 | false |
| 178 | })), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 179 | make("Expected", { ConvolutionMethod::WINOGRAD, ConvolutionMethod::WINOGRAD, ConvolutionMethod::GEMM, ConvolutionMethod::GEMM })), |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 180 | input_info, weights_info, output_info, conv_info, fast_math, expected) |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 181 | { |
Michele Di Giorgio | a0efe69 | 2021-07-30 10:25:59 +0100 | [diff] [blame] | 182 | ConvolutionMethod is_valid = NEConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true), |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 183 | &weights_info.clone()->set_is_resizable(true), |
| 184 | &output_info.clone()->set_is_resizable(true), conv_info, WeightsInfo(), Size2D(1U, 1U), ActivationLayerInfo(), fast_math); |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 185 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
| 186 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 187 | // clang-format on |
| 188 | // *INDENT-ON* |
| 189 | TEST_SUITE_END() // ConvolutionLayer |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 190 | |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 191 | /* |
| 192 | Testing Strategy of Neon Winograd: |
| 193 | - There is no need to thoroughly test nchw cases because winograd kernels accept |
| 194 | nhwc and the tensors are permuted before and after if they're nchw. |
| 195 | - Except relu and bounded relu, testing activations for a single input |
| 196 | combination is enough because activation is not fused into winograd and called |
| 197 | separately. |
| 198 | */ |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 199 | TEST_SUITE(WinogradLayer) |
| 200 | template <typename T> |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 201 | using NEWinogradConvolutionLayerFixture = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, T>; |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 202 | template <typename T> |
| 203 | using NEWinogradConvolutionLayerMixedDataLayoutFixture = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, T, T, true, true>; |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 204 | |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 205 | template <typename T> |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 206 | using NEWinogradConvolutionLayerNoBiasFixture = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, T, T, false>; |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 207 | |
Michalis Spyrou | 96f977e | 2021-07-01 12:20:56 +0100 | [diff] [blame] | 208 | /** Test case for memory injection in @ref cpu::CpuWinogradConv2d. |
| 209 | * |
| 210 | * Configure the operator once and inject memory at run-time in multiple executions. |
| 211 | * |
| 212 | * Checks performed in order: |
| 213 | * - Both runs compute the same output |
| 214 | */ |
| 215 | TEST_CASE(MemoryInjection, framework::DatasetMode::ALL) |
| 216 | { |
| 217 | auto winograd = std::make_unique<cpu::CpuWinogradConv2d>(); |
| 218 | const auto src_info = TensorInfo(TensorShape(8U, 8U, 32U), 1, DataType::F32); |
| 219 | const auto w_info = TensorInfo(TensorShape(1U), 1, DataType::F32); |
| 220 | const auto b_info = TensorInfo(TensorShape(1U, 3U, 32U, 1U), 1, DataType::F32); |
| 221 | auto dst_info = TensorInfo(TensorShape(8U, 6U, 1U), 1, DataType::F32); |
| 222 | const PadStrideInfo pad_info{}; |
| 223 | |
| 224 | winograd->configure(&src_info, &b_info, &w_info, &dst_info, pad_info); |
| 225 | |
| 226 | // telhs are newly created every call of this lambda function |
| 227 | auto a = create_tensor<Tensor>(src_info); |
| 228 | auto b = create_tensor<Tensor>(b_info); |
| 229 | auto c = create_tensor<Tensor>(w_info); |
| 230 | a.allocator()->allocate(); |
| 231 | b.allocator()->allocate(); |
| 232 | c.allocator()->allocate(); |
| 233 | |
| 234 | ITensorPack run_pack{ { TensorType::ACL_SRC_0, &a }, { TensorType::ACL_SRC_1, &b }, { TensorType::ACL_SRC_2, &c } }; |
| 235 | ITensorPack prep_pack{ { TensorType::ACL_SRC_1, &b }, { TensorType::ACL_SRC_2, &c } }; |
| 236 | |
| 237 | auto mg = MemoryGroup{}; |
| 238 | auto ws = manage_workspace<Tensor>(winograd->workspace(), mg, run_pack, prep_pack); |
| 239 | auto run_conv = [&]() -> Tensor |
| 240 | { |
| 241 | auto dst = create_tensor<Tensor>(dst_info); |
| 242 | dst.allocator()->allocate(); |
| 243 | |
| 244 | run_pack.add_tensor(TensorType::ACL_DST, &dst); |
| 245 | library->fill_tensor_value(Accessor(a), 1.f); |
| 246 | library->fill_tensor_value(Accessor(b), 2.f); |
| 247 | library->fill_tensor_value(Accessor(c), 3.f); |
| 248 | |
| 249 | // This operator is configured once and captured by this lambda. |
| 250 | winograd->prepare(prep_pack); |
| 251 | winograd->run(run_pack); |
| 252 | return dst; |
| 253 | }; |
| 254 | |
| 255 | auto result_0 = run_conv(); |
| 256 | auto result_1 = run_conv(); |
| 257 | |
| 258 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 259 | { |
| 260 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /** Test case for memory injection in @ref NEWinogradConvolutionLayer. |
| 265 | * |
| 266 | * Make sure @ref NEWinogradConvolutionLayer still works through injecting the memory at configure time using the old API. |
| 267 | * |
| 268 | * Checks performed in order: |
| 269 | * - Both runs compute the same output |
| 270 | */ |
| 271 | TEST_CASE(MultipleExecutionWithConfigure, framework::DatasetMode::ALL) |
| 272 | { |
| 273 | auto gemm = std::make_unique<NEWinogradConvolutionLayer>(); |
| 274 | const auto src_info = TensorInfo(TensorShape(8U, 8U, 32U), 1, DataType::F32); |
| 275 | const auto w_info = TensorInfo(TensorShape(1U), 1, DataType::F32); |
| 276 | const auto b_info = TensorInfo(TensorShape(1U, 3U, 32U, 1U), 1, DataType::F32); |
| 277 | auto dst_info = TensorInfo(TensorShape(8U, 6U, 1U), 1, DataType::F32); |
| 278 | const PadStrideInfo pad_info{}; |
| 279 | |
| 280 | auto run_conv = [&]() |
| 281 | { |
| 282 | auto src = create_tensor<Tensor>(src_info); |
| 283 | auto w = create_tensor<Tensor>(w_info); |
| 284 | auto b = create_tensor<Tensor>(b_info); |
| 285 | auto dst = create_tensor<Tensor>(dst_info); |
| 286 | |
| 287 | gemm->configure(&src, &b, &w, &dst, pad_info); |
| 288 | |
| 289 | src.allocator()->allocate(); |
| 290 | b.allocator()->allocate(); |
| 291 | w.allocator()->allocate(); |
| 292 | dst.allocator()->allocate(); |
| 293 | |
| 294 | library->fill_tensor_value(Accessor(src), 1.f); |
| 295 | library->fill_tensor_value(Accessor(b), 2.f); |
| 296 | library->fill_tensor_value(Accessor(w), 3.f); |
| 297 | gemm->run(); |
| 298 | return dst; |
| 299 | }; |
| 300 | |
| 301 | auto result_0 = run_conv(); |
| 302 | auto result_1 = run_conv(); |
| 303 | |
| 304 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 305 | { |
| 306 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 307 | } |
| 308 | } |
| 309 | |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 310 | DATA_TEST_CASE(SupportedKernels, framework::DatasetMode::ALL, zip( |
| 311 | make("WeightsInfo", |
| 312 | { |
| 313 | // Shapes are always in NCHW format. When layout is NHWC, the shape is permuted |
| 314 | |
| 315 | // Fp32, NCHW/NHWC (layout does not matter as it's ) |
| 316 | // 3x1, 1x3, 3x3 --> all TRUE |
| 317 | TensorInfo(TensorShape(3U, 3U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 318 | TensorInfo(TensorShape(1U, 3U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 319 | TensorInfo(TensorShape(3U, 1U, 2U, 8U), 1, DataType::F32, DataLayout::NCHW), |
| 320 | |
| 321 | // 5x1, 1x5, 5x5 --> all TRUE |
| 322 | TensorInfo(TensorShape(5U, 5U, 2U, 8U), 1, DataType::F32, DataLayout::NCHW), |
| 323 | TensorInfo(TensorShape(1U, 5U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 324 | TensorInfo(TensorShape(5U, 1U, 2U, 8U), 1, DataType::F32, DataLayout::NCHW), |
| 325 | |
| 326 | // 7x1, 1x7, 7x7 |
| 327 | // --> all FALSE |
| 328 | TensorInfo(TensorShape(7U, 7U, 2U, 8U), 1, DataType::F32, DataLayout::NCHW), |
| 329 | TensorInfo(TensorShape(1U, 7U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 330 | TensorInfo(TensorShape(7U, 1U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 331 | |
| 332 | // unsupported kernel sizes |
| 333 | TensorInfo(TensorShape(2U, 2U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 334 | TensorInfo(TensorShape(5U, 2U, 2U, 8U), 1, DataType::F32, DataLayout::NHWC), |
| 335 | TensorInfo(TensorShape(3U, 6U, 2U, 8U), 1, DataType::F32, DataLayout::NCHW), |
| 336 | |
| 337 | // Fp16 |
| 338 | TensorInfo(TensorShape(3U, 3U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 339 | TensorInfo(TensorShape(1U, 3U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 340 | TensorInfo(TensorShape(3U, 1U, 2U, 8U), 1, DataType::F16, DataLayout::NCHW), |
| 341 | |
| 342 | // 5x1, 1x5, 5x5 --> all TRUE |
| 343 | TensorInfo(TensorShape(5U, 5U, 2U, 8U), 1, DataType::F16, DataLayout::NCHW), |
| 344 | TensorInfo(TensorShape(1U, 5U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 345 | TensorInfo(TensorShape(5U, 1U, 2U, 8U), 1, DataType::F16, DataLayout::NCHW), |
| 346 | |
| 347 | // 7x1, 1x7, 7x7 |
| 348 | // --> all FALSE |
| 349 | TensorInfo(TensorShape(7U, 7U, 2U, 8U), 1, DataType::F16, DataLayout::NCHW), |
| 350 | TensorInfo(TensorShape(1U, 7U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 351 | TensorInfo(TensorShape(7U, 1U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 352 | |
| 353 | // unsupported kernel sizes |
| 354 | TensorInfo(TensorShape(2U, 2U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 355 | TensorInfo(TensorShape(5U, 2U, 2U, 8U), 1, DataType::F16, DataLayout::NHWC), |
| 356 | TensorInfo(TensorShape(3U, 6U, 2U, 8U), 1, DataType::F16, DataLayout::NCHW), |
| 357 | |
| 358 | }), |
| 359 | make("Expected", |
| 360 | { |
| 361 | // fp32 |
| 362 | true, true, true, // 3x3, 1x3, 3x1 |
| 363 | true, true, true, // 5x5, 1x5, 5x1 |
| 364 | false, true, true, // 7x7, 1x7, 7x1 |
| 365 | false, false, false, // random unsupported kernels |
| 366 | |
| 367 | // fp16 |
| 368 | true, false, false, // 3x3, 1x3, 3x1 |
| 369 | false, false, false, // 5x5, 1x5, 5x1 |
| 370 | false, false, false, // 7x7, 1x7, 7x1 |
| 371 | false, false, false, // random unsupported kernels |
| 372 | })), |
| 373 | weights_info_const, expected_const) |
| 374 | { |
| 375 | DataType data_type = weights_info_const.data_type(); |
| 376 | DataLayout data_layout = weights_info_const.data_layout(); |
| 377 | |
| 378 | TensorInfo input_info = TensorInfo(TensorShape(17U, 31U, 2U), 1, data_type); |
| 379 | TensorInfo bias_info = TensorInfo(TensorShape(8U), 1, data_type); |
| 380 | TensorInfo weights_info = weights_info_const; |
| 381 | |
| 382 | if(data_layout == DataLayout::NHWC) |
| 383 | { |
| 384 | // Convert to NHWC |
| 385 | PermutationVector perm = PermutationVector(2U, 0U, 1U); |
| 386 | |
| 387 | TensorShape input_shape = input_info.tensor_shape(); |
| 388 | TensorShape weights_shape = weights_info.tensor_shape(); |
| 389 | permute(input_shape, perm); |
| 390 | permute(weights_shape, perm); |
| 391 | |
| 392 | input_info.set_tensor_shape(input_shape); |
| 393 | weights_info.set_tensor_shape(weights_shape); |
| 394 | |
| 395 | input_info.set_data_layout(data_layout); |
| 396 | weights_info.set_data_layout(data_layout); |
| 397 | bias_info.set_data_layout(data_layout); |
| 398 | } |
| 399 | |
| 400 | PadStrideInfo conv_info(1, 1, 0, 0); |
| 401 | |
| 402 | TensorShape output_shape = compute_deep_convolution_shape(input_info, weights_info, conv_info); |
| 403 | TensorInfo output_info = TensorInfo(output_shape, 1, data_type, data_layout); |
| 404 | |
| 405 | Status status = NEWinogradConvolutionLayer::validate( |
| 406 | &input_info, |
| 407 | &weights_info, |
| 408 | &bias_info, |
| 409 | &output_info, |
| 410 | conv_info, |
| 411 | ActivationLayerInfo(), |
| 412 | true /* fast math */); |
| 413 | |
| 414 | Status fp16_supported = ::arm_compute::error_on_unsupported_cpu_fp16("N/A", "N/A", 0, &input_info); |
| 415 | bool expected = expected_const && static_cast<bool>(fp16_supported); |
| 416 | |
| 417 | ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS); |
| 418 | } |
| 419 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 420 | TEST_SUITE(FP32) |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 421 | |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 422 | TEST_SUITE(Conv1x3) |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 423 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 424 | combine(datasets::SmallWinogradConvolutionLayer1x3Dataset(), |
| 425 | make("DataType", { DataType::F32 }), |
| 426 | ActivationFunctionsDataset, |
| 427 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 428 | { |
| 429 | // Validate output |
| 430 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 431 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 432 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, NEWinogradConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 433 | combine( |
| 434 | make("Input", TensorShape(8U, 8U, 32U)), |
| 435 | make("Weight", TensorShape(1U, 3U, 32U, 1U)), |
| 436 | make("Bias", TensorShape(1U)), |
| 437 | make("Output", TensorShape(8U, 6U, 1U)), |
| 438 | make("PadStrideInfo", PadStrideInfo(1, 1, 0, 0)), |
| 439 | make("Dilation", Size2D(1U, 1U)), |
| 440 | make("DataType", { DataType::F32 }), |
| 441 | ActivationFunctionsDataset, |
| 442 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 443 | { |
| 444 | // Validate output |
| 445 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 446 | } |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 447 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 448 | combine(datasets::LargeWinogradConvolutionLayer1x3Dataset(), |
| 449 | make("DataType", { DataType::F32 }), |
| 450 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 451 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 452 | { |
| 453 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 454 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | TEST_SUITE_END() // Conv1x3 |
| 458 | |
| 459 | TEST_SUITE(Conv3x1) |
| 460 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 461 | combine(datasets::SmallWinogradConvolutionLayer3x1Dataset(), |
| 462 | make("DataType", { DataType::F32 }), |
| 463 | ActivationFunctionsDataset, |
| 464 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 465 | { |
| 466 | // Validate output |
| 467 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 468 | } |
| 469 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 470 | combine(datasets::LargeWinogradConvolutionLayer3x1Dataset(), |
| 471 | make("DataType", { DataType::F32 }), |
| 472 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 473 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 474 | { |
| 475 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 476 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | TEST_SUITE_END() // Conv3x1 |
| 480 | |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 481 | TEST_SUITE(Conv1x5) |
| 482 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 483 | combine(datasets::SmallWinogradConvolutionLayer1x5Dataset(), |
| 484 | make("DataType", { DataType::F32 }), |
| 485 | ActivationFunctionsDataset, |
| 486 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 487 | { |
| 488 | // Validate output |
| 489 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 490 | } |
| 491 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 492 | combine(datasets::LargeWinogradConvolutionLayer1x5Dataset(), |
| 493 | make("DataType", { DataType::F32 }), |
| 494 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 495 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 496 | { |
| 497 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 498 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | TEST_SUITE_END() // Conv1x5 |
| 502 | |
| 503 | TEST_SUITE(Conv5x1) |
| 504 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 505 | combine(datasets::SmallWinogradConvolutionLayer5x1Dataset(), |
| 506 | make("DataType", { DataType::F32 }), |
| 507 | ActivationFunctionsDataset, |
| 508 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 509 | { |
| 510 | // Validate output |
| 511 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 512 | } |
| 513 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 514 | combine(datasets::LargeWinogradConvolutionLayer5x1Dataset(), |
| 515 | make("DataType", { DataType::F32 }), |
| 516 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 517 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 518 | { |
| 519 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 520 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | TEST_SUITE_END() // Conv5x1 |
| 524 | |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 525 | TEST_SUITE(Conv7x1) |
| 526 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 527 | combine(datasets::SmallWinogradConvolutionLayer7x1Dataset(), |
| 528 | make("DataType", { DataType::F32 }), |
| 529 | ActivationFunctionsDataset, |
| 530 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 531 | { |
| 532 | // Validate output |
| 533 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 534 | } |
| 535 | |
| 536 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 537 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer7x1Dataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 538 | make("DataType", { DataType::F32 })), |
| 539 | make("ActivationInfo", { ActivationLayerInfo() })), |
| 540 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 541 | { |
| 542 | // Validate output |
| 543 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
| 544 | } |
| 545 | TEST_SUITE_END() // Conv7x1 |
| 546 | |
| 547 | TEST_SUITE(Conv1x7) |
| 548 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 549 | combine(datasets::SmallWinogradConvolutionLayer1x7Dataset(), |
| 550 | make("DataType", { DataType::F32 }), |
| 551 | ActivationFunctionsDataset, |
| 552 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 553 | { |
| 554 | // Validate output |
| 555 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 556 | } |
| 557 | |
| 558 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 559 | combine(datasets::LargeWinogradConvolutionLayer7x1Dataset(), |
| 560 | make("DataType", { DataType::F32 }), |
| 561 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 562 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 563 | { |
| 564 | // Validate output |
| 565 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
| 566 | } |
| 567 | TEST_SUITE_END() // Conv1x7 |
| 568 | |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 569 | TEST_SUITE(Conv3x3) |
| 570 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 571 | combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
| 572 | make("DataType", { DataType::F32 }), |
| 573 | ActivationFunctionsDataset, |
| 574 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 575 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 576 | { |
| 577 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 578 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 579 | } |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 580 | |
| 581 | /// It's enough to run the activations for a single weight/input combination and data type because |
| 582 | /// activation function is called on top of the winograd output as a separate operator |
| 583 | /// TODO: Enable after COMPMID-6573 is resolved |
| 584 | FIXTURE_DATA_TEST_CASE(RunActivations, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::DISABLED, |
| 585 | combine( |
| 586 | make("Input", TensorShape(3U, 3U, 32U)), |
| 587 | make("Weight", TensorShape(3U, 3U, 32U, 4U)), |
| 588 | make("Bias", TensorShape(4U)), |
| 589 | make("Output", TensorShape(1U, 1U, 4U)), |
| 590 | make("PadStrideInfo", PadStrideInfo(1, 1, 0, 0)), |
| 591 | make("Dilation", Size2D(1U, 1U)), |
| 592 | make("DataType", { DataType::F32 }), |
| 593 | ActivationFunctionsDatasetNightly, |
| 594 | make("DataLayout", { DataLayout::NHWC }))) |
| 595 | { |
| 596 | // Validate output |
| 597 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 598 | } |
| 599 | |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 600 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 601 | combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(), |
| 602 | make("DataType", { DataType::F32 }), |
| 603 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 604 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 605 | |
| 606 | { |
| 607 | // Validate output |
Pablo Tello | af7e600 | 2018-10-08 15:53:14 +0100 | [diff] [blame] | 608 | // floating point arithmetic the Winograd results will not be exactly the same as direct convolution, especially for big shapes |
| 609 | validate(Accessor(_target), _reference, rel_tolerance_winograd_3x3_f32, 0.f, float(abs_tolerance_f32)); |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 610 | } |
| 611 | TEST_SUITE_END() // Conv3x3 |
| 612 | |
| 613 | TEST_SUITE(Conv5x5) |
| 614 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 615 | combine(datasets::SmallWinogradConvolutionLayer5x5Dataset(), |
| 616 | make("DataType", { DataType::F32 }), |
| 617 | ActivationFunctionsDataset, |
| 618 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 619 | |
| 620 | { |
| 621 | // Validate output |
| 622 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 623 | } |
| 624 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 625 | combine(datasets::LargeWinogradConvolutionLayer5x5Dataset(), |
| 626 | make("DataType", { DataType::F32 }), |
| 627 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 628 | make("DataLayout", { DataLayout::NHWC }))) |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 629 | |
| 630 | { |
| 631 | // Validate output |
| 632 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 633 | } |
| 634 | |
| 635 | TEST_SUITE_END() // Conv5x5 |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 636 | |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 637 | FIXTURE_DATA_TEST_CASE(RunSmallNoBias, NEWinogradConvolutionLayerNoBiasFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 638 | combine(framework::dataset::concat( |
| 639 | datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
| 640 | datasets::SmallWinogradConvolutionLayer5x5Dataset()), |
| 641 | make("DataType", { DataType::F32 }), |
| 642 | ActivationFunctionsDataset, |
| 643 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 644 | { |
| 645 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 646 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 647 | } |
| 648 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 649 | TEST_SUITE_END() // FP32 |
Georgios Pinitas | 5ce897f | 2020-04-29 11:44:10 +0100 | [diff] [blame] | 650 | |
| 651 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 652 | TEST_SUITE(FP16) |
| 653 | using CLWinogradConvolutionLayerFastMathFixture16 = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, half, float>; |
| 654 | |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 655 | DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip( |
| 656 | make("InputInfo", { TensorInfo(TensorShape(18U, 18U, 32U), 1, DataType::F16), |
| 657 | TensorInfo(TensorShape(18U, 18U, 32U), 1, DataType::F16) |
| 658 | }), |
| 659 | make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 32U, 21U), 1, DataType::F16), |
| 660 | TensorInfo(TensorShape(3U, 3U, 32U, 21U), 1, DataType::F16) |
| 661 | }), |
| 662 | make("OutputInfo", { TensorInfo(TensorShape(16U, 16U, 21U), 1, DataType::F32), |
| 663 | TensorInfo(TensorShape(16U, 16U, 21U), 1, DataType::F16) |
| 664 | }), |
| 665 | make("ConvInfo", { PadStrideInfo(1, 1, 0, 0), |
| 666 | PadStrideInfo(1, 1, 0, 0) |
| 667 | }), |
| 668 | make("FastMath", |
| 669 | { |
| 670 | false, // case fp16 and fast_math False then disable Winograd |
| 671 | true // case fp16 and fast_math True then enable Winograd |
| 672 | }), |
| 673 | make("Expected", { ConvolutionMethod::GEMM, ConvolutionMethod::WINOGRAD })), |
| 674 | input_info, weights_info, output_info, conv_info, fast_math, expected) |
Ramy Elgammal | a4814e8 | 2022-09-08 15:05:19 +0100 | [diff] [blame] | 675 | { |
| 676 | ConvolutionMethod is_valid = NEConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true), |
| 677 | &weights_info.clone()->set_is_resizable(true), |
| 678 | &output_info.clone()->set_is_resizable(true), conv_info, WeightsInfo(), Size2D(1U, 1U), ActivationLayerInfo(), fast_math); |
| 679 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
| 680 | } |
| 681 | |
Georgios Pinitas | 5ce897f | 2020-04-29 11:44:10 +0100 | [diff] [blame] | 682 | TEST_SUITE(Conv3x3) |
| 683 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFastMathFixture16, framework::DatasetMode::PRECOMMIT, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 684 | combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
| 685 | make("DataType", { DataType::F16 }), |
| 686 | ActivationFunctionsDataset, |
| 687 | make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Georgios Pinitas | 5ce897f | 2020-04-29 11:44:10 +0100 | [diff] [blame] | 688 | |
| 689 | { |
| 690 | // Validate output |
| 691 | validate(Accessor(_target), _reference, tolerance_convolution_layer_f16, tolerance_num_f16); |
| 692 | } |
| 693 | |
| 694 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFastMathFixture16, framework::DatasetMode::NIGHTLY, |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 695 | combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(), |
| 696 | make("DataType", { DataType::F16 }), |
| 697 | make("ActivationInfo", { ActivationLayerInfo() }), |
| 698 | make("DataLayout", { DataLayout::NHWC }))) |
Georgios Pinitas | 5ce897f | 2020-04-29 11:44:10 +0100 | [diff] [blame] | 699 | |
| 700 | { |
| 701 | // Validate output |
| 702 | validate(Accessor(_target), _reference, tolerance_convolution_layer_f16, tolerance_num_f16); |
| 703 | } |
| 704 | TEST_SUITE_END() // Conv3x3 |
| 705 | TEST_SUITE_END() // FP16 |
| 706 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 707 | TEST_SUITE_END() // WinogradLayer |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 708 | |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 709 | #ifdef ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS |
David Svantesson | 4537089 | 2023-02-22 11:08:57 +0000 | [diff] [blame] | 710 | TEST_SUITE(FIXED_FORMAT_KERNELS) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 711 | TEST_SUITE(VariableWeightUtils) |
| 712 | |
| 713 | // UC2_1_* tests: the user requests a specific fixed format, but there is no kernel that supports it. |
| 714 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 715 | template <typename ConvolutionClass> |
| 716 | using HasOptImplFixtureNoFastMath = HasOptImplFixture<ConvolutionClass, /*enable_fast_math*/ false>; |
| 717 | |
| 718 | template <typename ConvolutionClass> |
| 719 | using HasOptImplFixtureFastMath = HasOptImplFixture<ConvolutionClass, /*enable_fast_math*/ true>; |
| 720 | |
| 721 | // UC2_1 |
| 722 | |
| 723 | FIXTURE_DATA_TEST_CASE(UC2_1_CpuGemmConv2d, HasOptImplFixtureNoFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 724 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 725 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo2 }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 726 | { |
| 727 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 728 | } |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 729 | FIXTURE_DATA_TEST_CASE(UC2_1_NEGEMMConvolutionLayer, HasOptImplFixtureNoFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 730 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 731 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo2 }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 732 | { |
| 733 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 734 | } |
| 735 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 736 | FIXTURE_DATA_TEST_CASE(UC2_1_CpuGemmConv2d_FastMath, HasOptImplFixtureFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
| 737 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
| 738 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo2 }))) |
| 739 | { |
| 740 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 741 | } |
| 742 | |
| 743 | FIXTURE_DATA_TEST_CASE(UC2_1_NEGEMMConvolutionLayer_FastMath, HasOptImplFixtureFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
| 744 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
| 745 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo2 }))) |
| 746 | { |
| 747 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 748 | } |
| 749 | |
| 750 | // UC2_2_* tests: the user requests a specific fixed format, and a |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 751 | // kernel that support that fixed format is found. |
| 752 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 753 | FIXTURE_DATA_TEST_CASE(UC2_2_CpuGemmConv2d, HasOptImplFixtureNoFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 754 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 755 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo4 }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 756 | { |
| 757 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 758 | ARM_COMPUTE_EXPECT(_computed_weight_format == arm_compute::WeightFormat::OHWIo4, framework::LogLevel::ERRORS); |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 759 | } |
| 760 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 761 | FIXTURE_DATA_TEST_CASE(UC2_2_NEGEMMConvolutionLayer, HasOptImplFixtureNoFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 762 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 763 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo4 }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 764 | { |
| 765 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 766 | ARM_COMPUTE_EXPECT(_computed_weight_format == arm_compute::WeightFormat::OHWIo4, framework::LogLevel::ERRORS); |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 767 | } |
| 768 | |
David Svantesson | 4537089 | 2023-02-22 11:08:57 +0000 | [diff] [blame] | 769 | #if defined(ARM_COMPUTE_ENABLE_BF16) |
David Svantesson-Yeung | 64f2300 | 2024-03-27 12:55:45 +0000 | [diff] [blame] | 770 | // These tests currently only works with SVE length 256 |
| 771 | // If other SVE length is used a kernel will fail to be found |
| 772 | // This needs to be addressed in order to ensure it doesn't revert to FP32 kernels for systems with SVE length other than 256 |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 773 | FIXTURE_DATA_TEST_CASE(UC2_2_CpuGemmConv2d_FastMath, HasOptImplFixtureFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
| 774 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
| 775 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo8i4_bf16 }))) |
| 776 | { |
David Svantesson-Yeung | 64f2300 | 2024-03-27 12:55:45 +0000 | [diff] [blame] | 777 | if(Scheduler::get().cpu_info().has_bf16() && (arm_gemm::utils::get_vector_length<float>() == 8)){ |
| 778 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
| 779 | ARM_COMPUTE_EXPECT_EQUAL(_computed_weight_format, arm_compute::WeightFormat::OHWIo8i4_bf16, framework::LogLevel::ERRORS); |
| 780 | } |
| 781 | else{ |
| 782 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 783 | } |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | FIXTURE_DATA_TEST_CASE(UC2_2_NEGEMMConvolutionLayer_FastMath, HasOptImplFixtureFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
| 787 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
| 788 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::OHWIo8i4_bf16 }))) |
| 789 | { |
David Svantesson-Yeung | 64f2300 | 2024-03-27 12:55:45 +0000 | [diff] [blame] | 790 | if(Scheduler::get().cpu_info().has_bf16() && (arm_gemm::utils::get_vector_length<float>() == 8)){ |
| 791 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
| 792 | ARM_COMPUTE_EXPECT(_computed_weight_format == arm_compute::WeightFormat::OHWIo8i4_bf16, framework::LogLevel::ERRORS); |
| 793 | } |
| 794 | else{ |
| 795 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 796 | } |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 797 | } |
| 798 | |
David Svantesson | 4537089 | 2023-02-22 11:08:57 +0000 | [diff] [blame] | 799 | #endif // ARM_COMPUTE_ENABLE_BF16 |
| 800 | |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 801 | // UC3_1_* tests: the user queries for ANY fixed format, but there is |
| 802 | // no kernel that support the use case specified by the user (for |
| 803 | // example, there is no fixed format kernel for the datatype of the |
| 804 | // problem). |
| 805 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 806 | FIXTURE_DATA_TEST_CASE(UC3_1_CpuGemmConv2d, HasOptImplFixtureNoFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 807 | combine(framework::dataset::make("DataType", { DataType::S32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 808 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 809 | { |
| 810 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 811 | } |
| 812 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 813 | FIXTURE_DATA_TEST_CASE(UC3_1_NEGEMMConvolutionLayer, HasOptImplFixtureNoFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
| 814 | combine(framework::dataset::make("DataType", { DataType::S32 }), |
| 815 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
| 816 | { |
| 817 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 818 | } |
| 819 | |
| 820 | FIXTURE_DATA_TEST_CASE(UC3_1_CpuGemmConv2d_FastMath, HasOptImplFixtureFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
| 821 | combine(framework::dataset::make("DataType", { DataType::S32 }), |
| 822 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
| 823 | { |
| 824 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 825 | } |
| 826 | |
| 827 | FIXTURE_DATA_TEST_CASE(UC3_1_NEGEMMConvolutionLayer_FastMath, HasOptImplFixtureFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 828 | combine(framework::dataset::make("DataType", { DataType::S32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 829 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 830 | { |
| 831 | ARM_COMPUTE_EXPECT(!_kernel_found, framework::LogLevel::ERRORS); |
| 832 | } |
| 833 | |
| 834 | // UC3_2_* tests: the user queries for ANY fixed format. The search |
| 835 | // succeeded and the fixed format found is prompted back for |
| 836 | // consumption by the user. Note that we just test the |
| 837 | // _computed_weight_format to be anything but not the formats that are |
| 838 | // not fixed formats (ANY and UNSPECIFIED). This is because the weight |
| 839 | // format that the runtime produces depends on the size of the vector |
| 840 | // units of the hardware where the tests is executed. For example, a |
| 841 | // format like OHWIo4 for FP32 data returned for 128-bit NEON hardware |
| 842 | // is replaced by OHWIo8 when running on 256-bit SVE. |
| 843 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 844 | FIXTURE_DATA_TEST_CASE(UC3_2_CpuGemmConv2d, HasOptImplFixtureNoFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 845 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 846 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 847 | { |
| 848 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 849 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::ANY, framework::LogLevel::ERRORS); |
| 850 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::UNSPECIFIED, framework::LogLevel::ERRORS); |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 851 | } |
| 852 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 853 | FIXTURE_DATA_TEST_CASE(UC3_2_NEGEMMConvolutionLayer, HasOptImplFixtureNoFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 854 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 855 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 856 | { |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 857 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::ANY, framework::LogLevel::ERRORS); |
| 858 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::UNSPECIFIED, framework::LogLevel::ERRORS); |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 859 | } |
| 860 | |
David Svantesson | 4537089 | 2023-02-22 11:08:57 +0000 | [diff] [blame] | 861 | #if defined(ARM_COMPUTE_ENABLE_BF16) |
| 862 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 863 | FIXTURE_DATA_TEST_CASE(UC3_2_CpuGemmConv2d_FastMath, HasOptImplFixtureFastMath<cpu::CpuGemmConv2d>, framework::DatasetMode::ALL, |
| 864 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
| 865 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
| 866 | { |
David Svantesson-Yeung | 64f2300 | 2024-03-27 12:55:45 +0000 | [diff] [blame] | 867 | if(Scheduler::get().cpu_info().has_bf16()){ |
| 868 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
| 869 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::ANY, framework::LogLevel::ERRORS); |
| 870 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::UNSPECIFIED, framework::LogLevel::ERRORS); |
| 871 | ARM_COMPUTE_EXPECT(arm_compute::is_fixed_format_fast_math(_computed_weight_format), framework::LogLevel::ERRORS); |
| 872 | } |
| 873 | else{ |
| 874 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
| 875 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::ANY, framework::LogLevel::ERRORS); |
| 876 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::UNSPECIFIED, framework::LogLevel::ERRORS); |
| 877 | ARM_COMPUTE_EXPECT(!arm_compute::is_fixed_format_fast_math(_computed_weight_format), framework::LogLevel::ERRORS); |
| 878 | } |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | FIXTURE_DATA_TEST_CASE(UC3_2_NEGEMMConvolutionLayer_FastMath, HasOptImplFixtureFastMath<NEGEMMConvolutionLayer>, framework::DatasetMode::ALL, |
| 882 | combine(framework::dataset::make("DataType", { DataType::F32 }), |
| 883 | framework::dataset::make("QueryWeightFormat", { arm_compute::WeightFormat::ANY }))) |
| 884 | { |
David Svantesson-Yeung | 64f2300 | 2024-03-27 12:55:45 +0000 | [diff] [blame] | 885 | if(Scheduler::get().cpu_info().has_bf16()){ |
| 886 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
| 887 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::ANY, framework::LogLevel::ERRORS); |
| 888 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::UNSPECIFIED, framework::LogLevel::ERRORS); |
| 889 | ARM_COMPUTE_EXPECT(arm_compute::is_fixed_format_fast_math(_computed_weight_format), framework::LogLevel::ERRORS); |
| 890 | } |
| 891 | else{ |
| 892 | ARM_COMPUTE_EXPECT(_kernel_found, framework::LogLevel::ERRORS); |
| 893 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::ANY, framework::LogLevel::ERRORS); |
| 894 | ARM_COMPUTE_EXPECT(_computed_weight_format != arm_compute::WeightFormat::UNSPECIFIED, framework::LogLevel::ERRORS); |
| 895 | ARM_COMPUTE_EXPECT(!arm_compute::is_fixed_format_fast_math(_computed_weight_format), framework::LogLevel::ERRORS); |
| 896 | } |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 897 | } |
| 898 | |
David Svantesson | 4537089 | 2023-02-22 11:08:57 +0000 | [diff] [blame] | 899 | #endif // ARM_COMPUTE_ENABLE_BF16 |
| 900 | |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 901 | namespace |
| 902 | { |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 903 | using TestCaseType = std::tuple<TensorShape, TensorShape, arm_compute::WeightFormat>; |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 904 | auto prepare_weights_shapes = framework::dataset::make("TensorShape", |
| 905 | { |
| 906 | // OHWIo<interleave_by>i<block_by> |
| 907 | // |
| 908 | // OHWI --> O'HWI', where: |
| 909 | // |
| 910 | // O'= smallest multiple of <interleave_by> such that O<=O' |
| 911 | // I'= smallest multiple of <block_by> such that I<=I' |
| 912 | // |
| 913 | |
| 914 | // Change N for OHWIo4 |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 915 | TestCaseType({ { 1U, 1U, 1U, 1U }, { 1U, 1U, 1U, 4U }, arm_compute::WeightFormat::OHWIo4 }), |
| 916 | TestCaseType({ { 1U, 1U, 1U, 2U }, { 1U, 1U, 1U, 4U }, arm_compute::WeightFormat::OHWIo4 }), |
| 917 | TestCaseType({ { 1U, 1U, 1U, 3U }, { 1U, 1U, 1U, 4U }, arm_compute::WeightFormat::OHWIo4 }), |
| 918 | TestCaseType({ { 1U, 1U, 1U, 4U }, { 1U, 1U, 1U, 4U }, arm_compute::WeightFormat::OHWIo4 }), |
| 919 | TestCaseType({ { 1U, 1U, 1U, 5U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo4 }), |
| 920 | TestCaseType({ { 1U, 1U, 1U, 6U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo4 }), |
| 921 | TestCaseType({ { 1U, 1U, 1U, 7U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo4 }), |
| 922 | TestCaseType({ { 1U, 1U, 1U, 8U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo4 }), |
| 923 | TestCaseType({ { 1U, 1U, 1U, 9U }, { 1U, 1U, 1U, 12U }, arm_compute::WeightFormat::OHWIo4 }), |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 924 | // // Change N for OHWIo8 |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 925 | TestCaseType({ { 1U, 1U, 1U, 1U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 926 | TestCaseType({ { 1U, 1U, 1U, 2U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 927 | TestCaseType({ { 1U, 1U, 1U, 3U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 928 | TestCaseType({ { 1U, 1U, 1U, 4U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 929 | TestCaseType({ { 1U, 1U, 1U, 5U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 930 | TestCaseType({ { 1U, 1U, 1U, 6U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 931 | TestCaseType({ { 1U, 1U, 1U, 7U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 932 | TestCaseType({ { 1U, 1U, 1U, 8U }, { 1U, 1U, 1U, 8U }, arm_compute::WeightFormat::OHWIo8 }), |
| 933 | TestCaseType({ { 1U, 1U, 1U, 9U }, { 1U, 1U, 1U, 16U }, arm_compute::WeightFormat::OHWIo8 }), |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 934 | // // Change N for OHWIo4 when H, W and C are not 1 |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 935 | TestCaseType({ { 3U, 4U, 2U, 1U }, { 3, 4, 2, 4 }, arm_compute::WeightFormat::OHWIo4 }), |
| 936 | TestCaseType({ { 3U, 4U, 2U, 2U }, { 3, 4, 2, 4 }, arm_compute::WeightFormat::OHWIo4 }), |
| 937 | TestCaseType({ { 3U, 4U, 2U, 3U }, { 3, 4, 2, 4 }, arm_compute::WeightFormat::OHWIo4 }), |
| 938 | TestCaseType({ { 3U, 4U, 2U, 4U }, { 3, 4, 2, 4 }, arm_compute::WeightFormat::OHWIo4 }), |
| 939 | TestCaseType({ { 3U, 4U, 2U, 5U }, { 3, 4, 2, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 940 | TestCaseType({ { 3U, 4U, 2U, 6U }, { 3, 4, 2, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 941 | TestCaseType({ { 3U, 4U, 2U, 7U }, { 3, 4, 2, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 942 | TestCaseType({ { 3U, 4U, 2U, 8U }, { 3, 4, 2, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 943 | TestCaseType({ { 3U, 4U, 2U, 9U }, { 3, 4, 2, 12 }, arm_compute::WeightFormat::OHWIo4 }), |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 944 | |
| 945 | // // Fix N and move HWI around, with different data layouts and formats |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 946 | TestCaseType({ { 2U, 4U, 3U, 5U }, { 2, 4, 3, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 947 | TestCaseType({ { 3U, 4U, 2U, 5U }, { 3, 4, 2, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 948 | TestCaseType({ { 2U, 4U, 3U, 9U }, { 2, 4, 3, 16 }, arm_compute::WeightFormat::OHWIo8 }), |
| 949 | TestCaseType({ { 3U, 4U, 2U, 9U }, { 3, 4, 2, 16 }, arm_compute::WeightFormat::OHWIo8 }), |
| 950 | TestCaseType({ { 1024U, 1U, 1U, 1001U }, { 1024, 1, 1, 1008 }, arm_compute::WeightFormat::OHWIo8 }), |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 951 | |
| 952 | // // Adding <block_by> on I (=C) |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 953 | TestCaseType({ { 1U, 4U, 3U, 5U }, { 2, 4, 3, 8 }, arm_compute::WeightFormat::OHWIo4i2 }), |
| 954 | TestCaseType({ { 2U, 4U, 3U, 5U }, { 2, 4, 3, 8 }, arm_compute::WeightFormat::OHWIo4i2 }), |
| 955 | TestCaseType({ { 3U, 4U, 3U, 5U }, { 4, 4, 3, 8 }, arm_compute::WeightFormat::OHWIo4i2 }), |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 956 | |
| 957 | // --------- |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 958 | TestCaseType({ { 2, 2, 1, 5 }, { 2, 2, 1, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
| 959 | TestCaseType({ { 1, 2, 2, 5 }, { 1, 2, 2, 8 }, arm_compute::WeightFormat::OHWIo4 }), |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 960 | |
| 961 | }); |
| 962 | } // unnamed namespace |
| 963 | |
| 964 | DATA_TEST_CASE(PrepareWeightShape, framework::DatasetMode::ALL, |
| 965 | prepare_weights_shapes, shapes) |
| 966 | { |
Ramy Elgammal | 9178002 | 2022-07-20 14:57:37 +0100 | [diff] [blame] | 967 | const TensorShape input_shape = std::get<0>(shapes); |
| 968 | const TensorShape expected_shape = std::get<1>(shapes); |
| 969 | const arm_compute::WeightFormat wf = std::get<2>(shapes); |
| 970 | const DataType DT = DataType::F32; |
| 971 | const DataLayout DL = DataLayout::NHWC; |
| 972 | const auto TI = TensorInfo(input_shape, 1 /*num_channels, deprecated*/, DT, DL); |
Jonathan Deakin | 464ed20 | 2023-01-12 11:41:14 +0000 | [diff] [blame] | 973 | const TensorInfo computed_info = ::arm_compute::test::validation::prepare_weights(TI, wf); |
| 974 | ARM_COMPUTE_EXPECT_EQUAL(computed_info.tensor_shape(), expected_shape, framework::LogLevel::ERRORS); |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | TEST_SUITE_END() // VariableWeightUtils |
| 978 | |
| 979 | TEST_SUITE(ExperimentalCpuAPIVariableWeightWithFixtures) |
| 980 | |
| 981 | template <typename ScalarType> |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 982 | using VarWidth = VariableWeightsFixture<cpu::CpuGemmConv2d, Tensor, Accessor, ScalarType, /*enable_fast_math*/ false>; |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 983 | |
| 984 | FIXTURE_DATA_TEST_CASE(RunSmallFloat, VarWidth<float>, framework::DatasetMode::ALL, |
| 985 | combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 986 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 987 | framework::dataset::make("ACL Scalar type", { DataType::F32 }))) |
| 988 | { |
| 989 | // Validate output |
| 990 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 991 | } |
| 992 | |
Mohammed Suhail Munshi | 8050d22 | 2024-02-04 17:55:40 +0000 | [diff] [blame] | 993 | #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 994 | FIXTURE_DATA_TEST_CASE(RunSmallHalf, VarWidth<half>, framework::DatasetMode::ALL, |
| 995 | combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 996 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 997 | framework::dataset::make("ACL Scalar type", { DataType::F16 }))) |
| 998 | { |
| 999 | // Validate output |
| 1000 | validate(Accessor(_target), _reference, rel_tolerance_f16, 0.f, half(abs_tolerance_f16)); |
| 1001 | } |
Mohammed Suhail Munshi | 8050d22 | 2024-02-04 17:55:40 +0000 | [diff] [blame] | 1002 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1003 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 1004 | #if defined(ARM_COMPUTE_ENABLE_BF16) |
| 1005 | template <typename ScalarType> |
| 1006 | using VarWidthFastMath = VariableWeightsFixture<cpu::CpuGemmConv2d, Tensor, Accessor, ScalarType, /*enable_fast_math*/ true>; |
| 1007 | |
| 1008 | FIXTURE_DATA_TEST_CASE(RunSmallFloatFastMath, VarWidthFastMath<float>, framework::DatasetMode::ALL, |
| 1009 | combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 1010 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1011 | framework::dataset::make("ACL Scalar type", { DataType::F32 }))) |
| 1012 | { |
| 1013 | // Validate output |
| 1014 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1015 | } |
| 1016 | #endif // ARM_COMPUTE_ENABLE_BF16 |
| 1017 | |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1018 | TEST_SUITE_END() // ExperimentalCpuAPIVariableWeightWithFixtures |
| 1019 | |
| 1020 | TEST_SUITE(ExperimentalNEAPIVariableWeightWithFixtures) |
| 1021 | |
| 1022 | template <typename ScalarType> |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 1023 | using NEGEMMVarWidth = VariableWeightsFixtureNEInterface<NEGEMMConvolutionLayer, Tensor, Accessor, ScalarType, /*enable_fast_math*/ false>; |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1024 | |
| 1025 | FIXTURE_DATA_TEST_CASE(NEGEMMRunSmallFloat, NEGEMMVarWidth<float>, framework::DatasetMode::ALL, |
| 1026 | combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 1027 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1028 | framework::dataset::make("ACL Scalar type", { DataType::F32 }))) |
| 1029 | { |
| 1030 | // Validate output |
| 1031 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1032 | } |
| 1033 | |
Mohammed Suhail Munshi | 8050d22 | 2024-02-04 17:55:40 +0000 | [diff] [blame] | 1034 | #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1035 | FIXTURE_DATA_TEST_CASE(NEGEMMRunSmallHalf, NEGEMMVarWidth<half>, framework::DatasetMode::ALL, |
| 1036 | combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 1037 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1038 | framework::dataset::make("ACL Scalar type", { DataType::F16 }))) |
| 1039 | { |
| 1040 | // Validate output |
| 1041 | validate(Accessor(_target), _reference, rel_tolerance_f16, 0.f, half(abs_tolerance_f16)); |
| 1042 | } |
Mohammed Suhail Munshi | 8050d22 | 2024-02-04 17:55:40 +0000 | [diff] [blame] | 1043 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1044 | |
Pablo Marquez Tello | 93581a5 | 2022-07-21 13:55:27 +0100 | [diff] [blame] | 1045 | #if defined(ARM_COMPUTE_ENABLE_BF16) |
| 1046 | template <typename ScalarType> |
| 1047 | using NEGEMMVarWidthFastMath = VariableWeightsFixtureNEInterface<NEGEMMConvolutionLayer, Tensor, Accessor, ScalarType, /*enable_fast_math*/ true>; |
| 1048 | |
| 1049 | FIXTURE_DATA_TEST_CASE(NEGEMMRunSmallFloatFastMath, NEGEMMVarWidthFastMath<float>, framework::DatasetMode::ALL, |
| 1050 | combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 1051 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1052 | framework::dataset::make("ACL Scalar type", { DataType::F32 }))) |
| 1053 | { |
| 1054 | // Validate output |
| 1055 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1056 | } |
| 1057 | #endif // ARM_COMPUTE_ENABLE_BF16 |
| 1058 | |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1059 | TEST_SUITE_END() // ExperimentalNEAPIVariableWeightWithFixtures |
David Svantesson | 4537089 | 2023-02-22 11:08:57 +0000 | [diff] [blame] | 1060 | TEST_SUITE_END() // FIXED_FORMAT_KERNELS |
Francesco Petrogalli | 553f695 | 2022-06-30 10:22:01 +0000 | [diff] [blame] | 1061 | |
| 1062 | #endif // ARM_COMPUTE_ENABLE_FIXED_FORMAT_KERNELS |
| 1063 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 1064 | TEST_SUITE(GEMMConvolutionLayer) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1065 | template <typename T> |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1066 | using NEGEMMConvolutionLayerFixture = ConvolutionValidationFixture<Tensor, Accessor, NEConvolutionLayer, T>; |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1067 | template <typename T> |
SiCong Li | c5ab4df | 2023-10-17 17:38:57 +0100 | [diff] [blame] | 1068 | using NEGEMMConvolutionLayerPaddedWeightsFixture = ConvolutionValidationPaddedWeightsFixture<Tensor, Accessor, NEConvolutionLayer, T>; |
| 1069 | template <typename T> |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1070 | using NEGEMMConvolutionLayerMixedDataLayoutFixture = ConvolutionValidationFixture<Tensor, Accessor, NEConvolutionLayer, T, true>; |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1071 | |
Georgios Pinitas | 1988463 | 2021-08-16 12:38:54 +0100 | [diff] [blame] | 1072 | /** Test case for memory injection in @ref cpu::CpuGemmConv2d. |
Manuel Bottini | 29599d0 | 2021-07-06 15:01:35 +0100 | [diff] [blame] | 1073 | * |
| 1074 | * Configure the operator once and inject memory at run-time in multiple executions. |
| 1075 | * |
| 1076 | * Checks performed in order: |
| 1077 | * - Both runs compute the same output |
| 1078 | */ |
| 1079 | TEST_CASE(MemoryInjection, framework::DatasetMode::ALL) |
| 1080 | { |
Georgios Pinitas | 1988463 | 2021-08-16 12:38:54 +0100 | [diff] [blame] | 1081 | auto conv = std::make_unique<cpu::CpuGemmConv2d>(); |
Manuel Bottini | 29599d0 | 2021-07-06 15:01:35 +0100 | [diff] [blame] | 1082 | const auto src_info = TensorInfo(TensorShape(1U, 5U, 2U), 1, DataType::F32, DataLayout::NCHW); |
| 1083 | const auto weight_info = TensorInfo(TensorShape(1U, 3U, 2U, 3U), 1, DataType::F32, DataLayout::NCHW); |
| 1084 | const auto bias_info = TensorInfo(TensorShape(3U), 1, DataType::F32, DataLayout::NCHW); |
| 1085 | auto dst_info = TensorInfo(TensorShape(1U, 7U, 3U), 1, DataType::F32, DataLayout::NCHW); |
| 1086 | const auto conv_info = PadStrideInfo(1, 1, 0, 0, 2, 2, DimensionRoundingType::FLOOR); |
| 1087 | WeightsInfo weights_info(false, 3U, 3U, 1U); |
| 1088 | conv->configure(&src_info, &weight_info, &bias_info, &dst_info, conv_info, weights_info); |
| 1089 | |
| 1090 | // tensors are newly created every call of this lambda function |
| 1091 | auto src = create_tensor<Tensor>(src_info); |
| 1092 | auto weight = create_tensor<Tensor>(weight_info); |
| 1093 | auto bias = create_tensor<Tensor>(bias_info); |
| 1094 | src.allocator()->allocate(); |
| 1095 | weight.allocator()->allocate(); |
| 1096 | bias.allocator()->allocate(); |
| 1097 | |
| 1098 | ITensorPack run_pack{ { TensorType::ACL_SRC_0, &src }, { TensorType::ACL_SRC_1, &weight }, { TensorType::ACL_SRC_2, &bias } }; |
| 1099 | ITensorPack prep_pack{ { TensorType::ACL_SRC_1, &weight }, { TensorType::ACL_SRC_2, &bias } }; |
| 1100 | |
| 1101 | auto mg = MemoryGroup{}; |
| 1102 | auto ws = manage_workspace<Tensor>(conv->workspace(), mg, run_pack, prep_pack); |
| 1103 | |
| 1104 | auto run_conv = [&]() -> Tensor |
| 1105 | { |
| 1106 | auto dst = create_tensor<Tensor>(dst_info); |
| 1107 | dst.allocator()->allocate(); |
| 1108 | run_pack.add_tensor(TensorType::ACL_DST, &dst); |
| 1109 | |
| 1110 | library->fill_tensor_value(Accessor(src), 1.f); |
| 1111 | library->fill_tensor_value(Accessor(weight), 2.f); |
| 1112 | library->fill_tensor_value(Accessor(bias), 3.f); |
| 1113 | // This operator is configured once and captured by this lambda. |
| 1114 | conv->prepare(prep_pack); |
| 1115 | conv->run(run_pack); |
| 1116 | return dst; |
| 1117 | }; |
| 1118 | auto result_0 = run_conv(); |
| 1119 | auto result_1 = run_conv(); |
| 1120 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 1121 | { |
| 1122 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 1123 | } |
| 1124 | } |
| 1125 | |
| 1126 | /** Test case for memory injection in @ref NEGEMMConvolutionLayer. |
| 1127 | * |
| 1128 | * Make sure @ref NEGEMMConvolutionLayer still works through injecting the memory at configure time using the old API. |
| 1129 | * |
| 1130 | * Checks performed in order: |
| 1131 | * - Both runs compute the same output |
| 1132 | */ |
| 1133 | TEST_CASE(MultipleExecutionWithConfigure, framework::DatasetMode::ALL) |
| 1134 | { |
| 1135 | auto conv = std::make_unique<NEGEMMConvolutionLayer>(); |
| 1136 | const auto src_info = TensorInfo(TensorShape(1U, 5U, 2U), 1, DataType::F32, DataLayout::NCHW); |
| 1137 | const auto weight_info = TensorInfo(TensorShape(1U, 3U, 2U, 3U), 1, DataType::F32, DataLayout::NCHW); |
| 1138 | const auto bias_info = TensorInfo(TensorShape(3U), 1, DataType::F32, DataLayout::NCHW); |
| 1139 | auto dst_info = TensorInfo(TensorShape(1U, 7U, 3U), 1, DataType::F32, DataLayout::NCHW); |
| 1140 | const auto conv_info = PadStrideInfo(1, 1, 0, 0, 2, 2, DimensionRoundingType::FLOOR); |
| 1141 | WeightsInfo weights_info(false, 3U, 3U, 1U); |
| 1142 | auto run_conv = [&]() |
| 1143 | { |
| 1144 | auto src = create_tensor<Tensor>(src_info); |
| 1145 | auto weight = create_tensor<Tensor>(weight_info); |
| 1146 | auto bias = create_tensor<Tensor>(bias_info); |
| 1147 | auto dst = create_tensor<Tensor>(dst_info); |
| 1148 | conv->configure(&src, &weight, &bias, &dst, conv_info, weights_info); |
| 1149 | src.allocator()->allocate(); |
| 1150 | weight.allocator()->allocate(); |
| 1151 | bias.allocator()->allocate(); |
| 1152 | dst.allocator()->allocate(); |
| 1153 | library->fill_tensor_value(Accessor(src), 1.f); |
| 1154 | library->fill_tensor_value(Accessor(weight), 2.f); |
| 1155 | library->fill_tensor_value(Accessor(bias), 3.f); |
| 1156 | conv->run(); |
| 1157 | return dst; |
| 1158 | }; |
| 1159 | auto result_0 = run_conv(); |
| 1160 | auto result_1 = run_conv(); |
| 1161 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 1162 | { |
| 1163 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 1164 | } |
| 1165 | } |
| 1166 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1167 | TEST_SUITE(Float) |
Pablo Marquez Tello | d208f4f | 2022-07-19 12:19:46 +0100 | [diff] [blame] | 1168 | #if defined(ARM_COMPUTE_ENABLE_BF16) |
Georgios Pinitas | c7b183a | 2020-03-06 18:12:09 +0000 | [diff] [blame] | 1169 | TEST_SUITE(BFLOAT16) |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1170 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1171 | framework::dataset::make("ReshapeWeights", { true })), |
David Svantesson-Yeung | 64f2300 | 2024-03-27 12:55:45 +0000 | [diff] [blame] | 1172 | framework::dataset::make("DataType", Scheduler::get().cpu_info().has_bf16() ? DataType::BFLOAT16 : DataType::F32)), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1173 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1174 | ActivationFunctionsDataset)) |
Georgios Pinitas | c7b183a | 2020-03-06 18:12:09 +0000 | [diff] [blame] | 1175 | { |
| 1176 | // Validate output |
| 1177 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1178 | } |
| 1179 | TEST_SUITE_END() // BFLOAT16 |
Pablo Marquez Tello | d208f4f | 2022-07-19 12:19:46 +0100 | [diff] [blame] | 1180 | #endif /* defined(ARM_COMPUTE_ENABLE_BF16) */ |
Georgios Pinitas | c7b183a | 2020-03-06 18:12:09 +0000 | [diff] [blame] | 1181 | |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 1182 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1183 | TEST_SUITE(FP16) |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1184 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1185 | framework::dataset::make("ReshapeWeights", { true })), |
| 1186 | framework::dataset::make("DataType", DataType::F16)), |
| 1187 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 1188 | ActivationFunctionsDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1189 | { |
| 1190 | // Validate output |
Gian Marco Iodice | 41acb76 | 2018-08-23 10:25:06 +0100 | [diff] [blame] | 1191 | validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1192 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 1193 | TEST_SUITE_END() // FP16 |
| 1194 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1195 | |
| 1196 | TEST_SUITE(FP32) |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1197 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1198 | framework::dataset::make("ReshapeWeights", { true })), |
| 1199 | framework::dataset::make("DataType", DataType::F32)), |
| 1200 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1201 | ActivationFunctionsDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1202 | { |
| 1203 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 1204 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1205 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1206 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, NEGEMMConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::ALL, |
Sang-Hoon Park | b3be457 | 2021-05-18 10:46:00 +0100 | [diff] [blame] | 1207 | combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1208 | framework::dataset::make("Input", TensorShape(23U, 27U, 5U)), |
| 1209 | framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))), |
| 1210 | framework::dataset::make("Bias", TensorShape(2U))), |
| 1211 | framework::dataset::make("Output", TensorShape(11U, 25U, 2U))), |
| 1212 | framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))), |
| 1213 | framework::dataset::make("Dilation", Size2D(1, 1))), |
| 1214 | framework::dataset::make("ReshapeWeights", { true })), |
| 1215 | framework::dataset::make("DataType", DataType::F32)), |
| 1216 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 1217 | ActivationFunctionsDataset)) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1218 | { |
| 1219 | // Validate output |
| 1220 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1221 | } |
SiCong Li | c5ab4df | 2023-10-17 17:38:57 +0100 | [diff] [blame] | 1222 | /** Padded weights |
| 1223 | * CpuGemmConv2d uses two different paths for reshaping the weights based on if the weight tensor has holes (a common |
| 1224 | * way to have "holes" in tensor is via extended paddings) |
| 1225 | * |
| 1226 | * We only need to test the padded weight path here on a single floating data type and a single layout, because the fallback path is agnostic of them |
| 1227 | */ |
| 1228 | FIXTURE_DATA_TEST_CASE(RunPaddedWeights, NEGEMMConvolutionLayerPaddedWeightsFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallConvolutionLayerDataset(), |
| 1229 | framework::dataset::make("ReshapeWeights", { true }), |
| 1230 | framework::dataset::make("DataType", DataType::F32), |
| 1231 | framework::dataset::make("DataLayout", { DataLayout::NHWC }) |
| 1232 | )) |
| 1233 | { |
| 1234 | // Validate output |
| 1235 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1236 | } |
Gunes Bayir | 9167c9c | 2024-03-06 09:58:40 +0000 | [diff] [blame] | 1237 | |
| 1238 | // This very large shape test is required to test heuristic paths where the tensor size is > 1e7 bytes |
| 1239 | // and weight dimensions larger than 7 |
| 1240 | FIXTURE_DATA_TEST_CASE(RunVeryLarge, NEGEMMConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 1241 | combine(datasets::VeryLargeConvolutionLayerDataset(), |
| 1242 | framework::dataset::make("ReshapeWeights", { true }), |
| 1243 | framework::dataset::make("DataType", DataType::F32), |
| 1244 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }), |
| 1245 | NoActivation)) |
| 1246 | { |
| 1247 | // Validate output |
| 1248 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1249 | } |
| 1250 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 1251 | TEST_SUITE_END() // FP32 |
| 1252 | TEST_SUITE_END() // Float |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1253 | |
SiCong Li | c5ab4df | 2023-10-17 17:38:57 +0100 | [diff] [blame] | 1254 | // TODO: COMPMID-6596 Extend quantized tests with at least one suite where the weight is padded (the legacy case, see floating point's RunPaddedWeights) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1255 | template <typename T> |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1256 | using NEGEMMConvolutionLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<Tensor, Accessor, NEConvolutionLayer, T>; |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1257 | template <typename T> |
| 1258 | using NEGEMMConvolutionLayerQuantizedMixedDataLayoutFixture = ConvolutionValidationQuantizedFixture<Tensor, Accessor, NEConvolutionLayer, T, true>; |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 1259 | |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 1260 | template <typename T> |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1261 | using NEGEMMConvolutionLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture<Tensor, Accessor, NEConvolutionLayer, T, int8_t>; |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 1262 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 1263 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 1264 | { |
| 1265 | ActivationLayerInfo(), |
| 1266 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 1267 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 1268 | }); |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 1269 | TEST_SUITE(Quantized) |
Gunes Bayir | 93a77cd | 2023-10-13 16:58:41 +0100 | [diff] [blame] | 1270 | /// @note: Every asymmetric quantized test where there's no fused activation will have its quantization info ignored |
| 1271 | /// This is because instead of using the same quantization information for all the tensors, the fixture generates |
| 1272 | /// separate quantization info for each input and the output tensor. |
| 1273 | /// When we can also support dynamic quantization with the presence of activation, these two versions should be merged |
| 1274 | /// again, with the explicitly specified quantization info removed |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 1275 | TEST_SUITE(QASYMM8) |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1276 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1277 | framework::dataset::make("ReshapeWeights", { true })), |
| 1278 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 1279 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Gunes Bayir | 93a77cd | 2023-10-13 16:58:41 +0100 | [diff] [blame] | 1280 | framework::dataset::make("QuantizationInfoIfActivationEnabled", { QuantizationInfo(2.f / 255.f, 10) })), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1281 | QuantizedActivationFunctionsDataset)) |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 1282 | { |
| 1283 | // Validate output |
| 1284 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1285 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1286 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, NEGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, |
Sang-Hoon Park | b3be457 | 2021-05-18 10:46:00 +0100 | [diff] [blame] | 1287 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1288 | framework::dataset::make("Input", TensorShape(23U, 27U, 5U)), |
| 1289 | framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))), |
| 1290 | framework::dataset::make("Bias", TensorShape(2U))), |
| 1291 | framework::dataset::make("Output", TensorShape(11U, 25U, 2U))), |
| 1292 | framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))), |
| 1293 | framework::dataset::make("Dilation", Size2D(1, 1))), |
| 1294 | framework::dataset::make("ReshapeWeights", { true })), |
| 1295 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 1296 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Gunes Bayir | 93a77cd | 2023-10-13 16:58:41 +0100 | [diff] [blame] | 1297 | framework::dataset::make("QuantizationInfoIfActivationEnabled", { QuantizationInfo(2.f / 255.f, 10) })), |
Sang-Hoon Park | b3be457 | 2021-05-18 10:46:00 +0100 | [diff] [blame] | 1298 | QuantizedActivationFunctionsDataset)) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1299 | { |
| 1300 | // Validate output |
| 1301 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1302 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 1303 | TEST_SUITE_END() // QASYMM8 |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 1304 | |
Georgios Pinitas | 6e1791b | 2019-12-02 19:01:25 +0000 | [diff] [blame] | 1305 | TEST_SUITE(QASYMM8_SIGNED) |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1306 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1307 | framework::dataset::make("ReshapeWeights", { true })), |
| 1308 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 1309 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Gunes Bayir | 93a77cd | 2023-10-13 16:58:41 +0100 | [diff] [blame] | 1310 | framework::dataset::make("QuantizationInfoIfActivationEnabled", { QuantizationInfo(0.01f, -10) })), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1311 | QuantizedActivationFunctionsDataset)) |
Georgios Pinitas | 6e1791b | 2019-12-02 19:01:25 +0000 | [diff] [blame] | 1312 | { |
| 1313 | // Validate output |
| 1314 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1315 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1316 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, NEGEMMConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, |
Sang-Hoon Park | b3be457 | 2021-05-18 10:46:00 +0100 | [diff] [blame] | 1317 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1318 | framework::dataset::make("Input", TensorShape(23U, 27U, 5U)), |
| 1319 | framework::dataset::make("Weights", TensorShape(3U, 3U, 5U, 2U))), |
| 1320 | framework::dataset::make("Bias", TensorShape(2U))), |
| 1321 | framework::dataset::make("Output", TensorShape(11U, 25U, 2U))), |
| 1322 | framework::dataset::make("PadStrideInfo", PadStrideInfo(2, 1, 0, 0))), |
| 1323 | framework::dataset::make("Dilation", Size2D(1, 1))), |
| 1324 | framework::dataset::make("ReshapeWeights", { true })), |
| 1325 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 1326 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Gunes Bayir | 93a77cd | 2023-10-13 16:58:41 +0100 | [diff] [blame] | 1327 | framework::dataset::make("QuantizationInfoIfActivationEnabled", { QuantizationInfo(2.f / 255.f, 10) })), |
Sang-Hoon Park | b3be457 | 2021-05-18 10:46:00 +0100 | [diff] [blame] | 1328 | QuantizedActivationFunctionsDataset)) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 1329 | { |
| 1330 | // Validate output |
| 1331 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1332 | } |
Georgios Pinitas | 6e1791b | 2019-12-02 19:01:25 +0000 | [diff] [blame] | 1333 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 1334 | |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 1335 | TEST_SUITE(QSYMM8_PER_CHANNEL) |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 1336 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerQuantizedPerChannelFixture<uint8_t>, framework::DatasetMode::ALL, |
Georgios Pinitas | 63d4dbd | 2019-11-08 11:51:56 +0000 | [diff] [blame] | 1337 | combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 1338 | framework::dataset::make("ReshapeWeights", { true })), |
| 1339 | framework::dataset::make("DataType", { DataType::QASYMM8 })), |
| 1340 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 1341 | QuantizationData), |
| 1342 | QuantizedActivationFunctionsDataset), |
| 1343 | framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL }))) |
| 1344 | { |
| 1345 | // Validate output |
| 1346 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1347 | } |
Sang-Hoon Park | 1fad814 | 2020-07-03 13:07:35 +0100 | [diff] [blame] | 1348 | FIXTURE_DATA_TEST_CASE(RunSmallSigned, NEGEMMConvolutionLayerQuantizedPerChannelFixture<int8_t>, framework::DatasetMode::ALL, |
| 1349 | combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 1350 | framework::dataset::make("ReshapeWeights", { true })), |
| 1351 | framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED })), |
| 1352 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 1353 | QuantizationData), |
| 1354 | QuantizedActivationFunctionsDataset), |
| 1355 | framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL }))) |
| 1356 | { |
| 1357 | // Validate output |
| 1358 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1359 | } |
Gunes Bayir | 2481e95 | 2024-04-25 12:32:36 +0100 | [diff] [blame^] | 1360 | |
| 1361 | FIXTURE_DATA_TEST_CASE(MemoryStressLargeChannels, NEGEMMConvolutionLayerQuantizedPerChannelFixture<int8_t>, |
| 1362 | framework::DatasetMode::ALL, |
| 1363 | combine( |
| 1364 | make("In", TensorShape(1U)), |
| 1365 | make("Weights", TensorShape(1U, 1U, 1U, 17000U)), |
| 1366 | make("Biases", TensorShape(17000U)), |
| 1367 | make("Out", TensorShape(1U, 1U, 17000U)), |
| 1368 | make("Info", PadStrideInfo(1, 1, 0, 0)), |
| 1369 | make("Dilation", Size2D(1, 1)), |
| 1370 | make("ReshapeWeights", { true }), |
| 1371 | make("DataType", { DataType::QASYMM8_SIGNED }), |
| 1372 | make("DataLayout", { DataLayout::NHWC }), |
| 1373 | make("QuantizationInfo", QuantizationInfo(0.5f, 10)), |
| 1374 | make("ActivationInfo", ActivationLayerInfo()), |
| 1375 | make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL }))) |
| 1376 | { |
| 1377 | // Validate output |
| 1378 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1379 | } |
| 1380 | |
Georgios Pinitas | dbdea0d | 2019-10-16 19:21:40 +0100 | [diff] [blame] | 1381 | TEST_SUITE_END() // QSYMM8_PER_CHANNEL |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 1382 | TEST_SUITE_END() // Quantized |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 1383 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 1384 | TEST_SUITE_END() // GEMMConvolutionLayer |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1385 | |
| 1386 | TEST_SUITE(DirectGEMMConv2d) |
| 1387 | template <typename T> |
| 1388 | using NEDirectGEMMConv2dLayerFixture = ConvolutionValidationFixture<Tensor, Accessor, NEGEMMConv2d, T>; |
| 1389 | |
Michele Di Giorgio | d7316eb | 2021-06-16 11:14:41 +0100 | [diff] [blame] | 1390 | /** Test case for memory injection in @ref cpu::CpuGemmDirectConv2d. |
| 1391 | * |
| 1392 | * Configure the operator once and inject memory at run-time in multiple executions. |
| 1393 | * |
| 1394 | * Checks performed in order: |
| 1395 | * - Both runs compute the same output |
| 1396 | */ |
| 1397 | TEST_CASE(MemoryInjection, framework::DatasetMode::ALL) |
| 1398 | { |
| 1399 | auto conv = std::make_unique<cpu::CpuGemmDirectConv2d>(); |
| 1400 | const auto src_info = TensorInfo(TensorShape(1U, 5U, 2U), 1, DataType::F32, DataLayout::NHWC); |
| 1401 | const auto weight_info = TensorInfo(TensorShape(1U, 3U, 2U, 3U), 1, DataType::F32, DataLayout::NHWC); |
| 1402 | const auto bias_info = TensorInfo(TensorShape(3U), 1, DataType::F32, DataLayout::NHWC); |
| 1403 | auto dst_info = TensorInfo(TensorShape(1U, 7U, 3U), 1, DataType::F32, DataLayout::NHWC); |
| 1404 | const auto conv_info = Conv2dInfo{}; |
| 1405 | conv->configure(&src_info, &weight_info, &bias_info, &dst_info, conv_info); |
| 1406 | |
| 1407 | // tensors are newly created every call of this lambda function |
| 1408 | auto src = create_tensor<Tensor>(src_info); |
| 1409 | auto weight = create_tensor<Tensor>(weight_info); |
| 1410 | auto bias = create_tensor<Tensor>(bias_info); |
| 1411 | src.allocator()->allocate(); |
| 1412 | weight.allocator()->allocate(); |
| 1413 | bias.allocator()->allocate(); |
| 1414 | |
| 1415 | ITensorPack run_pack{ { TensorType::ACL_SRC_0, &src }, { TensorType::ACL_SRC_1, &weight }, { TensorType::ACL_SRC_2, &bias } }; |
| 1416 | ITensorPack prep_pack{ { TensorType::ACL_SRC_1, &weight }, { TensorType::ACL_SRC_2, &bias } }; |
| 1417 | |
| 1418 | auto mg = MemoryGroup{}; |
| 1419 | auto ws = manage_workspace<Tensor>(conv->workspace(), mg, run_pack, prep_pack); |
| 1420 | |
| 1421 | auto run_conv = [&]() -> Tensor |
| 1422 | { |
| 1423 | auto dst = create_tensor<Tensor>(dst_info); |
| 1424 | dst.allocator()->allocate(); |
| 1425 | run_pack.add_tensor(TensorType::ACL_DST, &dst); |
| 1426 | |
| 1427 | library->fill_tensor_value(Accessor(src), 1.f); |
| 1428 | library->fill_tensor_value(Accessor(weight), 2.f); |
| 1429 | library->fill_tensor_value(Accessor(bias), 3.f); |
| 1430 | // This operator is configured once and captured by this lambda. |
| 1431 | conv->prepare(prep_pack); |
| 1432 | conv->run(run_pack); |
| 1433 | return dst; |
| 1434 | }; |
| 1435 | auto result_0 = run_conv(); |
| 1436 | auto result_1 = run_conv(); |
| 1437 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 1438 | { |
| 1439 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 1440 | } |
| 1441 | } |
| 1442 | |
| 1443 | /** Test case for memory injection in @ref NEGEMMConv2d. |
| 1444 | * |
| 1445 | * Make sure @ref NEGEMMConv2d still works through injecting the memory at configure time using the old API. |
| 1446 | * |
| 1447 | * Checks performed in order: |
| 1448 | * - Both runs compute the same output |
| 1449 | */ |
| 1450 | TEST_CASE(MultipleExecutionWithConfigure, framework::DatasetMode::ALL) |
| 1451 | { |
| 1452 | auto conv = std::make_unique<NEGEMMConv2d>(); |
| 1453 | const auto src_info = TensorInfo(TensorShape(1U, 5U, 2U), 1, DataType::F32, DataLayout::NHWC); |
| 1454 | const auto weight_info = TensorInfo(TensorShape(1U, 3U, 2U, 3U), 1, DataType::F32, DataLayout::NHWC); |
| 1455 | const auto bias_info = TensorInfo(TensorShape(3U), 1, DataType::F32, DataLayout::NHWC); |
| 1456 | auto dst_info = TensorInfo(TensorShape(1U, 7U, 3U), 1, DataType::F32, DataLayout::NHWC); |
| 1457 | const auto conv_info = Conv2dInfo{}; |
| 1458 | auto run_conv = [&]() |
| 1459 | { |
| 1460 | auto src = create_tensor<Tensor>(src_info); |
| 1461 | auto weight = create_tensor<Tensor>(weight_info); |
| 1462 | auto bias = create_tensor<Tensor>(bias_info); |
| 1463 | auto dst = create_tensor<Tensor>(dst_info); |
| 1464 | conv->configure(&src, &weight, &bias, &dst, conv_info); |
| 1465 | src.allocator()->allocate(); |
| 1466 | weight.allocator()->allocate(); |
| 1467 | bias.allocator()->allocate(); |
| 1468 | dst.allocator()->allocate(); |
| 1469 | library->fill_tensor_value(Accessor(src), 1.f); |
| 1470 | library->fill_tensor_value(Accessor(weight), 2.f); |
| 1471 | library->fill_tensor_value(Accessor(bias), 3.f); |
| 1472 | conv->run(); |
| 1473 | return dst; |
| 1474 | }; |
| 1475 | auto result_0 = run_conv(); |
| 1476 | auto result_1 = run_conv(); |
| 1477 | for(size_t i = 0; i < result_0.info()->tensor_shape().total_size(); ++i) |
| 1478 | { |
| 1479 | ARM_COMPUTE_EXPECT(((float *)result_0.buffer())[i] == ((float *)result_1.buffer())[i], framework::LogLevel::ERRORS); |
| 1480 | } |
| 1481 | } |
| 1482 | |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1483 | TEST_SUITE(Float) |
| 1484 | TEST_SUITE(FP32) |
| 1485 | FIXTURE_DATA_TEST_CASE(RunSmall, NEDirectGEMMConv2dLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1486 | framework::dataset::make("ReshapeWeights", { true })), |
| 1487 | framework::dataset::make("DataType", DataType::F32)), |
| 1488 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1489 | ActivationFunctionsDataset)) |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1490 | { |
| 1491 | // Validate output |
| 1492 | validate(Accessor(_target), _reference, rel_tolerance_f32, 0.f, float(abs_tolerance_f32)); |
| 1493 | } |
| 1494 | TEST_SUITE_END() // FP32 |
| 1495 | TEST_SUITE_END() // Float |
| 1496 | |
Georgios Pinitas | 61ffda4 | 2020-11-13 14:03:07 +0000 | [diff] [blame] | 1497 | #ifdef __aarch64__ |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1498 | template <typename T> |
| 1499 | using NEDirectGEMMConv2dLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<Tensor, Accessor, NEGEMMConv2d, T>; |
| 1500 | |
| 1501 | template <typename T> |
| 1502 | using NEDirectGEMMConv2dLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture<Tensor, Accessor, NEGEMMConv2d, T, int8_t>; |
| 1503 | |
| 1504 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 1505 | { |
| 1506 | ActivationLayerInfo(), |
| 1507 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 1508 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 1509 | }); |
| 1510 | TEST_SUITE(Quantized) |
| 1511 | TEST_SUITE(QASYMM8) |
| 1512 | FIXTURE_DATA_TEST_CASE(RunSmall, NEDirectGEMMConv2dLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1513 | framework::dataset::make("ReshapeWeights", { true })), |
| 1514 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 1515 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1516 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
| 1517 | QuantizedActivationFunctionsDataset)) |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1518 | { |
| 1519 | // Validate output |
| 1520 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1521 | } |
| 1522 | TEST_SUITE_END() // QASYMM8 |
| 1523 | |
| 1524 | TEST_SUITE(QASYMM8_SIGNED) |
| 1525 | FIXTURE_DATA_TEST_CASE(RunSmall, NEDirectGEMMConv2dLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Gunes Bayir | c2a51bd | 2023-09-28 10:30:18 +0100 | [diff] [blame] | 1526 | framework::dataset::make("ReshapeWeights", { true })), |
| 1527 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 1528 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1529 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.01f, -10) })), |
| 1530 | QuantizedActivationFunctionsDataset)) |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1531 | { |
| 1532 | // Validate output |
| 1533 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1534 | } |
| 1535 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 1536 | |
| 1537 | TEST_SUITE(QSYMM8_PER_CHANNEL) |
| 1538 | FIXTURE_DATA_TEST_CASE(RunSmallSigned, NEDirectGEMMConv2dLayerQuantizedPerChannelFixture<int8_t>, framework::DatasetMode::ALL, |
| 1539 | combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 1540 | framework::dataset::make("ReshapeWeights", { true })), |
| 1541 | framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED })), |
| 1542 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 1543 | QuantizationData), |
| 1544 | QuantizedActivationFunctionsDataset), |
| 1545 | framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL }))) |
| 1546 | { |
| 1547 | // Validate output |
| 1548 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 1549 | } |
| 1550 | TEST_SUITE_END() // QSYMM8_PER_CHANNEL |
| 1551 | TEST_SUITE_END() // Quantized |
Georgios Pinitas | 61ffda4 | 2020-11-13 14:03:07 +0000 | [diff] [blame] | 1552 | #endif // __aarch64__ |
Georgios Pinitas | c0b6f76 | 2020-11-02 01:37:17 +0000 | [diff] [blame] | 1553 | |
| 1554 | TEST_SUITE_END() // DirectGEMMConv2d |
| 1555 | |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 1556 | TEST_SUITE_END() // Neon |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1557 | } // namespace validation |
| 1558 | } // namespace test |
| 1559 | } // namespace arm_compute |