Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 Arm Limited. |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +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/CL/kernels/CLIm2ColKernel.h" |
| 25 | #include "arm_compute/core/Types.h" |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 26 | |
| 27 | #include "tests/CL/CLAccessor.h" |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 28 | #include "tests/CL/Helper.h" |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 29 | #include "tests/framework/Asserts.h" |
| 30 | #include "tests/framework/Macros.h" |
| 31 | #include "tests/framework/datasets/Datasets.h" |
| 32 | #include "tests/validation/Validation.h" |
| 33 | #include "tests/validation/fixtures/Im2ColFixture.h" |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace test |
| 38 | { |
| 39 | namespace validation |
| 40 | { |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 41 | TEST_SUITE(CL) |
| 42 | TEST_SUITE(Im2Col) |
| 43 | |
| 44 | using CLIm2Col = CLSynthetizeFunction<CLIm2ColKernel>; |
| 45 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 46 | /** Negative tests |
| 47 | * |
| 48 | * A series of validation tests on configurations which according to the API specification |
| 49 | * the function should fail against. |
| 50 | * |
| 51 | * Checks performed in order: |
| 52 | * - Pass unsupported data type for input |
| 53 | * - Pass a quantized input and ask to compress the bias into the resulting matrix |
| 54 | * - Pass a dilation factor of 0 |
| 55 | * - Check NHWC data layout while requesting to perform a grouped operation |
| 56 | * - Check NCHW grouped operation when the number of channels is not multiple of the groups |
| 57 | * - Pass an invalid output shape |
| 58 | */ |
| 59 | TEST_CASE(Negative, framework::DatasetMode::ALL) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 60 | { |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 61 | // Unsupported data type |
| 62 | { |
| 63 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::SIZET); |
| 64 | const auto output = TensorInfo(TensorShape(9U, 10U, 12U, 2U), 1, DataType::F32); |
| 65 | const auto conv_size = Size2D(3, 3); |
| 66 | const bool has_bias = false; |
| 67 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias); |
| 68 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 69 | } |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 70 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 71 | // Passing quantized input and ask to merge the bias in the output |
| 72 | { |
| 73 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::QASYMM8); |
| 74 | const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::QASYMM8); |
| 75 | const auto conv_size = Size2D(3, 3); |
| 76 | const bool has_bias = true; |
| 77 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias); |
| 78 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 79 | } |
| 80 | |
| 81 | // Invalid dilation |
| 82 | { |
| 83 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32); |
| 84 | const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::F32); |
| 85 | const auto conv_size = Size2D(3, 3); |
| 86 | const auto dilation = Size2D(0, 1); |
| 87 | const bool has_bias = false; |
| 88 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias, dilation); |
| 89 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 90 | } |
| 91 | |
| 92 | // NHWC and grouping greater than 1 |
| 93 | { |
| 94 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC); |
| 95 | const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::F32); |
| 96 | const auto conv_size = Size2D(3, 3); |
| 97 | const auto dilation = Size2D(1, 1); |
| 98 | const bool has_bias = false; |
| 99 | const unsigned int num_groups = 2; |
| 100 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias, dilation, num_groups); |
| 101 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 102 | } |
| 103 | |
| 104 | // NCWH and channels % num_groups !=0 |
| 105 | { |
| 106 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32, DataLayout::NCHW); |
| 107 | const auto output = TensorInfo(TensorShape(9U, 80U, 2U), 1, DataType::F32); |
| 108 | const auto conv_size = Size2D(3, 3); |
| 109 | const auto dilation = Size2D(1, 1); |
| 110 | const bool has_bias = false; |
| 111 | const unsigned int num_groups = 2; |
| 112 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias, dilation, num_groups); |
| 113 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 114 | } |
| 115 | |
| 116 | // Invalid output shape |
| 117 | { |
| 118 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32); |
| 119 | const auto output = TensorInfo(TensorShape(9U, 81U, 2U), 1, DataType::F32); |
| 120 | const auto conv_size = Size2D(3, 3); |
| 121 | const bool has_bias = false; |
| 122 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias); |
| 123 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 124 | } |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 125 | |
| 126 | // Kernel dimensions are too big |
| 127 | { |
| 128 | const auto input = TensorInfo(TensorShape(1U, 9U, 5U, 2U), 1, DataType::F32, DataLayout::NHWC); |
| 129 | const auto output = TensorInfo(TensorShape(1U, 1U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC); |
| 130 | const auto conv_size = Size2D(9, 9); |
| 131 | const bool has_bias = false; |
| 132 | const auto status = CLIm2ColKernel::validate(&input, &output, conv_size, PadStrideInfo(), has_bias); |
| 133 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 134 | } |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 135 | } |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 136 | |
| 137 | template <typename T> |
Gian Marco Iodice | 597a856 | 2018-08-01 15:06:06 +0100 | [diff] [blame] | 138 | using CLIm2ColFixture = Im2ColValidationFixture<CLTensor, CLAccessor, CLIm2Col, T, true>; |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 139 | |
| 140 | TEST_SUITE(NHWC) |
| 141 | |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 142 | /** Test that there's no padding added to input or output as part of configure |
| 143 | * |
| 144 | * @note 2 elements processed per iteration |
| 145 | * |
| 146 | * Three tests will be run: |
| 147 | * - Channels are multiple of elements processed |
| 148 | * - Channels larger and non multiple of elements used |
| 149 | * - Channels smaller and not multiple of elements used |
| 150 | * |
| 151 | */ |
| 152 | DATA_TEST_CASE(ValidateZeroPaddingNumElemsPerIterEqual2, framework::DatasetMode::ALL, |
| 153 | combine(combine(combine(combine(combine( |
| 154 | framework::dataset::make("InputChannel", |
| 155 | { |
| 156 | 2, 9, 1, |
| 157 | }), |
| 158 | framework::dataset::make("DataType", { DataType::F32 })), |
| 159 | framework::dataset::make("Kernel", { Size2D(3, 4) })), |
| 160 | framework::dataset::make("PadStride", { PadStrideInfo(2, 1, 1, 2) })), |
| 161 | framework::dataset::make("QInfo", { QuantizationInfo() })), |
| 162 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 163 | input_channel, data_type, conv_size, pad_stride_info, qinfo, data_layout) |
| 164 | { |
| 165 | TensorShape input_shape(input_channel, 10U, 30U, 3U); |
| 166 | const bool has_bias = false; |
| 167 | |
| 168 | const auto input_info = TensorInfo(input_shape, 1, data_type, data_layout); |
| 169 | const auto output_shape = compute_im2col_conv_shape(&input_info, conv_size, pad_stride_info, has_bias, Size2D(1U, 1U), true); |
| 170 | |
| 171 | CLTensor input = create_tensor<CLTensor>(input_shape, data_type, 1, qinfo, data_layout); |
| 172 | CLTensor output = create_tensor<CLTensor>(output_shape, data_type, 1, qinfo, data_layout); |
| 173 | |
| 174 | CLIm2ColKernel im2col; |
| 175 | im2col.configure(&input, &output, conv_size, pad_stride_info, has_bias); |
| 176 | |
| 177 | // Ensure there're no paddings added at all |
| 178 | const bool no_padding = input.info()->padding().empty() && output.info()->padding().empty(); |
| 179 | ARM_COMPUTE_EXPECT(no_padding, framework::LogLevel::ERRORS); |
| 180 | } |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 181 | /** Test special kernel used for NHWC for 3x3 kernels |
| 182 | * |
| 183 | * @note 2 elements processed per iteration |
| 184 | * |
| 185 | * Three tests will be run: |
| 186 | * - Channels are multiple of elements processed |
| 187 | * - Channels larger and non multiple of elements used |
| 188 | * - Channels smaller and not multiple of elements used |
| 189 | * |
| 190 | * Kernel tested im2col3x3_nhwc |
| 191 | */ |
| 192 | FIXTURE_DATA_TEST_CASE(W3x3, |
| 193 | CLIm2ColFixture<float>, |
| 194 | framework::DatasetMode::ALL, |
| 195 | combine(combine(combine(combine(combine(combine( |
| 196 | framework::dataset::make("InputShape", |
| 197 | { |
| 198 | TensorShape(2U, 5U, 7U, 2U), TensorShape(3U, 4U, 6U, 2U), TensorShape(1U, 5U, 3U, 2U), |
| 199 | }), |
| 200 | framework::dataset::make("DataType", DataType::F32)), |
| 201 | framework::dataset::make("Kernel", Size2D(3, 3))), |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 202 | framework::dataset::make("PadStride", { PadStrideInfo(1, 2, 1, 2), PadStrideInfo(1, 1, 0, 0) })), |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 203 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 204 | framework::dataset::make("DataLayout", DataLayout::NHWC)), |
| 205 | framework::dataset::make("Groups", 1))) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 206 | { |
| 207 | // Validate output |
| 208 | validate(CLAccessor(_target), _reference); |
| 209 | } |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 210 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 211 | /** Test special kernel used for NHWC for 9x9 kernels |
| 212 | * |
| 213 | * @note 2 elements processed per iteration |
| 214 | * |
| 215 | * Three tests will be run: |
| 216 | * - Channels are multiple of elements processed |
| 217 | * - Channels larger and non multiple of elements used |
| 218 | * - Channels smaller and not multiple of elements used |
| 219 | * |
| 220 | * Kernel tested im2col9x9_nhwc |
| 221 | */ |
| 222 | FIXTURE_DATA_TEST_CASE(W9x9, |
| 223 | CLIm2ColFixture<float>, |
| 224 | framework::DatasetMode::ALL, |
| 225 | combine(combine(combine(combine(combine(combine( |
| 226 | framework::dataset::make("InputShape", |
| 227 | { |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 228 | TensorShape(2U, 13U, 15U, 2U), TensorShape(3U, 15U, 12U, 2U), TensorShape(1U, 13U, 22U, 2U), |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 229 | }), |
| 230 | framework::dataset::make("DataType", DataType::F32)), |
| 231 | framework::dataset::make("Kernel", Size2D(9, 9))), |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 232 | framework::dataset::make("PadStride", { PadStrideInfo(2, 2, 1, 2), PadStrideInfo(1, 1, 0, 0) })), |
| 233 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 234 | framework::dataset::make("DataLayout", DataLayout::NHWC)), |
| 235 | framework::dataset::make("Groups", 1))) |
| 236 | { |
| 237 | // Validate output |
| 238 | validate(CLAccessor(_target), _reference); |
| 239 | } |
| 240 | |
| 241 | /** Test generic kernel used for NHWC |
| 242 | * |
| 243 | * @note 2 elements processed per iteration |
| 244 | * |
| 245 | * Three tests will be run: |
| 246 | * - Channels are multiple of elements processed |
| 247 | * - Channels larger and non multiple of elements used |
| 248 | * - Channels smaller and not multiple of elements used |
| 249 | * |
| 250 | * Kernel tested im2col_generic_nhwc |
| 251 | */ |
| 252 | FIXTURE_DATA_TEST_CASE(Generic, |
| 253 | CLIm2ColFixture<float>, |
| 254 | framework::DatasetMode::ALL, |
| 255 | combine(combine(combine(combine(combine(combine( |
| 256 | framework::dataset::make("InputShape", |
| 257 | { |
| 258 | TensorShape(4U, 13U, 15U, 2U), TensorShape(7U, 15U, 12U, 1U), TensorShape(1U, 5U, 3U, 1U), |
| 259 | }), |
| 260 | framework::dataset::make("DataType", DataType::F32)), |
| 261 | framework::dataset::make("Kernel", Size2D(5, 3))), |
| 262 | framework::dataset::make("PadStride", { PadStrideInfo(2, 2, 1, 2), PadStrideInfo(1, 1, 0, 0) })), |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 263 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 264 | framework::dataset::make("DataLayout", DataLayout::NHWC)), |
| 265 | framework::dataset::make("Groups", 1))) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 266 | { |
| 267 | // Validate output |
| 268 | validate(CLAccessor(_target), _reference); |
| 269 | } |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 270 | TEST_SUITE_END() // NHWC |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 271 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 272 | TEST_SUITE(NCHW) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 273 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 274 | /** Test special kernel used for NCHW for 1x1 kernels with stride 1 and no padding |
| 275 | * |
| 276 | * @note 4 elements processed per iteration |
| 277 | * |
| 278 | * Three tests will be run: |
| 279 | * - Channels are multiple of elements processed |
| 280 | * - Channels larger and non multiple of elements used |
| 281 | * - Channels smaller and not multiple of elements used |
| 282 | * |
| 283 | * Kernel tested im2col1x1_stridex1_nchw |
| 284 | */ |
| 285 | FIXTURE_DATA_TEST_CASE(W1x1_Stride1_NoPad, |
| 286 | CLIm2ColFixture<float>, |
| 287 | framework::DatasetMode::ALL, |
| 288 | combine(combine(combine(combine(combine(combine( |
| 289 | framework::dataset::make("InputShape", { TensorShape(4U, 4U, 3U, 2U), TensorShape(5U, 4U, 3U, 2U), TensorShape(3U, 4U, 3U, 2U) }), |
| 290 | framework::dataset::make("DataType", DataType::F32)), |
| 291 | framework::dataset::make("Kernel", Size2D(1, 1))), |
| 292 | framework::dataset::make("PadStride", PadStrideInfo(1, 1, 0, 0))), |
| 293 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 294 | framework::dataset::make("DataLayout", DataLayout::NCHW)), |
| 295 | framework::dataset::make("Groups", 1))) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 296 | { |
| 297 | // Validate output |
| 298 | validate(CLAccessor(_target), _reference); |
| 299 | } |
| 300 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 301 | /** Test special kernel used for NCHW for 3x3 kernels |
| 302 | * |
| 303 | * @note 1 elements processed per iteration |
| 304 | * |
| 305 | * Executed single test as padding is required. |
| 306 | * |
| 307 | * Kernel tested im2col3x3_nchw |
| 308 | */ |
| 309 | FIXTURE_DATA_TEST_CASE(W3x3, |
| 310 | CLIm2ColFixture<float>, |
| 311 | framework::DatasetMode::ALL, |
| 312 | combine(combine(combine(combine(combine(combine( |
| 313 | framework::dataset::make("InputShape", TensorShape(4U, 4U, 3U, 2U)), |
| 314 | framework::dataset::make("DataType", DataType::F32)), |
| 315 | framework::dataset::make("Kernel", Size2D(3, 3))), |
| 316 | framework::dataset::make("PadStride", PadStrideInfo(1, 2, 1, 2))), |
| 317 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 318 | framework::dataset::make("DataLayout", DataLayout::NCHW)), |
| 319 | framework::dataset::make("Groups", { 1, 3 }))) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 320 | { |
| 321 | // Validate output |
| 322 | validate(CLAccessor(_target), _reference); |
| 323 | } |
| 324 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 325 | /** Test special kernel used for NCHW for 5x5 kernels |
| 326 | * |
| 327 | * @note 1 elements processed per iteration |
| 328 | * |
| 329 | * Executed single test as padding is required. |
| 330 | * |
| 331 | * Kernel tested im2col5x5_nchw |
| 332 | */ |
| 333 | FIXTURE_DATA_TEST_CASE(W5x5, |
| 334 | CLIm2ColFixture<float>, |
| 335 | framework::DatasetMode::ALL, |
| 336 | combine(combine(combine(combine(combine(combine( |
| 337 | framework::dataset::make("InputShape", TensorShape(7U, 4U, 3U, 2U)), |
| 338 | framework::dataset::make("DataType", DataType::F32)), |
| 339 | framework::dataset::make("Kernel", Size2D(5, 5))), |
| 340 | framework::dataset::make("PadStride", PadStrideInfo(2, 1, 2, 1))), |
| 341 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 342 | framework::dataset::make("DataLayout", DataLayout::NCHW)), |
| 343 | framework::dataset::make("Groups", { 1, 3 }))) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 344 | { |
| 345 | // Validate output |
| 346 | validate(CLAccessor(_target), _reference); |
| 347 | } |
| 348 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 349 | /** Test special kernel used for NCHW for 11x11 kernels when no padding present |
| 350 | * |
| 351 | * @note 1 elements processed per iteration |
| 352 | * |
| 353 | * Two tests will be run: |
| 354 | * - Without padding requirements |
| 355 | * - With padding requirements |
| 356 | * |
| 357 | * Kernel tested im2col11x11_padx0_pady0_nchw |
| 358 | */ |
| 359 | FIXTURE_DATA_TEST_CASE(W11x11_NoPad, |
| 360 | CLIm2ColFixture<float>, |
| 361 | framework::DatasetMode::ALL, |
| 362 | combine(combine(combine(combine(combine(combine( |
| 363 | framework::dataset::make("InputShape", { TensorShape(11U, 11U, 2U, 2U), TensorShape(14U, 13U, 1U, 2U) }), |
| 364 | framework::dataset::make("DataType", DataType::F32)), |
| 365 | framework::dataset::make("Kernel", Size2D(11, 11))), |
| 366 | framework::dataset::make("PadStride", PadStrideInfo(1, 1, 0, 0))), |
| 367 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 368 | framework::dataset::make("DataLayout", DataLayout::NCHW)), |
| 369 | framework::dataset::make("Groups", 1))) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 370 | { |
| 371 | // Validate output |
| 372 | validate(CLAccessor(_target), _reference); |
| 373 | } |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 374 | |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 375 | /** Test special kernel used for NCHW for kernels which do not fall in the categories above and have no padding present |
| 376 | * |
| 377 | * @note 1 elements processed per iteration |
| 378 | * |
| 379 | * Executed single test as padding is required. |
| 380 | * |
| 381 | * Kernel tested im2col_generic_padx0_pady0_nchw |
| 382 | */ |
| 383 | FIXTURE_DATA_TEST_CASE(GenericZeroPad, |
| 384 | CLIm2ColFixture<float>, |
| 385 | framework::DatasetMode::ALL, |
| 386 | combine(combine(combine(combine(combine(combine( |
| 387 | framework::dataset::make("InputShape", TensorShape(13U, 11U, 2U, 2U)), |
| 388 | framework::dataset::make("DataType", DataType::F32)), |
| 389 | framework::dataset::make("Kernel", Size2D(3, 2))), |
| 390 | framework::dataset::make("PadStride", PadStrideInfo(2, 1, 0, 0))), |
| 391 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 392 | framework::dataset::make("DataLayout", DataLayout::NCHW)), |
| 393 | framework::dataset::make("Groups", { 1, 2 }))) |
| 394 | { |
| 395 | // Validate output |
| 396 | validate(CLAccessor(_target), _reference); |
| 397 | } |
| 398 | TEST_SUITE_END() // NCHW |
| 399 | |
| 400 | /** Generic NCHW/NHWC kernel |
| 401 | * |
| 402 | * @note 1 elements processed per iteration |
| 403 | * |
| 404 | * Padding is not needed thus executed sample tests with different kernels sizes |
| 405 | * and stride/padding information |
| 406 | * |
| 407 | * Kernel tested im2col_generic_(nchw|nhwc) |
| 408 | */ |
| 409 | FIXTURE_DATA_TEST_CASE(Generic, |
| 410 | CLIm2ColFixture<float>, |
| 411 | framework::DatasetMode::ALL, |
| 412 | combine(combine(combine(combine(combine(combine( |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 413 | framework::dataset::make("InputShape", TensorShape(13U, 11U, 5U, 2U)), |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 414 | framework::dataset::make("DataType", DataType::F32)), |
| 415 | framework::dataset::make("Kernel", { Size2D(3, 2), Size2D(3, 5) })), |
| 416 | framework::dataset::make("PadStride", PadStrideInfo(2, 1, 2, 1))), |
| 417 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 418 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 419 | framework::dataset::make("Groups", 1))) |
| 420 | { |
| 421 | // Validate output |
| 422 | validate(CLAccessor(_target), _reference); |
| 423 | } |
| 424 | |
| 425 | /** Tests to check that quantized padding value is set correctly |
| 426 | * |
| 427 | * Kernels tested: |
| 428 | * - im2col_generic_nhwc |
| 429 | * - im2col_generic_nchw |
| 430 | * - im2col5x5_nchw |
| 431 | * - im2col3x3_nhwc |
| 432 | * - im2col3x3_nchw |
| 433 | * - im2col9x9_nhwc |
| 434 | */ |
| 435 | FIXTURE_DATA_TEST_CASE(Quantized, |
| 436 | CLIm2ColFixture<uint8_t>, |
| 437 | framework::DatasetMode::ALL, |
| 438 | combine(combine(combine(combine(combine(combine( |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 439 | framework::dataset::make("InputShape", TensorShape(13U, 11U, 11U, 2U)), |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 440 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 441 | framework::dataset::make("Kernel", { Size2D(1, 1), Size2D(3, 3), Size2D(5, 5), Size2D(3, 5), Size2D(9, 9) })), |
| 442 | framework::dataset::make("PadStride", { PadStrideInfo(1, 2, 1, 1) })), |
| 443 | framework::dataset::make("QInfo", QuantizationInfo(0.5f, 10))), |
| 444 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 445 | framework::dataset::make("Groups", 1))) |
| 446 | { |
| 447 | // Validate output |
| 448 | validate(CLAccessor(_target), _reference); |
| 449 | } |
| 450 | |
| 451 | /** Tests to check that half-precision execution |
| 452 | * |
| 453 | * Kernels tested: |
| 454 | * - im2col_generic_nhwc |
| 455 | * - im2col_generic_nchw |
| 456 | * - im2col5x5_nchw |
| 457 | * - im2col3x3_nhwc |
| 458 | * - im2col3x3_nchw |
| 459 | * - im2col9x9_nhwc |
| 460 | */ |
| 461 | FIXTURE_DATA_TEST_CASE(FP16, |
| 462 | CLIm2ColFixture<half>, |
| 463 | framework::DatasetMode::ALL, |
| 464 | combine(combine(combine(combine(combine(combine( |
SiCong Li | f650ea5 | 2020-08-05 15:04:00 +0100 | [diff] [blame] | 465 | framework::dataset::make("InputShape", TensorShape(13U, 11U, 11U, 2U)), |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 466 | framework::dataset::make("DataType", DataType::F16)), |
| 467 | framework::dataset::make("Kernel", { Size2D(1, 1), Size2D(3, 3), Size2D(5, 5), Size2D(3, 5), Size2D(9, 9) })), |
| 468 | framework::dataset::make("PadStride", { PadStrideInfo(1, 2, 1, 1) })), |
| 469 | framework::dataset::make("QInfo", QuantizationInfo())), |
| 470 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 471 | framework::dataset::make("Groups", 1))) |
| 472 | { |
| 473 | // Validate output |
| 474 | validate(CLAccessor(_target), _reference); |
| 475 | } |
| 476 | |
| 477 | TEST_SUITE_END() // Im2Col |
| 478 | TEST_SUITE_END() // CL |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 479 | } // namespace validation |
| 480 | } // namespace test |
| 481 | } // namespace arm_compute |