Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 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, |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/core/Types.h" |
| 25 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 27 | #include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 28 | #include "arm_compute/runtime/CL/functions/CLGEMMConvolutionLayer.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 29 | #include "tests/CL/CLAccessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 31 | #include "tests/datasets/LargeConvolutionLayerDataset.h" |
| 32 | #include "tests/datasets/SmallConvolutionLayerDataset.h" |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 33 | #include "tests/datasets/TinyConvolutionLayerDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 34 | #include "tests/framework/Asserts.h" |
| 35 | #include "tests/framework/Macros.h" |
| 36 | #include "tests/framework/datasets/Datasets.h" |
| 37 | #include "tests/validation/Validation.h" |
| 38 | #include "tests/validation/fixtures/ConvolutionLayerFixture.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 39 | |
| 40 | namespace arm_compute |
| 41 | { |
| 42 | namespace test |
| 43 | { |
| 44 | namespace validation |
| 45 | { |
| 46 | namespace |
| 47 | { |
Manuel Bottini | 28a46c9 | 2020-11-11 15:05:29 +0000 | [diff] [blame] | 48 | class SmallConvolutionLayerDatasetCases final : public datasets::ConvolutionLayerDataset |
| 49 | { |
| 50 | public: |
| 51 | SmallConvolutionLayerDatasetCases() |
| 52 | { |
| 53 | // 1D Kernel |
| 54 | add_config(TensorShape(1U, 130U, 2000U), TensorShape(1U, 1U, 2000U, 2000U), TensorShape(2000U), TensorShape(1U, 130U, 2000U), PadStrideInfo(1, 1, 0, 0)); |
| 55 | } |
| 56 | }; |
| 57 | |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 58 | RelativeTolerance<float> tolerance_f32(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ |
steniu01 | f81652d | 2017-09-11 15:29:12 +0100 | [diff] [blame] | 59 | RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.2)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ |
Georgios Pinitas | 51e53a3 | 2018-10-22 13:49:08 +0100 | [diff] [blame] | 60 | constexpr AbsoluteTolerance<float> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for quantized data types */ |
steniu01 | f81652d | 2017-09-11 15:29:12 +0100 | [diff] [blame] | 61 | constexpr float tolerance_num = 0.07f; /**< Tolerance number */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 62 | |
| 63 | /** CNN data types */ |
| 64 | const auto CNNDataTypes = framework::dataset::make("DataType", |
| 65 | { |
| 66 | DataType::F16, |
| 67 | DataType::F32, |
Chunosov | 5124be5 | 2017-11-22 20:42:13 +0700 | [diff] [blame] | 68 | DataType::QASYMM8, |
Sang-Hoon Park | 4715cf9 | 2020-01-08 16:02:47 +0000 | [diff] [blame] | 69 | DataType::QASYMM8_SIGNED, |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 70 | }); |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 71 | |
| 72 | /** Grouped CNN data types */ |
| 73 | const auto GroupedCNNDataTypes = framework::dataset::make("DataType", |
| 74 | { |
| 75 | DataType::F16, |
| 76 | DataType::F32 |
| 77 | }); |
| 78 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 79 | const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 80 | { |
| 81 | ActivationLayerInfo(), |
| 82 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 83 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f), |
| 84 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) |
| 85 | }); |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 86 | const auto ActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo", |
| 87 | { |
| 88 | ActivationLayerInfo(), |
| 89 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) |
| 90 | }); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 91 | } // namespace |
| 92 | |
| 93 | TEST_SUITE(CL) |
| 94 | TEST_SUITE(ConvolutionLayer) |
| 95 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 96 | // *INDENT-OFF* |
| 97 | // clang-format off |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 98 | DATA_TEST_CASE(ValidateConvolutionMethod, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 99 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Select GEMM |
| 100 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Select GEMM |
| 101 | TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Select GEMM |
| 102 | TensorInfo(TensorShape(23U, 27U, 31U, 4U), 1, DataType::F32), // Select WINOGRAD |
| 103 | TensorInfo(TensorShape(3U, 3U, 2U, 1U), 1, DataType::F32), // Select GEMM |
| 104 | TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32), // Select GEMM |
| 105 | TensorInfo(TensorShape(17U, 31U, 32U), 1, DataType::F32), // Select WINOGRAD |
| 106 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Select GEMM |
| 107 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::QASYMM8_SIGNED), // Select GEMM |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 108 | }), |
| 109 | framework::dataset::make("WeightsInfo", { TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32), |
| 110 | TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32), |
| 111 | TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32), |
| 112 | TensorInfo(TensorShape(3U, 3U, 31U, 21U), 1, DataType::F32), |
| 113 | TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32), |
| 114 | TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16), |
| 115 | TensorInfo(TensorShape(5U, 5U, 32U, 19U), 1, DataType::F32), |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 116 | TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::F32), |
| 117 | TensorInfo(TensorShape(5U, 5U, 2U, 19U), 1, DataType::QASYMM8_SIGNED), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 118 | })), |
| 119 | framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32), |
| 120 | TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32), |
| 121 | TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32), |
| 122 | TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32), |
| 123 | TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), |
| 124 | TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32), |
| 125 | TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32), |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 126 | TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32), |
| 127 | TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::QASYMM8_SIGNED), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 128 | })), |
| 129 | framework::dataset::make("ConvInfo", { PadStrideInfo(1, 2, 1, 1), |
| 130 | PadStrideInfo(1, 2, 1, 1), |
| 131 | PadStrideInfo(1, 1, 0, 0), |
| 132 | PadStrideInfo(1, 1, 0, 0), |
| 133 | PadStrideInfo(2, 1, 0, 0), |
| 134 | PadStrideInfo(3, 2, 1, 0), |
| 135 | PadStrideInfo(1, 1, 2, 2), |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 136 | PadStrideInfo(1, 1, 2, 2), |
| 137 | PadStrideInfo(1, 1, 2, 2), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 138 | })), |
| 139 | framework::dataset::make("GpuTarget", { GPUTarget::BIFROST, |
| 140 | GPUTarget::MIDGARD, |
| 141 | GPUTarget::G71, |
| 142 | GPUTarget::G71, |
| 143 | GPUTarget::MIDGARD, |
| 144 | GPUTarget::BIFROST, |
| 145 | GPUTarget::BIFROST, |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 146 | GPUTarget::BIFROST, |
| 147 | GPUTarget::BIFROST, |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 148 | })), |
| 149 | framework::dataset::make("Dilation", { Size2D(1U, 1U), |
| 150 | Size2D(1U, 1U), |
| 151 | Size2D(1U, 1U), |
| 152 | Size2D(1U, 1U), |
| 153 | Size2D(1U, 1U), |
| 154 | Size2D(1U, 1U), |
| 155 | Size2D(1U, 1U), |
| 156 | Size2D(2U, 1U), |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 157 | Size2D(2U, 1U), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 158 | })), |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 159 | framework::dataset::make("EnableFastMath", { false, false, false, false, false, false, true, true, true })), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 160 | framework::dataset::make("Expected",{ ConvolutionMethod::GEMM, |
| 161 | ConvolutionMethod::GEMM, |
| 162 | ConvolutionMethod::GEMM, |
| 163 | ConvolutionMethod::WINOGRAD, |
| 164 | ConvolutionMethod::GEMM, |
| 165 | ConvolutionMethod::GEMM, |
| 166 | ConvolutionMethod::WINOGRAD, |
| 167 | ConvolutionMethod::GEMM, |
Sang-Hoon Park | 70d33bd | 2020-01-08 16:29:15 +0000 | [diff] [blame] | 168 | ConvolutionMethod::GEMM, |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 169 | })), |
| 170 | input_info, weights_info, output_info, conv_info, gpu_target, dilation, enable_fast_math, expected) |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 171 | { |
| 172 | ConvolutionMethod is_valid = CLConvolutionLayer::get_convolution_method(&input_info.clone()->set_is_resizable(true), |
| 173 | &weights_info.clone()->set_is_resizable(true), |
| 174 | &output_info.clone()->set_is_resizable(true), conv_info, |
| 175 | WeightsInfo(), |
| 176 | ActivationLayerInfo(), |
| 177 | gpu_target, |
| 178 | dilation, |
| 179 | enable_fast_math); |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 180 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
| 181 | } |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 182 | // clang-format on |
| 183 | // *INDENT-ON* |
| 184 | TEST_SUITE_END() // ConvolutionLayer |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 185 | |
| 186 | TEST_SUITE(GEMMConvolutionLayer) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 187 | template <typename T> |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 188 | using CLGEMMConvolutionLayerFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>; |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 189 | |
| 190 | TEST_SUITE(Float) |
| 191 | TEST_SUITE(FP16) |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 192 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 193 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 194 | framework::dataset::make("ReshapeWeights", { true })), |
| 195 | framework::dataset::make("DataType", |
| 196 | DataType::F16)), |
| 197 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 198 | ActivationFunctionsSmallDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 199 | { |
| 200 | // Validate output |
steniu01 | 3e05e4e | 2017-08-25 17:18:01 +0100 | [diff] [blame] | 201 | validate(CLAccessor(_target), _reference, tolerance_f16, tolerance_num); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 202 | } |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 203 | TEST_SUITE_END() // FP16 |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 204 | |
| 205 | TEST_SUITE(FP32) |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 206 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 207 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 208 | framework::dataset::make("ReshapeWeights", { true })), |
| 209 | framework::dataset::make("DataType", |
| 210 | DataType::F32)), |
| 211 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 212 | ActivationFunctionsSmallDataset)) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 213 | { |
| 214 | // Validate output |
| 215 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 216 | } |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 217 | TEST_SUITE_END() // FP32 |
| 218 | TEST_SUITE_END() // Float |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 219 | |
| 220 | template <typename T> |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 221 | using CLGEMMConvolutionLayerQuantizedFixture = ConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>; |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 222 | template <typename T> |
| 223 | using CLGEMMConvolutionLayerQuantizedPerChannelFixture = ConvolutionValidationQuantizedPerChannelFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T, int8_t>; |
Chunosov | 5124be5 | 2017-11-22 20:42:13 +0700 | [diff] [blame] | 224 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 225 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 226 | { |
| 227 | ActivationLayerInfo(), |
| 228 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 229 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 230 | }); |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 231 | const auto QuantizedActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo", |
| 232 | { |
| 233 | ActivationLayerInfo(), |
| 234 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 235 | }); |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 236 | |
Chunosov | 5124be5 | 2017-11-22 20:42:13 +0700 | [diff] [blame] | 237 | TEST_SUITE(Quantized) |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 238 | |
Gian Marco Iodice | 3139f03 | 2018-11-05 14:26:32 +0000 | [diff] [blame] | 239 | const auto QuantizationData = framework::dataset::make("QuantizationInfo", |
| 240 | { |
| 241 | QuantizationInfo(0.5f, 10), |
| 242 | QuantizationInfo(0.3f, 3), |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 243 | QuantizationInfo(1.1f, 10), |
Gian Marco Iodice | 3139f03 | 2018-11-05 14:26:32 +0000 | [diff] [blame] | 244 | }); |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 245 | TEST_SUITE(QASYMM8) |
Gian Marco Iodice | 3139f03 | 2018-11-05 14:26:32 +0000 | [diff] [blame] | 246 | |
Manuel Bottini | 28a46c9 | 2020-11-11 15:05:29 +0000 | [diff] [blame] | 247 | FIXTURE_DATA_TEST_CASE(RunSmallCases, CLGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, |
| 248 | combine(combine(combine(combine(combine(SmallConvolutionLayerDatasetCases(), |
| 249 | framework::dataset::make("ReshapeWeights", { true })), |
| 250 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 251 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 252 | QuantizationData), |
| 253 | QuantizedActivationFunctionsSmallDataset)) |
| 254 | { |
| 255 | // Validate output |
| 256 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 257 | } |
| 258 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 259 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, |
| 260 | combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 261 | framework::dataset::make("ReshapeWeights", { true })), |
| 262 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 263 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 264 | QuantizationData), |
| 265 | QuantizedActivationFunctionsSmallDataset)) |
Chunosov | 5124be5 | 2017-11-22 20:42:13 +0700 | [diff] [blame] | 266 | { |
| 267 | // Validate output |
| 268 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 269 | } |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 270 | TEST_SUITE_END() // QASYMM8 |
Sang-Hoon Park | 4715cf9 | 2020-01-08 16:02:47 +0000 | [diff] [blame] | 271 | TEST_SUITE(QASYMM8_SIGNED) |
| 272 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 273 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, |
| 274 | combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
Sang-Hoon Park | 4715cf9 | 2020-01-08 16:02:47 +0000 | [diff] [blame] | 275 | framework::dataset::make("ReshapeWeights", { true })), |
| 276 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 277 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 278 | QuantizationData), |
| 279 | QuantizedActivationFunctionsSmallDataset)) |
| 280 | { |
| 281 | // Validate output |
| 282 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 283 | } |
| 284 | TEST_SUITE_END() // QASYMM8_SIGNED |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 285 | TEST_SUITE(QSYMM8_PER_CHANNEL) |
| 286 | |
morgolock | d13931d | 2020-06-23 15:49:35 +0100 | [diff] [blame] | 287 | FIXTURE_DATA_TEST_CASE(RunSmallSigned, CLGEMMConvolutionLayerQuantizedPerChannelFixture<int8_t>, framework::DatasetMode::ALL, |
| 288 | combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 289 | framework::dataset::make("ReshapeWeights", { true })), |
| 290 | framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED })), |
| 291 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 292 | QuantizationData), |
| 293 | QuantizedActivationFunctionsSmallDataset), |
| 294 | framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL }))) |
| 295 | { |
| 296 | // Validate output |
| 297 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 298 | } |
| 299 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 300 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMConvolutionLayerQuantizedPerChannelFixture<uint8_t>, framework::DatasetMode::ALL, |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 301 | combine(combine(combine(combine(combine(combine(datasets::SmallConvolutionLayerDataset(), |
| 302 | framework::dataset::make("ReshapeWeights", { true })), |
| 303 | framework::dataset::make("DataType", { DataType::QASYMM8 })), |
| 304 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 305 | QuantizationData), |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 306 | QuantizedActivationFunctionsSmallDataset), |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame] | 307 | framework::dataset::make("WeightsDataType", { DataType::QSYMM8_PER_CHANNEL }))) |
| 308 | { |
| 309 | // Validate output |
| 310 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 311 | } |
| 312 | TEST_SUITE_END() // QSYMM8_PER_CHANNEL |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 313 | TEST_SUITE_END() // Quantized |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 314 | |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 315 | TEST_SUITE_END() // GEMMConvolutionLayer |
| 316 | |
| 317 | template <typename T> |
| 318 | using CLGEMMGroupedConvolutionLayerFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLGEMMConvolutionLayer, T>; |
| 319 | |
| 320 | TEST_SUITE(GroupedGEMMConvolutionLayer) |
| 321 | |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 322 | TEST_SUITE(Float) |
| 323 | TEST_SUITE(FP32) |
| 324 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 325 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(), |
| 326 | framework::dataset::make("ReshapeWeights", { true })), |
| 327 | framework::dataset::make("DataType", DataType::F32)), |
| 328 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 329 | ActivationFunctionsSmallDataset)) |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 330 | { |
| 331 | // Validate output |
| 332 | validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num); |
| 333 | } |
| 334 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 335 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMGroupedConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 336 | combine(combine(combine(combine(datasets::LargeGroupedConvolutionLayerDataset(), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 337 | framework::dataset::make("ReshapeWeights", { true })), |
| 338 | framework::dataset::make("DataType", DataType::F32)), |
| 339 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 340 | ActivationFunctionsDataset)) |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 341 | { |
| 342 | // Validate output |
| 343 | validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num); |
| 344 | } |
| 345 | TEST_SUITE_END() // FP32 |
| 346 | |
| 347 | TEST_SUITE(FP16) |
| 348 | |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 349 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMGroupedConvolutionLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallGroupedConvolutionLayerDataset(), |
| 350 | framework::dataset::make("ReshapeWeights", { true })), |
| 351 | framework::dataset::make("DataType", DataType::F16)), |
| 352 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 353 | ActivationFunctionsSmallDataset)) |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 354 | { |
| 355 | // Validate output |
| 356 | validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num); |
| 357 | } |
| 358 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 359 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMGroupedConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, |
Michele Di Giorgio | e37662a | 2020-04-29 15:14:18 +0100 | [diff] [blame] | 360 | combine(combine(combine(combine(datasets::LargeGroupedConvolutionLayerDataset(), |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 361 | framework::dataset::make("ReshapeWeights", { true })), |
| 362 | framework::dataset::make("DataType", DataType::F16)), |
| 363 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 364 | ActivationFunctionsDataset)) |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 365 | { |
| 366 | // Validate output |
| 367 | validate(CLAccessor(_target), _reference, tolerance_f32, tolerance_num); |
| 368 | } |
| 369 | TEST_SUITE_END() // FP16 |
| 370 | TEST_SUITE_END() // Float |
| 371 | |
| 372 | TEST_SUITE_END() // GroupedGEMMConvolutionLayer |
| 373 | TEST_SUITE_END() // CL |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 374 | } // namespace validation |
| 375 | } // namespace test |
| 376 | } // namespace arm_compute |