Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 1 | /* |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +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 | */ |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 24 | #include "arm_compute/core/Types.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 25 | #include "src/gpu/cl/kernels/ClCol2ImKernel.h" |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 26 | #include "tests/CL/CLAccessor.h" |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 27 | #include "tests/CL/Helper.h" |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 28 | #include "tests/framework/Asserts.h" |
| 29 | #include "tests/framework/Macros.h" |
| 30 | #include "tests/framework/datasets/Datasets.h" |
| 31 | #include "tests/validation/Validation.h" |
| 32 | #include "tests/validation/fixtures/Col2ImFixture.h" |
| 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace test |
| 37 | { |
| 38 | namespace validation |
| 39 | { |
| 40 | TEST_SUITE(CL) |
| 41 | TEST_SUITE(Col2Im) |
| 42 | |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 43 | using ClCol2Im = ClSynthetizeOperatorWithBorder<opencl::kernels::ClCol2ImKernel>; |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 44 | |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 45 | /** Negative tests |
| 46 | * |
| 47 | * A series of validation tests on configurations which according to the API specification |
| 48 | * the function should fail against. |
| 49 | * |
| 50 | * Checks performed in order: |
| 51 | * - Pass unsupported data type for input |
| 52 | * - Pass NHWC as output data layout |
| 53 | * - Pass an invalid output shape |
| 54 | */ |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 55 | TEST_CASE(Negative, framework::DatasetMode::ALL) |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 56 | { |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 57 | // Unsupported data type |
| 58 | { |
| 59 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::SIZET); |
| 60 | const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32); |
| 61 | const auto conv_size = Size2D(3, 4); |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 62 | const auto status = opencl::kernels::ClCol2ImKernel::validate(&input, &output, conv_size); |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 63 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 64 | } |
| 65 | |
| 66 | // NHWC as output data layout |
| 67 | { |
| 68 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32); |
| 69 | const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC); |
| 70 | const auto conv_size = Size2D(3, 4); |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 71 | const auto status = opencl::kernels::ClCol2ImKernel::validate(&input, &output, conv_size); |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 72 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 73 | } |
| 74 | |
| 75 | // Invalid output size |
| 76 | { |
| 77 | const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32); |
| 78 | const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 2U, 2U), 1, DataType::F32); |
| 79 | const auto conv_size = Size2D(3, 4); |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 80 | const auto status = opencl::kernels::ClCol2ImKernel::validate(&input, &output, conv_size); |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 81 | ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS); |
| 82 | } |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 83 | } |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 84 | |
| 85 | template <typename T> |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 86 | using ClCol2ImFixture = Col2ImOpValidationFixture<CLTensor, CLAccessor, ClCol2Im, T, true>; |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 87 | |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 88 | /** Test kernel for single-precision floating point |
| 89 | * |
| 90 | * @note 8 elements processed per iteration |
| 91 | * |
| 92 | * Three main tests will be run: |
| 93 | * - Channels are multiple of elements processed |
| 94 | * - Channels larger and non multiple of elements used |
| 95 | * - Channels smaller and not multiple of elements used |
| 96 | * |
| 97 | * The above will be repeated with a different group size |
| 98 | * |
| 99 | * Kernel tested col2im |
| 100 | */ |
| 101 | FIXTURE_DATA_TEST_CASE(FP32, |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 102 | ClCol2ImFixture<float>, |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 103 | framework::DatasetMode::ALL, |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 104 | combine(combine(combine(combine( |
| 105 | framework::dataset::make("InputShape", { TensorShape(8U, 16U, 3U, 1U), TensorShape(17U, 16U, 3U, 1U), TensorShape(7U, 16U, 3U, 1U) }), |
| 106 | framework::dataset::make("ConvolvedWidth", 4)), |
| 107 | framework::dataset::make("ConvolvedHeight", 4)), |
| 108 | framework::dataset::make("Groups", { 1, 3 })), |
| 109 | framework::dataset::make("DataType", DataType::F32))) |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 110 | { |
| 111 | // Validate output |
| 112 | validate(CLAccessor(_target), _reference); |
| 113 | } |
| 114 | |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 115 | /** Test kernel for half-precision floating point |
| 116 | * |
| 117 | * @note 8 elements processed per iteration |
| 118 | * |
| 119 | * One main tests will be run: |
| 120 | * - Channels larger and non multiple of elements used |
| 121 | * |
| 122 | * We just need to test the difference in the data type size. |
| 123 | * Any other issues can be identified by the main FP32 tests |
| 124 | * |
| 125 | * Kernel tested col2im |
| 126 | */ |
| 127 | FIXTURE_DATA_TEST_CASE(F16, |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 128 | ClCol2ImFixture<half>, |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 129 | framework::DatasetMode::ALL, |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 130 | combine(combine(combine(combine( |
| 131 | framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)), |
| 132 | framework::dataset::make("ConvolvedWidth", 4)), |
| 133 | framework::dataset::make("ConvolvedHeight", 4)), |
| 134 | framework::dataset::make("Groups", 3)), |
| 135 | framework::dataset::make("DataType", DataType::F16))) |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 136 | { |
| 137 | // Validate output |
| 138 | validate(CLAccessor(_target), _reference); |
| 139 | } |
| 140 | |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 141 | /** Test kernel for unsigned asymmetric quantized type |
| 142 | * |
| 143 | * @note 8 elements processed per iteration |
| 144 | * |
| 145 | * One main tests will be run: |
| 146 | * - Channels larger and non multiple of elements used |
| 147 | * |
| 148 | * We just need to test the difference in the data type size. |
| 149 | * Any other issues can be identified by the main FP32 tests |
| 150 | * |
| 151 | * Kernel tested col2im |
| 152 | */ |
| 153 | FIXTURE_DATA_TEST_CASE(QASYMM8, |
Manuel Bottini | 7b23732 | 2021-07-14 17:07:23 +0100 | [diff] [blame] | 154 | ClCol2ImFixture<uint8_t>, |
Georgios Pinitas | c1c366d | 2020-03-30 18:09:24 +0100 | [diff] [blame] | 155 | framework::DatasetMode::ALL, |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 156 | combine(combine(combine(combine( |
| 157 | framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)), |
| 158 | framework::dataset::make("ConvolvedWidth", 4)), |
| 159 | framework::dataset::make("ConvolvedHeight", 4)), |
| 160 | framework::dataset::make("Groups", 3)), |
| 161 | framework::dataset::make("DataType", DataType::QASYMM8))) |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 162 | { |
| 163 | // Validate output |
| 164 | validate(CLAccessor(_target), _reference); |
| 165 | } |
| 166 | |
Georgios Pinitas | 5fc8f84 | 2020-04-08 17:48:56 +0100 | [diff] [blame] | 167 | TEST_SUITE_END() // CL |
| 168 | TEST_SUITE_END() // Col2Im |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 169 | } // namespace validation |
| 170 | } // namespace test |
| 171 | } // namespace arm_compute |