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, |
| 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 | { |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 46 | // COMPMID-517 Investigate the mismatch to see whether it is a real bug |
Pablo Tello | d041a83 | 2018-10-03 17:11:09 +0100 | [diff] [blame] | 47 | RelativeTolerance<half> tolerance_fp16(half(0.2)); /**< Tolerance for floating point tests */ |
Michele Di Giorgio | 954051f | 2020-07-20 10:31:09 +0100 | [diff] [blame] | 48 | RelativeTolerance<float> tolerance_fp32(0.03f); /**< Tolerance for floating point tests */ |
Pablo Tello | d041a83 | 2018-10-03 17:11:09 +0100 | [diff] [blame] | 49 | constexpr float tolerance_num = 0.07f; /**< Tolerance number */ |
| 50 | constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance for quantized tests */ |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 51 | |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 52 | const auto data_strides = combine(framework::dataset::make("StrideX", 1, 3), framework::dataset::make("StrideY", 1, 3)); |
| 53 | const auto data_strides_small = combine(framework::dataset::make("StrideX", 1), framework::dataset::make("StrideY", 1)); |
| 54 | const auto data_ksize_one = combine(framework::dataset::make("PadX", 0, 1), combine(framework::dataset::make("PadY", 0, 1), framework::dataset::make("KernelSize", 1))); |
| 55 | const auto data_ksize_one_small = combine(framework::dataset::make("PadX", 0), combine(framework::dataset::make("PadY", 0), framework::dataset::make("KernelSize", 1))); |
| 56 | const auto data_ksize_three = combine(framework::dataset::make("PadX", 0, 2), combine(framework::dataset::make("PadY", 0, 2), framework::dataset::make("KernelSize", 3))); |
| 57 | const auto data_ksize_five = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 5))); |
| 58 | const auto data_ksize_nine = combine(framework::dataset::make("PadX", 0, 3), combine(framework::dataset::make("PadY", 0, 3), framework::dataset::make("KernelSize", 9))); |
| 59 | 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] | 60 | |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 61 | const auto data_all_kernels = concat(concat(data_ksize_one, data_ksize_three), data_ksize_five); |
| 62 | |
| 63 | const auto data = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_all_kernels)); |
| 64 | const auto data9x9 = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides, data_ksize_nine)); |
| 65 | const auto data_small = combine(datasets::SmallDirectConvolutionShapes(), combine(data_strides_small, data_ksize_one_small)); |
| 66 | 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] | 67 | |
| 68 | /** Direct convolution nightly data set. */ |
Michele Di Giorgio | ba2cc1a | 2020-07-15 17:39:30 +0100 | [diff] [blame] | 69 | const auto data_nightly = combine(data, framework::dataset::make("NumKernels", { 1, 4 })); |
| 70 | const auto data_nightly_9x9 = combine(data9x9, framework::dataset::make("NumKernels", { 1, 4 })); |
| 71 | const auto data_nightly_usecase = combine(framework::dataset::make("InputShape", { TensorShape{ 3U, 800U, 800U } }), |
| 72 | combine(framework::dataset::make("StrideX", { 1 }), |
| 73 | combine(framework::dataset::make("StrideY", { 1 }), |
| 74 | combine(framework::dataset::make("PadX", { 4 }), |
| 75 | combine(framework::dataset::make("PadY", { 4 }), |
| 76 | combine(framework::dataset::make("KernelSize", 9), |
| 77 | framework::dataset::make("NumKernels", { 16 }))))))); |
| 78 | |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 79 | /** Direct convolution precommit data set. */ |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 80 | const auto data_precommit = combine(data_small, framework::dataset::make("NumKernels", { 1 })); |
| 81 | 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] | 82 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 83 | /** Activation function Dataset*/ |
| 84 | const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
Michalis Spyrou | 5ce99a2 | 2019-01-25 14:17:49 +0000 | [diff] [blame] | 85 | { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f) }); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 86 | } // namespace |
| 87 | |
| 88 | TEST_SUITE(CL) |
| 89 | TEST_SUITE(DirectConvolutionLayer) |
| 90 | |
| 91 | //TODO(COMPMID-415): Configuration tests? |
| 92 | |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 93 | // *INDENT-OFF* |
| 94 | // clang-format off |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 95 | 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] | 96 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/weights |
| 97 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching input feature maps |
| 98 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Unsupported kernel width |
| 99 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Non-rectangular weights dimensions |
| 100 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid weights dimensions |
| 101 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid stride |
| 102 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases size |
| 103 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid biases dimensions |
| 104 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Invalid output size |
| 105 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Window shrink |
| 106 | TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 107 | }), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 108 | framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F16), |
| 109 | TensorInfo(TensorShape(3U, 3U, 3U, 4U), 1, DataType::F32), |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 110 | TensorInfo(TensorShape(11U, 11U, 2U, 4U), 1, DataType::F32), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 111 | TensorInfo(TensorShape(5U, 3U, 2U, 4U), 1, DataType::F32), |
| 112 | TensorInfo(TensorShape(3U, 3U, 2U, 4U, 3U), 1, DataType::F32), |
| 113 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 114 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 115 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 116 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 117 | TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), |
| 118 | TensorInfo(TensorShape(1U, 1U, 2U, 4U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 119 | })), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 120 | framework::dataset::make("BiasesInfo",{ TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 121 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 122 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 123 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 124 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 125 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 126 | TensorInfo(TensorShape(3U), 1, DataType::F32), |
| 127 | TensorInfo(TensorShape(4U, 2U), 1, DataType::F32), |
| 128 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 129 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
| 130 | TensorInfo(TensorShape(4U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 131 | })), |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 132 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 133 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 134 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 135 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 136 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 137 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 138 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 139 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 140 | TensorInfo(TensorShape(26U, 11U, 4U), 1, DataType::F32), |
| 141 | TensorInfo(TensorShape(25U, 11U, 4U), 1, DataType::F32), |
| 142 | TensorInfo(TensorShape(32U, 16U, 4U), 1, DataType::F32), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 143 | })), |
| 144 | framework::dataset::make("ConvInfo", { PadStrideInfo(1, 1, 0, 0), |
| 145 | PadStrideInfo(1, 1, 0, 0), |
| 146 | PadStrideInfo(1, 1, 0, 0), |
| 147 | PadStrideInfo(1, 1, 0, 0), |
| 148 | PadStrideInfo(1, 1, 0, 0), |
| 149 | PadStrideInfo(3, 3, 0, 0), |
| 150 | PadStrideInfo(1, 1, 0, 0), |
| 151 | PadStrideInfo(1, 1, 0, 0), |
| 152 | PadStrideInfo(1, 1, 0, 0), |
| 153 | PadStrideInfo(1, 1, 0, 0), |
Giorgio Arena | 5948634 | 2017-12-01 10:42:47 +0000 | [diff] [blame] | 154 | PadStrideInfo(1, 1, 0, 0), |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 155 | })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 156 | framework::dataset::make("ActivationInfo", |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 157 | { |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 158 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) |
| 159 | })), |
| 160 | framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, false, false, true })), |
| 161 | input_info, weights_info, biases_info, output_info, conv_info, act_info, expected) |
| 162 | { |
| 163 | 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] | 164 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
Georgios Pinitas | 30902ed | 2017-11-14 15:32:57 +0000 | [diff] [blame] | 165 | } |
| 166 | // clang-format on |
| 167 | // *INDENT-ON* |
| 168 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 169 | template <typename T> |
| 170 | using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 171 | template <typename T> |
| 172 | using CLDirectConvolutionValidationWithTensorShapesFixture = DirectConvolutionValidationWithTensorShapesFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 173 | |
| 174 | TEST_SUITE(Float) |
| 175 | TEST_SUITE(FP16) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 176 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType", DataType::F16)), |
| 177 | ActivationFunctionsDataset), |
| 178 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 179 | { |
| 180 | // Validate output |
steniu01 | 3e05e4e | 2017-08-25 17:18:01 +0100 | [diff] [blame] | 181 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 182 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 183 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F16)), |
| 184 | ActivationFunctionsDataset), |
| 185 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
| 186 | { |
| 187 | // Validate output |
| 188 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
| 189 | } |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 190 | FIXTURE_DATA_TEST_CASE(RunLarge9x9, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly_9x9, framework::dataset::make("DataType", |
| 191 | DataType::F16)), |
| 192 | ActivationFunctionsDataset), |
| 193 | framework::dataset::make("DataLayout", { DataLayout::NHWC }))) |
| 194 | { |
| 195 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
| 196 | } |
| 197 | FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit_9x9, framework::dataset::make("DataType", |
| 198 | DataType::F16)), |
| 199 | ActivationFunctionsDataset), |
| 200 | framework::dataset::make("DataLayout", { DataLayout::NHWC }))) |
| 201 | { |
| 202 | validate(CLAccessor(_target), _reference, tolerance_fp16, tolerance_num); |
| 203 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 204 | TEST_SUITE_END() // FP16 |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 205 | |
| 206 | TEST_SUITE(FP32) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 207 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit, framework::dataset::make("DataType", |
| 208 | DataType::F32)), |
| 209 | ActivationFunctionsDataset), |
| 210 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 211 | { |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 212 | validate(CLAccessor(_target), _reference, tolerance_fp32); |
| 213 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 214 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly, framework::dataset::make("DataType", DataType::F32)), |
| 215 | ActivationFunctionsDataset), |
| 216 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 217 | { |
| 218 | validate(CLAccessor(_target), _reference, tolerance_fp32); |
| 219 | } |
Michalis Spyrou | 4509173 | 2019-05-13 17:41:01 +0100 | [diff] [blame] | 220 | FIXTURE_DATA_TEST_CASE(RunLarge9x9, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly_9x9, framework::dataset::make("DataType", |
| 221 | DataType::F32)), |
| 222 | ActivationFunctionsDataset), |
| 223 | framework::dataset::make("DataLayout", { DataLayout::NHWC }))) |
| 224 | { |
| 225 | validate(CLAccessor(_target), _reference, tolerance_fp32); |
| 226 | } |
| 227 | FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(data_precommit_9x9, framework::dataset::make("DataType", |
| 228 | DataType::F32)), |
| 229 | ActivationFunctionsDataset), |
| 230 | framework::dataset::make("DataLayout", { DataLayout::NHWC }))) |
| 231 | { |
| 232 | validate(CLAccessor(_target), _reference, tolerance_fp32); |
| 233 | } |
Michele Di Giorgio | ba2cc1a | 2020-07-15 17:39:30 +0100 | [diff] [blame] | 234 | |
| 235 | FIXTURE_DATA_TEST_CASE(RunLargeUsecase, CLDirectConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(data_nightly_usecase, framework::dataset::make("DataType", |
| 236 | DataType::F32)), |
| 237 | framework::dataset::make("ActivationInfo", { ActivationLayerInfo() })), |
| 238 | framework::dataset::make("DataLayout", { DataLayout::NHWC }))) |
| 239 | { |
| 240 | // Validate output |
| 241 | validate(CLAccessor(_target), _reference, tolerance_fp32); |
| 242 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 243 | TEST_SUITE_END() // FP32 |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 244 | |
| 245 | TEST_SUITE(FP32_CustomDataset) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 246 | 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] | 247 | framework::dataset::make("DataType", DataType::F32)), |
| 248 | ActivationFunctionsDataset)) |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 249 | { |
| 250 | // Validate output |
| 251 | validate(CLAccessor(_target), _reference, tolerance_fp32); |
| 252 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 253 | TEST_SUITE_END() // FP32_CustomDataset |
| 254 | TEST_SUITE_END() // Float |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 255 | |
Michalis Spyrou | def665a | 2017-08-14 11:26:37 +0100 | [diff] [blame] | 256 | template <typename T> |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 257 | using CLDirectConvolutionLayerQuantizedFixture = DirectConvolutionValidationQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 258 | template <typename T> |
| 259 | using CLDirectConvolutionValidationWithTensorShapesQuantizedFixture = DirectConvolutionValidationWithTensorShapesQuantizedFixture<CLTensor, CLAccessor, CLDirectConvolutionLayer, T>; |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 260 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 261 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 262 | { |
| 263 | ActivationLayerInfo(), |
| 264 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 265 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 6.f) |
| 266 | }); |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 267 | TEST_SUITE(Quantized) |
| 268 | TEST_SUITE(QASYMM8) |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 269 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit, |
Sang-Hoon Park | ab5b1a2 | 2019-10-15 09:29:13 +0100 | [diff] [blame] | 270 | framework::dataset::make("DataType", |
| 271 | DataType::QASYMM8)), |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 272 | 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] | 273 | QuantizedActivationFunctionsDataset), |
| 274 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Sang-Hoon Park | ab5b1a2 | 2019-10-15 09:29:13 +0100 | [diff] [blame] | 275 | { |
| 276 | // Validate output |
| 277 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 278 | } |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 279 | FIXTURE_DATA_TEST_CASE(RunSmall9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(data_precommit_9x9, |
| 280 | framework::dataset::make("DataType", |
| 281 | DataType::QASYMM8)), |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 282 | 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] | 283 | QuantizedActivationFunctionsDataset), |
Georgios Pinitas | aa95ddc | 2020-07-21 22:45:13 +0100 | [diff] [blame^] | 284 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 285 | { |
| 286 | // Validate output |
| 287 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 288 | } |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 289 | 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] | 290 | DataType::QASYMM8)), |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 291 | 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] | 292 | QuantizedActivationFunctionsDataset), |
| 293 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
| 294 | { |
| 295 | // Validate output |
| 296 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 297 | } |
| 298 | FIXTURE_DATA_TEST_CASE(RunLarge9x9, CLDirectConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(data_nightly_9x9, |
| 299 | framework::dataset::make("DataType", |
| 300 | DataType::QASYMM8)), |
| 301 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 10), QuantizationInfo(1.1f, 10) })), |
| 302 | QuantizedActivationFunctionsDataset), |
| 303 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Sang-Hoon Park | ab5b1a2 | 2019-10-15 09:29:13 +0100 | [diff] [blame] | 304 | { |
| 305 | // Validate output |
| 306 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 307 | } |
| 308 | |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 309 | TEST_SUITE_END() // QASYMM8 |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 310 | |
| 311 | TEST_SUITE(QASYMM8_CustomDataset) |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 312 | FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, |
| 313 | combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(), |
| 314 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 315 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })), |
| 316 | QuantizedActivationFunctionsDataset), |
| 317 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Jaroslaw Rzepecki | 2ecbada | 2017-11-29 13:51:34 +0000 | [diff] [blame] | 318 | { |
| 319 | // Validate output |
| 320 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 321 | } |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 322 | TEST_SUITE_END() // QASYMM8_CustomDataset |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 323 | |
| 324 | TEST_SUITE(QASYMM8_SIGNED) |
| 325 | |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 326 | 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] | 327 | DataType::QASYMM8_SIGNED)), |
| 328 | 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] | 329 | QuantizedActivationFunctionsDataset), |
| 330 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 331 | { |
| 332 | // Validate output |
| 333 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 334 | } |
| 335 | |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 336 | 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] | 337 | framework::dataset::make("DataType", |
| 338 | DataType::QASYMM8_SIGNED)), |
| 339 | 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] | 340 | QuantizedActivationFunctionsDataset), |
| 341 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 342 | { |
| 343 | // Validate output |
| 344 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 345 | } |
| 346 | |
| 347 | FIXTURE_DATA_TEST_CASE(RunCustomDataset, CLDirectConvolutionValidationWithTensorShapesQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, |
Giorgio Arena | e620a83 | 2020-02-17 16:33:20 +0000 | [diff] [blame] | 348 | combine(combine(combine(combine(datasets::DirectConvolutionLayerDataset(), |
| 349 | framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 350 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(2.f / 255, 127), QuantizationInfo(1.1f, 10) })), |
| 351 | QuantizedActivationFunctionsDataset), |
| 352 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) |
Sheri Zhang | 681f2d4 | 2020-02-20 11:23:08 +0000 | [diff] [blame] | 353 | { |
| 354 | // Validate output |
| 355 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 356 | } |
| 357 | |
| 358 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 359 | |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 360 | TEST_SUITE_END() // Quantized |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 361 | |
Michalis Spyrou | 064add6 | 2018-11-01 18:14:27 +0000 | [diff] [blame] | 362 | TEST_SUITE_END() // DirectConvolutionLayer |
| 363 | TEST_SUITE_END() // Float |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 364 | } // namespace validation |
| 365 | } // namespace test |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 366 | } // namespace arm_compute |