Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 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" |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 26 | #include "arm_compute/runtime/NEON/functions/NEGEMMConvolutionLayer.h" |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 27 | #include "arm_compute/runtime/NEON/functions/NEWinogradConvolutionLayer.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 28 | #include "arm_compute/runtime/Tensor.h" |
| 29 | #include "arm_compute/runtime/TensorAllocator.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 30 | #include "tests/NEON/Accessor.h" |
| 31 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 32 | #include "tests/datasets/LargeConvolutionLayerDataset.h" |
| 33 | #include "tests/datasets/SmallConvolutionLayerDataset.h" |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 34 | #include "tests/datasets/TinyConvolutionLayerDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 35 | #include "tests/framework/Asserts.h" |
| 36 | #include "tests/framework/Macros.h" |
| 37 | #include "tests/framework/datasets/Datasets.h" |
| 38 | #include "tests/validation/Validation.h" |
| 39 | #include "tests/validation/fixtures/ConvolutionLayerFixture.h" |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 40 | #include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 41 | |
| 42 | namespace arm_compute |
| 43 | { |
| 44 | namespace test |
| 45 | { |
| 46 | namespace validation |
| 47 | { |
| 48 | namespace |
| 49 | { |
Pablo Tello | af7e600 | 2018-10-08 15:53:14 +0100 | [diff] [blame] | 50 | const RelativeTolerance<float> rel_tolerance_f32(0.01f); /**< Relative tolerance for FP32 types */ |
| 51 | const RelativeTolerance<float> rel_tolerance_winograd_3x3_f32(0.05f); /**< Relative tolerance for FP32 types */ |
| 52 | const AbsoluteTolerance<float> abs_tolerance_f32(0.002f); /**< Absolute tolerance for FP32 types */ |
| 53 | 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] | 54 | |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 55 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Gian Marco Iodice | 41acb76 | 2018-08-23 10:25:06 +0100 | [diff] [blame] | 56 | const RelativeTolerance<half_float::half> rel_tolerance_f16(half_float::half(0.2f)); /**< Relative tolerance value for FP16 types */ |
| 57 | const AbsoluteTolerance<float> abs_tolerance_f16(0.2f); /**< Absolute tolerance for FP16 types */ |
| 58 | constexpr float tolerance_num = 0.07f; /**< Tolerance number for the FP16 implementation */ |
| 59 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 60 | constexpr AbsoluteTolerance<float> tolerance_qasymm8(0.0); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 61 | |
| 62 | /** CNN data types */ |
| 63 | const auto CNNDataTypes = framework::dataset::make("DataType", |
| 64 | { |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 65 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 66 | DataType::F16, |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 67 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 68 | DataType::F32, |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 69 | DataType::QASYMM8, |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 70 | }); |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 71 | const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 72 | { |
| 73 | ActivationLayerInfo(), |
| 74 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 75 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f) |
| 76 | }); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 77 | } // namespace |
| 78 | |
| 79 | TEST_SUITE(NEON) |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 80 | TEST_SUITE(ConvolutionLayer) |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 81 | |
| 82 | // *INDENT-OFF* |
| 83 | // clang-format off |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 84 | DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 85 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(18U, 18U, 32U), 1, DataType::F32), |
| 86 | TensorInfo(TensorShape(23U, 27U, 32U, 4U), 1, DataType::F32), |
| 87 | TensorInfo(TensorShape(3U, 3U, 2U, 1U), 1, DataType::F32), |
| 88 | TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) |
| 89 | }), |
| 90 | framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(3U, 3U, 32U, 21U), 1, DataType::F32), |
| 91 | TensorInfo(TensorShape(5U, 5U, 32U, 21U), 1, DataType::F32), |
| 92 | TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32), |
| 93 | TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16) |
| 94 | })), |
| 95 | framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(16U, 16U, 21U), 1, DataType::F32), |
| 96 | TensorInfo(TensorShape(19U, 23U, 21U, 4U), 1, DataType::F32), |
| 97 | TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), |
| 98 | TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32) |
| 99 | })), |
| 100 | framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0), |
| 101 | PadStrideInfo(1, 1, 0, 0), |
| 102 | PadStrideInfo(2, 1, 0, 0), |
| 103 | PadStrideInfo(3, 2, 1, 0) |
| 104 | })), |
| 105 | framework::dataset::make("FastMath", { true, |
| 106 | true, |
| 107 | false, |
| 108 | false |
| 109 | })), |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 110 | framework::dataset::make("Expected", { ConvolutionMethod::WINOGRAD, ConvolutionMethod::WINOGRAD, ConvolutionMethod::GEMM, ConvolutionMethod::GEMM })), |
| 111 | input_info, weights_info, output_info, conv_info, fast_math, expected) |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 112 | { |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 113 | ConvolutionMethod is_valid = NEConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true), |
| 114 | &weights_info.clone()->set_is_resizable(true), |
| 115 | &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] | 116 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
| 117 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 118 | // clang-format on |
| 119 | // *INDENT-ON* |
| 120 | TEST_SUITE_END() // ConvolutionLayer |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 121 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 122 | TEST_SUITE(WinogradLayer) |
| 123 | template <typename T> |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 124 | using NEWinogradConvolutionLayerFixture = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, T>; |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 125 | |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 126 | template <typename T> |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 127 | using NEWinogradConvolutionLayerNoBiasFixture = WinogradConvolutionLayerFastMathValidationFixture<Tensor, Accessor, NEWinogradConvolutionLayer, T, T, false>; |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 128 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 129 | TEST_SUITE(FP32) |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 130 | |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 131 | TEST_SUITE(Conv1x3) |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 132 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 133 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer1x3Dataset(), |
| 134 | framework::dataset::make("DataType", { DataType::F32 })), |
| 135 | ActivationFunctionsDataset), |
| 136 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 137 | { |
| 138 | // Validate output |
| 139 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 140 | } |
| 141 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 142 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer1x3Dataset(), |
| 143 | framework::dataset::make("DataType", { DataType::F32 })), |
| 144 | ActivationFunctionsDataset), |
| 145 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 146 | { |
| 147 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 148 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | TEST_SUITE_END() // Conv1x3 |
| 152 | |
| 153 | TEST_SUITE(Conv3x1) |
| 154 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 155 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer3x1Dataset(), |
| 156 | framework::dataset::make("DataType", { DataType::F32 })), |
| 157 | ActivationFunctionsDataset), |
| 158 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 159 | { |
| 160 | // Validate output |
| 161 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 162 | } |
| 163 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 164 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer3x1Dataset(), |
| 165 | framework::dataset::make("DataType", { DataType::F32 })), |
| 166 | ActivationFunctionsDataset), |
| 167 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 168 | { |
| 169 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 170 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | TEST_SUITE_END() // Conv3x1 |
| 174 | |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 175 | TEST_SUITE(Conv1x5) |
| 176 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 177 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer1x5Dataset(), |
| 178 | framework::dataset::make("DataType", { DataType::F32 })), |
| 179 | ActivationFunctionsDataset), |
| 180 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 181 | { |
| 182 | // Validate output |
| 183 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 184 | } |
| 185 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 186 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer1x5Dataset(), |
| 187 | framework::dataset::make("DataType", { DataType::F32 })), |
| 188 | ActivationFunctionsDataset), |
| 189 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 190 | { |
| 191 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 192 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | TEST_SUITE_END() // Conv1x5 |
| 196 | |
| 197 | TEST_SUITE(Conv5x1) |
| 198 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 199 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer5x1Dataset(), |
| 200 | framework::dataset::make("DataType", { DataType::F32 })), |
| 201 | ActivationFunctionsDataset), |
| 202 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 203 | { |
| 204 | // Validate output |
| 205 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 206 | } |
| 207 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 208 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer5x1Dataset(), |
| 209 | framework::dataset::make("DataType", { DataType::F32 })), |
| 210 | ActivationFunctionsDataset), |
| 211 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 212 | { |
| 213 | // Validate output |
Pablo Tello | 952aeb1 | 2018-09-12 09:47:25 +0100 | [diff] [blame] | 214 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
Pablo Tello | 000d33a | 2018-09-03 16:59:20 +0100 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | TEST_SUITE_END() // Conv5x1 |
| 218 | |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 219 | TEST_SUITE(Conv7x1) |
| 220 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 221 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer7x1Dataset(), |
| 222 | framework::dataset::make("DataType", { DataType::F32 })), |
| 223 | ActivationFunctionsDataset), |
| 224 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 225 | { |
| 226 | // Validate output |
| 227 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 228 | } |
| 229 | |
| 230 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 231 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer7x1Dataset(), |
| 232 | framework::dataset::make("DataType", { DataType::F32 })), |
| 233 | ActivationFunctionsDataset), |
| 234 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 235 | { |
| 236 | // Validate output |
| 237 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
| 238 | } |
| 239 | TEST_SUITE_END() // Conv7x1 |
| 240 | |
| 241 | TEST_SUITE(Conv1x7) |
| 242 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 243 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer1x7Dataset(), |
| 244 | framework::dataset::make("DataType", { DataType::F32 })), |
| 245 | ActivationFunctionsDataset), |
| 246 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 247 | { |
| 248 | // Validate output |
| 249 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 250 | } |
| 251 | |
| 252 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 253 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer7x1Dataset(), |
| 254 | framework::dataset::make("DataType", { DataType::F32 })), |
| 255 | ActivationFunctionsDataset), |
| 256 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 257 | { |
| 258 | // Validate output |
| 259 | validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); |
| 260 | } |
| 261 | TEST_SUITE_END() // Conv1x7 |
| 262 | |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 263 | TEST_SUITE(Conv3x3) |
| 264 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 265 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 266 | framework::dataset::make("DataType", { DataType::F32 })), |
| 267 | ActivationFunctionsDataset), |
| 268 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 269 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 270 | { |
| 271 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 272 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 273 | } |
Pablo Tello | bda6e4b | 2018-08-22 11:40:33 +0100 | [diff] [blame] | 274 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 275 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(), |
| 276 | framework::dataset::make("DataType", { DataType::F32 })), |
| 277 | ActivationFunctionsDataset), |
| 278 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 279 | |
| 280 | { |
| 281 | // Validate output |
Pablo Tello | af7e600 | 2018-10-08 15:53:14 +0100 | [diff] [blame] | 282 | // floating point arithmetic the Winograd results will not be exactly the same as direct convolution, especially for big shapes |
| 283 | 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] | 284 | } |
| 285 | TEST_SUITE_END() // Conv3x3 |
| 286 | |
| 287 | TEST_SUITE(Conv5x5) |
| 288 | FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 289 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer5x5Dataset(), |
| 290 | framework::dataset::make("DataType", { DataType::F32 })), |
| 291 | ActivationFunctionsDataset), |
| 292 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 293 | |
| 294 | { |
| 295 | // Validate output |
| 296 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 297 | } |
| 298 | FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 299 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer5x5Dataset(), |
| 300 | framework::dataset::make("DataType", { DataType::F32 })), |
| 301 | ActivationFunctionsDataset), |
| 302 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 303 | |
| 304 | { |
| 305 | // Validate output |
| 306 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
| 307 | } |
| 308 | |
| 309 | TEST_SUITE_END() // Conv5x5 |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 310 | |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 311 | FIXTURE_DATA_TEST_CASE(RunSmallNoBias, NEWinogradConvolutionLayerNoBiasFixture<float>, framework::DatasetMode::PRECOMMIT, |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 312 | combine(combine(combine(framework::dataset::concat(datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
| 313 | datasets::SmallWinogradConvolutionLayer5x5Dataset()), |
| 314 | framework::dataset::make("DataType", { DataType::F32 })), |
| 315 | ActivationFunctionsDataset), |
| 316 | |
| 317 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 318 | { |
| 319 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 320 | validate(Accessor(_target), _reference, abs_tolerance_f32); |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 323 | TEST_SUITE_END() // FP32 |
| 324 | TEST_SUITE_END() // WinogradLayer |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 325 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 326 | TEST_SUITE(GEMMConvolutionLayer) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 327 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 328 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), |
| 329 | CNNDataTypes), |
| 330 | framework::dataset::make("ActivationInfo", |
| 331 | { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) })), |
| 332 | input_shape, weights_shape, bias_shape, output_shape, info, dilation, data_type, act_info) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 333 | { |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 334 | auto bias_data_type = is_data_type_quantized_asymmetric(data_type) ? DataType::S32 : data_type; |
| 335 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 336 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 337 | Tensor src = create_tensor<Tensor>(input_shape, data_type, 1, QuantizationInfo(2.f / 255.f, 127)); |
| 338 | Tensor weights = create_tensor<Tensor>(weights_shape, data_type, 1, QuantizationInfo(2.f / 255.f, 127)); |
| 339 | Tensor bias = create_tensor<Tensor>(bias_shape, bias_data_type, 1, QuantizationInfo(2.f / 255.f, 127)); |
| 340 | Tensor dst = create_tensor<Tensor>(output_shape, data_type, 1, QuantizationInfo(2.f / 255.f, 127)); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 341 | |
| 342 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 343 | ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 344 | ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 345 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 346 | |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 347 | const QuantizationInfo src_quantization_info = src.info()->quantization_info(); |
| 348 | const QuantizationInfo weights_quantization_info = weights.info()->quantization_info(); |
| 349 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 350 | // Create and configure function |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 351 | NEGEMMConvolutionLayer conv; |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 352 | conv.configure(&src, &weights, &bias, &dst, info, WeightsInfo(), dilation, act_info); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 353 | |
| 354 | // Validate valid region |
| 355 | const ValidRegion src_valid_region = shape_to_valid_region(input_shape); |
| 356 | const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); |
| 357 | const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); |
| 358 | const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); |
| 359 | |
| 360 | validate(src.info()->valid_region(), src_valid_region); |
| 361 | validate(weights.info()->valid_region(), weights_valid_region); |
| 362 | validate(bias.info()->valid_region(), bias_valid_region); |
| 363 | validate(dst.info()->valid_region(), dst_valid_region); |
| 364 | |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 365 | // Validate QuantizationInfo |
| 366 | ARM_COMPUTE_EXPECT(src.info()->quantization_info() == src_quantization_info, framework::LogLevel::ERRORS); |
| 367 | ARM_COMPUTE_EXPECT(weights.info()->quantization_info() == weights_quantization_info, framework::LogLevel::ERRORS); |
| 368 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 369 | // Validate padding |
| 370 | //TODO(COMPMID-415) Need to validate padding? |
| 371 | } |
| 372 | |
| 373 | template <typename T> |
Anthony Barbier | c8e84b5 | 2018-07-17 16:48:42 +0100 | [diff] [blame] | 374 | using NEGEMMConvolutionLayerFixture = ConvolutionValidationFixture<Tensor, Accessor, NEGEMMConvolutionLayer, T>; |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 375 | |
| 376 | TEST_SUITE(Float) |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 377 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 378 | TEST_SUITE(FP16) |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 379 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 380 | framework::dataset::make("ReshapeWeights", { true })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 381 | framework::dataset::make("DataType", DataType::F16)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 382 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 383 | ActivationFunctionsDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 384 | { |
| 385 | // Validate output |
Gian Marco Iodice | 41acb76 | 2018-08-23 10:25:06 +0100 | [diff] [blame] | 386 | validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 387 | } |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 388 | FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(), |
| 389 | framework::dataset::make("ReshapeWeights", { true })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 390 | framework::dataset::make("DataType", DataType::F16)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 391 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 392 | ActivationFunctionsDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 393 | { |
| 394 | // Validate output |
Gian Marco Iodice | 41acb76 | 2018-08-23 10:25:06 +0100 | [diff] [blame] | 395 | validate(Accessor(_target), _reference, rel_tolerance_f16, tolerance_num, abs_tolerance_f16); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 396 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 397 | TEST_SUITE_END() // FP16 |
| 398 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 399 | |
| 400 | TEST_SUITE(FP32) |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 401 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 402 | framework::dataset::make("ReshapeWeights", { true })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 403 | framework::dataset::make("DataType", DataType::F32)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 404 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 405 | ActivationFunctionsDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 406 | { |
| 407 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 408 | 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] | 409 | } |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 410 | FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(), |
| 411 | framework::dataset::make("ReshapeWeights", { true })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 412 | framework::dataset::make("DataType", DataType::F32)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 413 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 414 | ActivationFunctionsDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 415 | { |
| 416 | // Validate output |
Georgios Pinitas | 8dea602 | 2018-06-08 18:33:31 +0100 | [diff] [blame] | 417 | 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] | 418 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 419 | TEST_SUITE_END() // FP32 |
| 420 | TEST_SUITE_END() // Float |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 421 | |
| 422 | template <typename T> |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 423 | using NEGEMMConvolutionLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<Tensor, Accessor, NEGEMMConvolutionLayer, T>; |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 424 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 425 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 426 | { |
| 427 | ActivationLayerInfo(), |
| 428 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 429 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 430 | }); |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 431 | TEST_SUITE(Quantized) |
| 432 | TEST_SUITE(QASYMM8) |
Georgios Pinitas | 19ea419 | 2018-06-19 13:09:53 +0100 | [diff] [blame] | 433 | FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 434 | framework::dataset::make("ReshapeWeights", { true })), |
| 435 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Gian Marco Iodice | db9d46d | 2018-08-08 12:29:38 +0100 | [diff] [blame] | 436 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 437 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
| 438 | QuantizedActivationFunctionsDataset)) |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 439 | { |
| 440 | // Validate output |
| 441 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 442 | } |
Georgios Pinitas | 19ea419 | 2018-06-19 13:09:53 +0100 | [diff] [blame] | 443 | FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(), |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 444 | framework::dataset::make("ReshapeWeights", { true })), |
| 445 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Gian Marco Iodice | db9d46d | 2018-08-08 12:29:38 +0100 | [diff] [blame] | 446 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 447 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
| 448 | QuantizedActivationFunctionsDataset)) |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 449 | { |
| 450 | // Validate output |
| 451 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 452 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 453 | TEST_SUITE_END() // QASYMM8 |
| 454 | TEST_SUITE_END() // Quantized |
Isabella Gottardi | e6630e4 | 2018-01-18 15:50:39 +0000 | [diff] [blame] | 455 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 456 | TEST_SUITE_END() // GEMMConvolutionLayer |
| 457 | TEST_SUITE_END() // NEON |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 458 | } // namespace validation |
| 459 | } // namespace test |
| 460 | } // namespace arm_compute |