Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 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" |
| 26 | #include "tests/CL/Helper.h" |
| 27 | |
| 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/datasets/ShapeDatasets.h" |
| 30 | #include "tests/framework/Asserts.h" |
| 31 | #include "tests/framework/Macros.h" |
| 32 | #include "tests/framework/datasets/Datasets.h" |
| 33 | #include "tests/validation/Validation.h" |
| 34 | #include "tests/validation/fixtures/Im2ColFixture.h" |
| 35 | |
| 36 | namespace arm_compute |
| 37 | { |
| 38 | namespace test |
| 39 | { |
| 40 | namespace validation |
| 41 | { |
| 42 | namespace |
| 43 | { |
Gian Marco Iodice | 215b4ea | 2018-06-28 16:29:29 +0100 | [diff] [blame] | 44 | // *INDENT-OFF* |
| 45 | // clang-format off |
| 46 | const auto conv_filter_sizes = framework::dataset::make("KernelDims", { Size2D(3U, 3U), |
| 47 | Size2D(5U, 5U), |
| 48 | Size2D(3U, 1U), |
| 49 | Size2D(1U, 3U), |
| 50 | Size2D(5U, 3U), |
| 51 | Size2D(1U, 1U), |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 52 | Size2D(9U, 9U), |
Gian Marco Iodice | 215b4ea | 2018-06-28 16:29:29 +0100 | [diff] [blame] | 53 | Size2D(11U, 11U)} ); |
| 54 | const auto padstrides = framework::dataset::make("PadStride", { PadStrideInfo(1U, 1U, 0U, 0U), |
| 55 | PadStrideInfo(1U, 1U, 1U, 1U), |
| 56 | PadStrideInfo(2U, 2U, 0U, 2U) }); |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 57 | const auto conv_args = combine(combine(combine(combine(conv_filter_sizes, padstrides), |
| 58 | framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))), |
| 59 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 60 | framework::dataset::make("NumGroups", { 1 })); |
| 61 | const auto grouped_args = combine(combine(combine(combine(conv_filter_sizes, padstrides), |
| 62 | framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))), |
| 63 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 64 | framework::dataset::make("NumGroups", { 2, 3, 4 })); |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 65 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 66 | const auto conv_filter_sizes_small = framework::dataset::make("KernelDims", { Size2D(3U, 3U), |
| 67 | Size2D(3U, 1U)}); |
| 68 | const auto padstrides_small = framework::dataset::make("PadStride", {PadStrideInfo(2U, 2U, 0U, 2U)}); |
| 69 | const auto conv_args_small = combine(combine(combine(combine(conv_filter_sizes_small, padstrides_small), |
| 70 | framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))), |
| 71 | framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })), |
| 72 | framework::dataset::make("NumGroups", { 1 })); |
| 73 | const auto grouped_args_small = combine(combine(combine(combine(conv_filter_sizes_small, padstrides_small), |
| 74 | framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))), |
| 75 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 76 | framework::dataset::make("NumGroups", { 2 })); |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 77 | } // namespace |
| 78 | TEST_SUITE(CL) |
| 79 | TEST_SUITE(Im2Col) |
| 80 | |
| 81 | using CLIm2Col = CLSynthetizeFunction<CLIm2ColKernel>; |
| 82 | |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 83 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
| 84 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::U8), // Unsupported data type |
| 85 | TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::F32), // Mismatching data type |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 86 | TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::QASYMM8), // Bias not supported with QASYMM8 |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 87 | TensorInfo(TensorShape(10U, 12U, 2U, 2U), 1, DataType::QASYMM8), |
| 88 | }), |
| 89 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::F16), |
| 90 | TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::F16), |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 91 | TensorInfo(TensorShape(3U, 3U, 10U, 2U), 1, DataType::QASYMM8), |
Gian Marco Iodice | 215b4ea | 2018-06-28 16:29:29 +0100 | [diff] [blame] | 92 | TensorInfo(TensorShape(18U, 80U, 2U, 1U), 1, DataType::QASYMM8), |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 93 | })), |
Gian Marco Iodice | 215b4ea | 2018-06-28 16:29:29 +0100 | [diff] [blame] | 94 | framework::dataset::make("HasBias", { true, true, true, false })), |
| 95 | framework::dataset::make("Expected", { false, false, false, true })), |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 96 | input_info, output_info, has_bias, expected) |
| 97 | { |
| 98 | |
| 99 | bool status = bool(CLIm2Col::validate(&input_info, &output_info, Size2D(3U, 3U), PadStrideInfo(), has_bias)); |
| 100 | ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS); |
| 101 | } |
| 102 | // clang-format on |
| 103 | // *INDENT-ON* |
| 104 | |
| 105 | template <typename T> |
Gian Marco Iodice | 597a856 | 2018-08-01 15:06:06 +0100 | [diff] [blame] | 106 | using CLIm2ColFixture = Im2ColValidationFixture<CLTensor, CLAccessor, CLIm2Col, T, true>; |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 107 | TEST_SUITE(Float) |
| 108 | TEST_SUITE(FP32) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 109 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), |
| 110 | conv_args_small)) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 111 | { |
| 112 | // Validate output |
| 113 | validate(CLAccessor(_target), _reference); |
| 114 | } |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 115 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 116 | FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", |
| 117 | DataType::F32)), |
Giorgio Arena | fb62908 | 2018-08-20 18:03:27 +0100 | [diff] [blame] | 118 | conv_args)) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 119 | { |
| 120 | // Validate output |
| 121 | validate(CLAccessor(_target), _reference); |
| 122 | } |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 123 | TEST_SUITE_END() |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 124 | |
| 125 | TEST_SUITE(FP16) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 126 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)), |
| 127 | conv_args_small)) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 128 | { |
| 129 | // Validate output |
| 130 | validate(CLAccessor(_target), _reference); |
| 131 | } |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 132 | FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", |
| 133 | DataType::F16)), |
Giorgio Arena | fb62908 | 2018-08-20 18:03:27 +0100 | [diff] [blame] | 134 | conv_args)) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 135 | { |
| 136 | // Validate output |
| 137 | validate(CLAccessor(_target), _reference); |
| 138 | } |
| 139 | TEST_SUITE_END() |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 140 | TEST_SUITE_END() |
| 141 | |
| 142 | TEST_SUITE(QASYMM8) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 143 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), |
| 144 | conv_args_small)) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 145 | { |
| 146 | // Validate output |
| 147 | validate(CLAccessor(_target), _reference); |
| 148 | } |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 149 | FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), |
| 150 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Giorgio Arena | fb62908 | 2018-08-20 18:03:27 +0100 | [diff] [blame] | 151 | conv_args)) |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 152 | { |
| 153 | // Validate output |
| 154 | validate(CLAccessor(_target), _reference); |
| 155 | } |
| 156 | TEST_SUITE_END() |
| 157 | |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 158 | TEST_SUITE(Grouped) |
| 159 | TEST_SUITE(FP32) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 160 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::GroupedIm2ColSmallShapes(), framework::dataset::make("DataType", |
| 161 | DataType::F32)), |
| 162 | grouped_args_small)) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 163 | { |
| 164 | // Validate output |
| 165 | validate(CLAccessor(_target), _reference); |
| 166 | } |
| 167 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 168 | FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(concat(datasets::GroupedIm2ColSmallShapes(), datasets::GroupedIm2ColLargeShapes()), |
| 169 | framework::dataset::make("DataType", |
| 170 | DataType::F32)), |
Giorgio Arena | fb62908 | 2018-08-20 18:03:27 +0100 | [diff] [blame] | 171 | grouped_args)) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 172 | { |
| 173 | // Validate output |
| 174 | validate(CLAccessor(_target), _reference); |
| 175 | } |
| 176 | TEST_SUITE_END() |
| 177 | |
| 178 | TEST_SUITE(FP16) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 179 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::GroupedIm2ColSmallShapes(), framework::dataset::make("DataType", |
| 180 | DataType::F16)), |
| 181 | grouped_args_small)) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 182 | { |
| 183 | // Validate output |
| 184 | validate(CLAccessor(_target), _reference); |
| 185 | } |
| 186 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 187 | FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(concat(datasets::GroupedIm2ColSmallShapes(), datasets::GroupedIm2ColLargeShapes()), |
| 188 | framework::dataset::make("DataType", |
| 189 | DataType::F16)), |
Giorgio Arena | fb62908 | 2018-08-20 18:03:27 +0100 | [diff] [blame] | 190 | grouped_args)) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 191 | { |
| 192 | // Validate output |
| 193 | validate(CLAccessor(_target), _reference); |
| 194 | } |
| 195 | TEST_SUITE_END() |
| 196 | |
| 197 | TEST_SUITE(QASYMM8) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 198 | FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::GroupedIm2ColSmallShapes(), framework::dataset::make("DataType", |
| 199 | DataType::QASYMM8)), |
| 200 | grouped_args_small)) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 201 | { |
| 202 | // Validate output |
| 203 | validate(CLAccessor(_target), _reference); |
| 204 | } |
| 205 | |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 206 | FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(concat(datasets::GroupedIm2ColSmallShapes(), datasets::GroupedIm2ColLargeShapes()), |
| 207 | framework::dataset::make("DataType", |
| 208 | DataType::QASYMM8)), |
Giorgio Arena | fb62908 | 2018-08-20 18:03:27 +0100 | [diff] [blame] | 209 | grouped_args)) |
Giorgio Arena | 0f17039 | 2018-07-18 16:13:12 +0100 | [diff] [blame] | 210 | { |
| 211 | // Validate output |
| 212 | validate(CLAccessor(_target), _reference); |
| 213 | } |
| 214 | TEST_SUITE_END() |
| 215 | TEST_SUITE_END() |
| 216 | |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 217 | TEST_SUITE_END() |
| 218 | TEST_SUITE_END() |
| 219 | } // namespace validation |
| 220 | } // namespace test |
| 221 | } // namespace arm_compute |