Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 1 | /* |
Ramy Elgammal | 73f19af | 2022-10-23 11:44:49 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2017-2022 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/CL/CLTensor.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 27 | #include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/PaddingCalculator.h" |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 30 | #include "tests/datasets/DirectConvolutionLayerDataset.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 31 | #include "tests/datasets/ShapeDatasets.h" |
| 32 | #include "tests/framework/Asserts.h" |
| 33 | #include "tests/framework/Macros.h" |
| 34 | #include "tests/framework/datasets/Datasets.h" |
| 35 | #include "tests/validation/Validation.h" |
| 36 | #include "tests/validation/fixtures/DirectConvolutionLayerFixture.h" |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 46 | RelativeTolerance<half> tolerance_fp16(half(0.2)); /**< Tolerance for floating point tests */ |
| 47 | RelativeTolerance<float> tolerance_fp32(0.05f); /**< Tolerance for floating point tests */ |
| 48 | constexpr float abs_tolerance_f32(0.0001f); /**< Absolute tolerance for FP32 tests*/ |
| 49 | |
| 50 | constexpr float tolerance_num = 0.07f; /**< Tolerance number */ |
| 51 | constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance for quantized tests */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 52 | |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 53 | const auto data_strides = combine(framework::dataset::make("StrideX", 1, 3), framework::dataset::make("StrideY", 1, 3)); |
| 54 | const auto data_strides_small = combine(framework::dataset::make("StrideX", 1), framework::dataset::make("StrideY", 1)); |
| 55 | const auto data_ksize_one = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 1))); |
| 56 | const auto data_ksize_one_small = combine(framework::dataset::make("PadX", 0), combine(framework::dataset::make("PadY", 0), framework::dataset::make("KernelSize", 1))); |
| 57 | const auto data_ksize_three = combine(framework::dataset::make("PadX", 0, 2), combine(framework::dataset::make("PadY", 0, 2), framework::dataset::make("KernelSize", 3))); |
| 58 | const auto data_ksize_five = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 5))); |
| 59 | const auto data_ksize_nine = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 9))); |
| 60 | const auto data_ksize_nine_small = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 9))); |
Michalis Spyrou | def665a | 2017-08-14 11:26:37 +0100 | [diff] [blame] | 61 | |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 62 | const auto data_all_kernels = concat(concat(data_ksize_one, data_ksize_three), data_ksize_five); |
| 63 | |
| 64 | const auto data = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_all_kernels)); |
| 65 | const auto data9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_ksize_nine)); |
| 66 | const auto data_small = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_one_small)); |
| 67 | const auto data_small9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_nine_small)); |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 68 | |
| 69 | /** Direct convolution nightly data set. */ |
Michele Di Giorgio | ba2cc1a | 2020-07-15 17:39:30 +0100 | [diff] [blame] | 70 | const auto data_nightly = combine(data, framework::dataset::make("NumKernels", { 1, 4 })); |
| 71 | const auto data_nightly_9x9 = combine(data9x9, framework::dataset::make("NumKernels", { 1, 4 })); |
| 72 | const auto data_nightly_usecase = combine(framework::dataset::make("InputShape", { TensorShape{ 3U, 800U, 800U } }), |
| 73 | combine(framework::dataset::make("StrideX", { 1 }), |
| 74 | combine(framework::dataset::make("StrideY", { 1 }), |
| 75 | combine(framework::dataset::make("PadX", { 4 }), |
| 76 | combine(framework::dataset::make("PadY", { 4 }), |
| 77 | combine(framework::dataset::make("KernelSize", 9), |
| 78 | framework::dataset::make("NumKernels", { 16 }))))))); |
| 79 | |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 80 | /** Direct convolution precommit data set. */ |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 81 | const auto data_precommit = combine(data_small, framework::dataset::make("NumKernels", { 1 })); |
| 82 | const auto data_precommit_9x9 = combine(data_small9x9, framework::dataset::make("NumKernels", { 1 })); |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 83 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 84 | /** Activation function Dataset*/ |
| 85 | const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
Michalis Spyrou | 5ce99a2 | 2019-01-25 14:17:49 +0000 | [diff] [blame] | 86 | { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) }); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 87 | } // namespace |
| 88 | |
| 89 | TEST_SUITE(CL) |
| 90 | TEST_SUITE(DirectConvolutionLayer) |
| 91 | |
Michele Di Giorgio | 97e2580 | 2021-03-25 12:37:45 +0000 | [diff] [blame] | 92 | /** Check whether the configuration of a Direct Convolution layer with no |
| 93 | * bias leads to a successful execution. |
| 94 | */ |
| 95 | TEST_CASE(NoBias, framework::DatasetMode::PRECOMMIT) |
| 96 | { |
| 97 | const auto src_shape = TensorShape(27U, 13U, 2U); |
| 98 | const auto weights_shape = TensorShape(3U, 3U, 2U, 4U); |
| 99 | const auto bias_shape = TensorShape(4U); |
| 100 | const auto dst_shape = TensorShape(25U, 11U, 4U); |
| 101 | constexpr auto dt = DataType::F32; |
| 102 | |
| 103 | auto src = create_tensor<CLTensor>(src_shape, dt); |
| 104 | auto weights = create_tensor<CLTensor>(weights_shape, dt); |
| 105 | auto dst = create_tensor<CLTensor>(dst_shape, dt); |
| 106 | |
| 107 | const auto conv_info = PadStrideInfo(1, 1, 0, 0); |
| 108 | |
| 109 | // Create Direct Convolution function |
| 110 | CLDirectConvolutionLayer conv{}; |
| 111 | conv.configure(&src, &weights, nullptr, &dst, conv_info); |
| 112 | |
| 113 | src.allocator()->allocate(); |
| 114 | weights.allocator()->allocate(); |
| 115 | dst.allocator()->allocate(); |
| 116 | |
| 117 | library->fill_tensor_value(CLAccessor(src), 1.f); |
| 118 | library->fill_tensor_value(CLAccessor(weights), 1.f); |
| 119 | |
| 120 | conv.run(); |
| 121 | |
| 122 | // Compute reference to compare |
| 123 | SimpleTensor<float> ref_src{ src_shape, dt }; |
| 124 | SimpleTensor<float> ref_weights{ weights_shape, dt }; |
| 125 | SimpleTensor<float> ref_bias{ bias_shape, dt }; |
| 126 | library->fill_tensor_value(ref_src, 1.f); |
| 127 | library->fill_tensor_value(ref_weights, 1.f); |
| 128 | // No bias |
| 129 | library->fill_tensor_value(ref_bias, 0.f); |
| 130 | auto ref_dst = reference::convolution_layer<float>(ref_src, ref_weights, ref_bias, dst_shape, conv_info); |
| 131 | |
| 132 | validate(CLAccessor(dst), ref_dst); |
| 133 | } |
| 134 | |
Ramy Elgammal | 73f19af | 2022-10-23 11:44:49 +0100 | [diff] [blame^] | 135 | /** Check whether the case of rectangle kernels i.e. when width and height of the weight_shape are not equal |
| 136 | * would lead to successful run |
| 137 | */ |
| 138 | TEST_CASE(NonSquareKernel, framework::DatasetMode::PRECOMMIT) |
| 139 | { |
| 140 | auto src_shape = TensorShape(33U, 27U, 3U); |
| 141 | auto weights_shape = TensorShape(5U, 7U, 3U, 4U); // non-square kernel |
| 142 | const auto bias_shape = TensorShape(4U); |
| 143 | auto dst_shape = TensorShape(11U, 12U, 4U); |
| 144 | constexpr auto dt = DataType::F32; |
| 145 | |
| 146 | TensorShape src_shape_nhwc(src_shape); |
| 147 | TensorShape weights_shape_nhwc(weights_shape); |
| 148 | TensorShape dst_shape_nhwc(dst_shape); |
| 149 | |
| 150 | // Non-square shapes are only allowed for NHWC |
| 151 | permute(src_shape_nhwc, PermutationVector(2U, 0U, 1U)); |
| 152 | permute(weights_shape_nhwc, PermutationVector(2U, 0U, 1U)); |
| 153 | permute(dst_shape_nhwc, PermutationVector(2U, 0U, 1U)); |
| 154 | |
| 155 | auto src = create_tensor<CLTensor>(src_shape_nhwc, dt, 1, QuantizationInfo(), DataLayout::NHWC); |
| 156 | auto weights = create_tensor<CLTensor>(weights_shape_nhwc, dt, 1, QuantizationInfo(), DataLayout::NHWC); |
| 157 | auto dst = create_tensor<CLTensor>(dst_shape_nhwc, dt, 1, QuantizationInfo(), DataLayout::NHWC); |
| 158 | const auto conv_info = PadStrideInfo(3, 2, 1, 1, 2, 0, DimensionRoundingType::FLOOR); |
| 159 | |
| 160 | // Create direct convolution function |
| 161 | CLDirectConvolutionLayer conv{}; |
| 162 | conv.configure(&src, &weights, nullptr, &dst, conv_info); |
| 163 | |
| 164 | src.allocator()->allocate(); |
| 165 | weights.allocator()->allocate(); |
| 166 | dst.allocator()->allocate(); |
| 167 | |
| 168 | library->fill_tensor_value(CLAccessor(src), 1.f); |
| 169 | library->fill_tensor_value(CLAccessor(weights), 1.f); |
| 170 | |
| 171 | conv.run(); |
| 172 | |
| 173 | // Compute reference to compare |
| 174 | SimpleTensor<float> ref_src{ src_shape, dt }; |
| 175 | SimpleTensor<float> ref_weights{ weights_shape, dt }; |
| 176 | SimpleTensor<float> ref_bias{ bias_shape, dt }; |
| 177 | library->fill_tensor_value(ref_src, 1.f); |
| 178 | library->fill_tensor_value(ref_weights, 1.f); |
| 179 | // No bias |
| 180 | library->fill_tensor_value(ref_bias, 0.f); |
| 181 | auto ref_dst = reference::convolution_layer<float>(ref_src, ref_weights, ref_bias, dst_shape, conv_info); |
| 182 | |
| 183 | validate(CLAccessor(dst), ref_dst); |
| 184 | } |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 185 | // *INDENT-OFF* |
| 186 | // clang-format off |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 187 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip( |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 188 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/weights |
| 189 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching input feature maps |
| 190 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Unsupported kernel width |
| 191 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Non-rectangular weights dimensions |
| 192 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid weights dimensions |
| 193 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid stride |
| 194 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases size |
| 195 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases dimensions |
| 196 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid output size |
| 197 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Window shrink |
| 198 | TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 199 | }), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 200 | framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F16), |
| 201 | TensorInfo(TensorShape(3U, 3U, 3U, 4U), 1, DataType::F32), |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 202 | TensorInfo(TensorShape(11U, 11U, 2U, 4U), 1, DataType::F32), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 203 | TensorInfo(TensorShape(5U, 3U, 2U, 4U), 1, DataType::F32), |
| 204 | TensorInfo(TensorShape(3U, 3U, 2U, 4U, 3U), 1, DataType::F32), |
| 205 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 206 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 207 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 208 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 209 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 210 | TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 211 | })), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 212 | framework::dataset::make("BiasesInfo",{ TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 213 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 214 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 215 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 216 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 217 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 218 | TensorInfo(TensorShape(3U), 1, DataType::F32), |
| 219 | TensorInfo(TensorShape(4U, 2U), 1, DataType::F32), |
| 220 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 221 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 222 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 223 | })), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 224 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 225 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 226 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 227 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 228 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 229 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 230 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 231 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 232 | TensorInfo(TensorShape(26U, 11U, 4U), 1, DataType::F32), |
| 233 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 234 | TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 235 | })), |
| 236 | framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0), |
| 237 | PadStrideInfo(1, 1, 0, 0), |
| 238 | PadStrideInfo(1, 1, 0, 0), |
| 239 | PadStrideInfo(1, 1, 0, 0), |
| 240 | PadStrideInfo(1, 1, 0, 0), |
| 241 | PadStrideInfo(3, 3, 0, 0), |
| 242 | PadStrideInfo(1, 1, 0, 0), |
| 243 | PadStrideInfo(1, 1, 0, 0), |
| 244 | PadStrideInfo(1, 1, 0, 0), |
| 245 | PadStrideInfo(1, 1, 0, 0), |
Giorgio Arena | 5948634 | 2017-12-01 10:42:47 +0000 | [diff] [blame] | 246 | PadStrideInfo(1, 1, 0, 0), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 247 | })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 248 | framework::dataset::make("ActivationInfo", |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 249 | { |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 250 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) |
| 251 | })), |
| 252 | framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, false, false, true })), |
| 253 | input_info, weights_info, biases_info, output_info, conv_info, act_info, expected) |
| 254 | { |
| 255 | bool is_valid = bool(CLDirectConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &biases_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, act_info)); |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 256 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 257 | } |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 258 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 259 | template <typename T> |
| 260 | using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 261 | template <typename T> |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 262 | using CLDirectConvolutionLayerMixedDataLayoutFixture = DirectConvolutionValidationFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T, true>; |
| 263 | template <typename T> |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 264 | using CLDirectConvolutionValidationWithTensorShapesFixture = DirectConvolutionValidationWithTensorShapesFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 265 | template <typename T> |
| 266 | using CLDirectConvolutionLayerQuantizedFixture = DirectConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
| 267 | template <typename T> |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 268 | using CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture = DirectConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T, true>; |
| 269 | template <typename T> |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 270 | using CLDirectConvolutionValidationWithTensorShapesQuantizedFixture = DirectConvolutionValidationWithTensorShapesQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 271 | |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 272 | TEST_SUITE(NHWC) |
| 273 | TEST_SUITE(FP16) |
| 274 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, |
| 275 | combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 276 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 277 | TensorShape(19U, 5U, 16U, 4U), |
| 278 | TensorShape(13U, 5U, 17U, 2U), |
| 279 | TensorShape(32U, 37U, 13U) } ), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 280 | framework::dataset::make("StrideX", { 1, 3, 1, 1 })), |
| 281 | framework::dataset::make("StrideY", { 1, 3, 2, 1 })), |
| 282 | framework::dataset::make("PadX", { 1, 3, 0, 4 })), |
| 283 | framework::dataset::make("PadY", { 1, 3, 0, 4 })), |
| 284 | framework::dataset::make("KernelSize", { 3, 8, 1, 9 })), |
Gian Marco Iodice | 5c9eed8 | 2021-03-19 11:26:20 +0000 | [diff] [blame] | 285 | framework::dataset::make("NumKernels", { 17, 3, 1, 19 })), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 286 | framework::dataset::make("DataType", DataType::F16)), |
| 287 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 288 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 289 | { |
| 290 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
| 291 | } |
| 292 | |
| 293 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, |
| 294 | combine(combine(combine(zip(zip(zip(zip(zip(zip( |
| 295 | framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ), |
| 296 | framework::dataset::make("StrideX", { 1 })), |
| 297 | framework::dataset::make("StrideY", { 1 })), |
| 298 | framework::dataset::make("PadX", { 1 })), |
| 299 | framework::dataset::make("PadY", { 1 })), |
| 300 | framework::dataset::make("KernelSize", { 9 })), |
| 301 | framework::dataset::make("NumKernels", { 3 })), |
| 302 | framework::dataset::make("DataType", DataType::F16)), |
| 303 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::IDENTITY) )), |
| 304 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 305 | { |
| 306 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
| 307 | } |
| 308 | |
| 309 | TEST_SUITE_END() // FP16 |
| 310 | |
| 311 | TEST_SUITE(FP32) |
| 312 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 313 | combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 314 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 315 | TensorShape(19U, 5U, 16U, 4U), |
| 316 | TensorShape(13U, 5U, 17U, 2U), |
| 317 | TensorShape(32U, 37U, 13U) } ), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 318 | framework::dataset::make("StrideX", { 1, 3, 1, 1 })), |
| 319 | framework::dataset::make("StrideY", { 1, 3, 2, 1 })), |
| 320 | framework::dataset::make("PadX", { 1, 3, 0, 4 })), |
| 321 | framework::dataset::make("PadY", { 1, 3, 0, 4 })), |
| 322 | framework::dataset::make("KernelSize", { 3, 8, 1, 9 })), |
Gian Marco Iodice | 5c9eed8 | 2021-03-19 11:26:20 +0000 | [diff] [blame] | 323 | framework::dataset::make("NumKernels", { 17, 3, 1, 19 })), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 324 | framework::dataset::make("DataType", DataType::F32)), |
| 325 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 326 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 327 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 328 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 329 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 330 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 331 | combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 332 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 333 | TensorShape(19U, 5U, 16U, 4U), |
| 334 | TensorShape(13U, 5U, 17U, 2U), |
| 335 | TensorShape(32U, 37U, 13U) } ), |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 336 | framework::dataset::make("StrideX", { 1 })), |
| 337 | framework::dataset::make("StrideY", { 2 })), |
| 338 | framework::dataset::make("PadX", { 1 })), |
| 339 | framework::dataset::make("PadY", { 3 })), |
| 340 | framework::dataset::make("KernelSize", { 3 })), |
| 341 | framework::dataset::make("NumKernels", { 3 })), |
| 342 | framework::dataset::make("DataType", DataType::F32)), |
| 343 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 344 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 345 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 346 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 347 | } |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 348 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, |
| 349 | combine(combine(combine(zip(zip(zip(zip(zip(zip( |
| 350 | framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ), |
| 351 | framework::dataset::make("StrideX", { 1 })), |
| 352 | framework::dataset::make("StrideY", { 1 })), |
| 353 | framework::dataset::make("PadX", { 1 })), |
| 354 | framework::dataset::make("PadY", { 1 })), |
| 355 | framework::dataset::make("KernelSize", { 9 })), |
| 356 | framework::dataset::make("NumKernels", { 3 })), |
| 357 | framework::dataset::make("DataType", DataType::F32)), |
| 358 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::IDENTITY) )), |
| 359 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 360 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 361 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 362 | } |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 363 | TEST_SUITE_END() // FP32 |
| 364 | |
| 365 | TEST_SUITE(Quantized) |
| 366 | TEST_SUITE(QASYMM8) |
| 367 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, |
| 368 | combine(combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 369 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 370 | TensorShape(19U, 5U, 16U, 4U), |
| 371 | TensorShape(13U, 5U, 17U, 2U), |
| 372 | TensorShape(32U, 37U, 13U) } ), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 373 | framework::dataset::make("StrideX", { 1, 3, 1, 1 })), |
| 374 | framework::dataset::make("StrideY", { 1, 3, 2, 1 })), |
| 375 | framework::dataset::make("PadX", { 1, 3, 0, 4 })), |
| 376 | framework::dataset::make("PadY", { 1, 3, 0, 4 })), |
| 377 | framework::dataset::make("KernelSize", { 3, 8, 1, 9 })), |
| 378 | framework::dataset::make("NumKernels", { 7, 3, 1, 3 })), |
| 379 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 380 | framework::dataset::make("QuantizationInfo", QuantizationInfo(1.1f / 255, 10))), |
| 381 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 382 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 383 | { |
| 384 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 385 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 386 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, |
| 387 | combine(combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 388 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 389 | TensorShape(19U, 5U, 16U, 4U), |
| 390 | TensorShape(13U, 5U, 17U, 2U), |
| 391 | TensorShape(32U, 37U, 13U) } ), |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 392 | framework::dataset::make("StrideX", { 1 })), |
| 393 | framework::dataset::make("StrideY", { 2 })), |
| 394 | framework::dataset::make("PadX", { 1 })), |
| 395 | framework::dataset::make("PadY", { 1 })), |
| 396 | framework::dataset::make("KernelSize", { 3 })), |
| 397 | framework::dataset::make("NumKernels", { 3 })), |
| 398 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 399 | framework::dataset::make("QuantizationInfo", QuantizationInfo(1.1f / 255, 10))), |
| 400 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 401 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 402 | { |
| 403 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 404 | } |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 405 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, |
| 406 | combine(combine(combine(combine(zip(zip(zip(zip(zip(zip( |
| 407 | framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ), |
| 408 | framework::dataset::make("StrideX", { 1 })), |
| 409 | framework::dataset::make("StrideY", { 1 })), |
| 410 | framework::dataset::make("PadX", { 1 })), |
| 411 | framework::dataset::make("PadY", { 1 })), |
| 412 | framework::dataset::make("KernelSize", { 9 })), |
| 413 | framework::dataset::make("NumKernels", { 3 })), |
| 414 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 415 | framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))), |
| 416 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 417 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 418 | { |
| 419 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 420 | } |
| 421 | |
| 422 | TEST_SUITE_END() // QASYMM8 |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 423 | TEST_SUITE(QASYMM8_SIGNED) |
| 424 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, |
| 425 | combine(combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 426 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 427 | TensorShape(19U, 5U, 16U, 4U), |
| 428 | TensorShape(13U, 5U, 17U, 2U), |
| 429 | TensorShape(32U, 37U, 13U) } ), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 430 | framework::dataset::make("StrideX", { 1, 3, 1, 1 })), |
| 431 | framework::dataset::make("StrideY", { 1, 3, 2, 1 })), |
| 432 | framework::dataset::make("PadX", { 1, 3, 0, 4 })), |
| 433 | framework::dataset::make("PadY", { 1, 3, 0, 4 })), |
| 434 | framework::dataset::make("KernelSize", { 3, 8, 1, 9 })), |
| 435 | framework::dataset::make("NumKernels", { 7, 3, 1, 3 })), |
| 436 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 437 | framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))), |
| 438 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 439 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 440 | { |
| 441 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 442 | } |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 443 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<int8_t>, framework::DatasetMode::PRECOMMIT, |
| 444 | combine(combine(combine(combine(zip(zip(zip(zip(zip(zip( |
Gian Marco Iodice | 2ba39b6 | 2021-05-07 09:21:47 +0100 | [diff] [blame] | 445 | framework::dataset::make("InputShape", { TensorShape(27U, 13U, 23U), |
| 446 | TensorShape(19U, 5U, 16U, 4U), |
| 447 | TensorShape(13U, 5U, 17U, 2U), |
| 448 | TensorShape(32U, 37U, 13U) } ), |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 449 | framework::dataset::make("StrideX", { 1 })), |
| 450 | framework::dataset::make("StrideY", { 1 })), |
| 451 | framework::dataset::make("PadX", { 1 })), |
| 452 | framework::dataset::make("PadY", { 1 })), |
| 453 | framework::dataset::make("KernelSize", { 3 })), |
| 454 | framework::dataset::make("NumKernels", { 3 })), |
| 455 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 456 | framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))), |
| 457 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 458 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 459 | { |
| 460 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 461 | } |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 462 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, |
| 463 | combine(combine(combine(combine(zip(zip(zip(zip(zip(zip( |
| 464 | framework::dataset::make("InputShape", { TensorShape(800U, 800U, 3U) } ), |
| 465 | framework::dataset::make("StrideX", { 1 })), |
| 466 | framework::dataset::make("StrideY", { 1 })), |
| 467 | framework::dataset::make("PadX", { 1 })), |
| 468 | framework::dataset::make("PadY", { 1 })), |
| 469 | framework::dataset::make("KernelSize", { 9 })), |
| 470 | framework::dataset::make("NumKernels", { 3 })), |
| 471 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 472 | framework::dataset::make("QuantizationInfo", QuantizationInfo(2.f / 255, 10))), |
| 473 | framework::dataset::make("ActivationInfo", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) )), |
| 474 | framework::dataset::make("DataLayout", DataLayout::NHWC))) |
| 475 | { |
| 476 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 477 | } |
| 478 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 479 | TEST_SUITE_END() // Quantized |
| 480 | TEST_SUITE_END() // NHWC |
| 481 | |
| 482 | // clang-format on |
| 483 | // *INDENT-ON* |
| 484 | TEST_SUITE(NCHW) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 485 | TEST_SUITE(Float) |
| 486 | TEST_SUITE(FP16) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 487 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType", DataType::F16)), |
| 488 | ActivationFunctionsDataset), |
| 489 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 490 | { |
| 491 | // Validate output |
steniu01 | 3e05e4e | 2017-08-25 17:18:01 +0100 | [diff] [blame] | 492 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 493 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 494 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F16)), |
| 495 | ActivationFunctionsDataset), |
| 496 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
| 497 | { |
| 498 | // Validate output |
| 499 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
| 500 | } |
| 501 | TEST_SUITE_END() // FP16 |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 502 | |
| 503 | TEST_SUITE(FP32) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 504 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType", |
| 505 | DataType::F32)), |
| 506 | ActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 507 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 508 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 509 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 510 | } |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 511 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, |
| 512 | framework::dataset::make("DataType", |
| 513 | DataType::F32)), |
| 514 | ActivationFunctionsDataset), |
| 515 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 516 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 517 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 518 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 519 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F32)), |
| 520 | ActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 521 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 522 | { |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 523 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 524 | } |
| 525 | TEST_SUITE_END() // FP32 |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 526 | |
| 527 | TEST_SUITE(FP32_CustomDataset) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 528 | FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::DirectConvolutionLayerDataset(), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 529 | framework::dataset::make("DataType", DataType::F32)), |
| 530 | ActivationFunctionsDataset)) |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 531 | { |
| 532 | // Validate output |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 533 | validate(CLAccessor(_target), _reference, tolerance_fp32, 0.0, abs_tolerance_f32); |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 534 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 535 | TEST_SUITE_END() // FP32_CustomDataset |
| 536 | TEST_SUITE_END() // Float |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 537 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 538 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 539 | { |
| 540 | ActivationLayerInfo(), |
| 541 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 542 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 543 | }); |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 544 | TEST_SUITE(Quantized) |
| 545 | TEST_SUITE(QASYMM8) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 546 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit, |
| 547 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 548 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10) })), |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 549 | QuantizedActivationFunctionsDataset), |
| 550 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
| 551 | { |
| 552 | // Validate output |
| 553 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 554 | } |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 555 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit, |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 556 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 557 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })), |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 558 | QuantizedActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 559 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Sang-Hoon Park | ab5b1a2 | 2019-10-15 09:29:13 +0100 | [diff] [blame] | 560 | { |
| 561 | // Validate output |
| 562 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 563 | } |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 564 | FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit_9x9, |
| 565 | framework::dataset::make("DataType", |
| 566 | DataType::QASYMM8)), |
Manuel Bottini | 136174a | 2020-11-24 13:04:19 +0000 | [diff] [blame] | 567 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(3.f / 255, 10), QuantizationInfo(1.1f, 10) })), |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 568 | QuantizedActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 569 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 570 | { |
| 571 | // Validate output |
| 572 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 573 | } |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 574 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly, framework::dataset::make("DataType", |
Sang-Hoon Park | ab5b1a2 | 2019-10-15 09:29:13 +0100 | [diff] [blame] | 575 | DataType::QASYMM8)), |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 576 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })), |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 577 | QuantizedActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 578 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 579 | { |
| 580 | // Validate output |
| 581 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 582 | } |
| 583 | FIXTURE_DATA_TEST_CASE(RunLarge9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly_9x9, |
| 584 | framework::dataset::make("DataType", |
| 585 | DataType::QASYMM8)), |
Manuel Bottini | 136174a | 2020-11-24 13:04:19 +0000 | [diff] [blame] | 586 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(3.f / 255, 10), QuantizationInfo(1.1f, 10) })), |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 587 | QuantizedActivationFunctionsDataset), |
| 588 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Sang-Hoon Park | ab5b1a2 | 2019-10-15 09:29:13 +0100 | [diff] [blame] | 589 | { |
| 590 | // Validate output |
| 591 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 592 | } |
| 593 | |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 594 | TEST_SUITE_END() // QASYMM8 |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 595 | |
| 596 | TEST_SUITE(QASYMM8_CustomDataset) |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 597 | FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, |
| 598 | combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(), |
| 599 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 600 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })), |
| 601 | QuantizedActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 602 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 603 | { |
| 604 | // Validate output |
| 605 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 606 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 607 | TEST_SUITE_END() // QASYMM8_CustomDataset |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 608 | |
| 609 | TEST_SUITE(QASYMM8_SIGNED) |
| 610 | |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 611 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit, framework::dataset::make("DataType", |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 612 | DataType::QASYMM8_SIGNED)), |
| 613 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, -10) })), |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 614 | QuantizedActivationFunctionsDataset), |
| 615 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 616 | { |
| 617 | // Validate output |
| 618 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 619 | } |
Gunes Bayir | 38ce29d | 2021-08-04 12:45:33 +0100 | [diff] [blame] | 620 | FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLDirectConvolutionLayerQuantizedMixedDataLayoutFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit, |
| 621 | framework::dataset::make("DataType", |
| 622 | DataType::QASYMM8_SIGNED)), |
| 623 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.1f, -10) })), |
| 624 | QuantizedActivationFunctionsDataset), |
| 625 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Manuel Bottini | ca62c6f | 2021-03-23 11:50:34 +0000 | [diff] [blame] | 626 | { |
| 627 | // Validate output |
| 628 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 629 | } |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 630 | FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(combine(data_precommit_9x9, |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 631 | framework::dataset::make("DataType", |
| 632 | DataType::QASYMM8_SIGNED)), |
| 633 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })), |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 634 | QuantizedActivationFunctionsDataset), |
| 635 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 636 | { |
| 637 | // Validate output |
| 638 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 639 | } |
| 640 | |
| 641 | FIXTURE_DATA_TEST_CASE(RunCustomDataset, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 642 | combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(), |
| 643 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 644 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })), |
| 645 | QuantizedActivationFunctionsDataset), |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 646 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 647 | { |
| 648 | // Validate output |
| 649 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 650 | } |
| 651 | |
| 652 | TEST_SUITE_END() // QASYMM8_SIGNED |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 653 | TEST_SUITE_END() // Quantized |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 654 | TEST_SUITE_END() // NCHW |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 655 | TEST_SUITE_END() // DirectConvolutionLayer |
Gian Marco Iodice | 0841ca0 | 2021-02-01 14:37:02 +0000 | [diff] [blame] | 656 | TEST_SUITE_END() // CL |
| 657 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 658 | } // namespace validation |
| 659 | } // namespace test |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 660 | } // namespace arm_compute |