Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 1 | /* |
Freddie Liardet | c2d0e20 | 2021-05-07 09:03:12 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [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 | |
| 25 | #include "arm_compute/core/Types.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 27 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 28 | #include "arm_compute/runtime/CL/functions/CLSelect.h" |
| 29 | #include "tests/CL/CLAccessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
| 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/SelectFixture.h" |
| 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 46 | auto run_small_dataset = combine(datasets::SmallShapes(), framework::dataset::make("has_same_rank", { false, true })); |
| 47 | auto run_large_dataset = combine(datasets::LargeShapes(), framework::dataset::make("has_same_rank", { false, true })); |
| 48 | |
| 49 | } // namespace |
| 50 | TEST_SUITE(CL) |
| 51 | TEST_SUITE(Select) |
| 52 | |
| 53 | // *INDENT-OFF* |
| 54 | // clang-format off |
| 55 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
| 56 | framework::dataset::make("CInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S8), // Invalid condition datatype |
| 57 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid output datatype |
| 58 | TensorInfo(TensorShape(13U), 1, DataType::U8), // Invalid c shape |
| 59 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Mismatching shapes |
| 60 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 61 | TensorInfo(TensorShape(2U), 1, DataType::U8), |
| 62 | }), |
| 63 | framework::dataset::make("XInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 64 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 65 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 66 | TensorInfo(TensorShape(32U, 10U, 2U), 1, DataType::F32), |
| 67 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 68 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 69 | })), |
| 70 | framework::dataset::make("YInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 71 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 72 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 73 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 74 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 75 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 76 | })), |
| 77 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 78 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S8), |
| 79 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 80 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 81 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 82 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 83 | })), |
| 84 | framework::dataset::make("Expected", { false, false, false, false, true, true})), |
| 85 | c_info, x_info, y_info, output_info, expected) |
| 86 | { |
| 87 | Status s = CLSelect::validate(&c_info.clone()->set_is_resizable(false), |
| 88 | &x_info.clone()->set_is_resizable(false), |
| 89 | &y_info.clone()->set_is_resizable(false), |
| 90 | &output_info.clone()->set_is_resizable(false)); |
| 91 | ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS); |
| 92 | } |
| 93 | // clang-format on |
| 94 | // *INDENT-ON* |
| 95 | |
| 96 | template <typename T> |
| 97 | using CLSelectFixture = SelectValidationFixture<CLTensor, CLAccessor, CLSelect, T>; |
| 98 | |
| 99 | TEST_SUITE(Float) |
| 100 | TEST_SUITE(F16) |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 101 | FIXTURE_DATA_TEST_CASE(RunSmall, |
| 102 | CLSelectFixture<half>, |
| 103 | framework::DatasetMode::PRECOMMIT, |
| 104 | combine(run_small_dataset, framework::dataset::make("DataType", DataType::F16))) |
| 105 | { |
| 106 | // Validate output |
| 107 | validate(CLAccessor(_target), _reference); |
| 108 | } |
| 109 | |
Freddie Liardet | c2d0e20 | 2021-05-07 09:03:12 +0100 | [diff] [blame] | 110 | FIXTURE_DATA_TEST_CASE(RunOneDim, |
| 111 | CLSelectFixture<half>, |
| 112 | framework::DatasetMode::PRECOMMIT, |
| 113 | combine(combine(framework::dataset::make("Shape", TensorShape(1U, 16U)), |
| 114 | framework::dataset::make("has_same_rank", { false, true })), |
| 115 | framework::dataset::make("DataType", DataType::F16))) |
| 116 | { |
| 117 | // Validate output |
| 118 | validate(CLAccessor(_target), _reference); |
| 119 | } |
| 120 | |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 121 | FIXTURE_DATA_TEST_CASE(RunLarge, |
| 122 | CLSelectFixture<half>, |
| 123 | framework::DatasetMode::NIGHTLY, |
| 124 | combine(run_large_dataset, framework::dataset::make("DataType", DataType::F16))) |
| 125 | { |
| 126 | // Validate output |
| 127 | validate(CLAccessor(_target), _reference); |
| 128 | } |
| 129 | TEST_SUITE_END() // F16 |
| 130 | |
| 131 | TEST_SUITE(FP32) |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 132 | FIXTURE_DATA_TEST_CASE(RunSmall, |
| 133 | CLSelectFixture<float>, |
| 134 | framework::DatasetMode::PRECOMMIT, |
| 135 | combine(run_small_dataset, framework::dataset::make("DataType", DataType::F32))) |
| 136 | { |
| 137 | // Validate output |
| 138 | validate(CLAccessor(_target), _reference); |
| 139 | } |
| 140 | |
Freddie Liardet | c2d0e20 | 2021-05-07 09:03:12 +0100 | [diff] [blame] | 141 | FIXTURE_DATA_TEST_CASE(RunOneDim, |
| 142 | CLSelectFixture<float>, |
| 143 | framework::DatasetMode::PRECOMMIT, |
| 144 | combine(combine(framework::dataset::make("Shape", TensorShape(1U, 16U)), |
| 145 | framework::dataset::make("has_same_rank", { false, true })), |
| 146 | framework::dataset::make("DataType", DataType::F32))) |
| 147 | { |
| 148 | // Validate output |
| 149 | validate(CLAccessor(_target), _reference); |
| 150 | } |
| 151 | |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 152 | FIXTURE_DATA_TEST_CASE(RunLarge, |
| 153 | CLSelectFixture<float>, |
| 154 | framework::DatasetMode::NIGHTLY, |
| 155 | combine(run_large_dataset, framework::dataset::make("DataType", DataType::F32))) |
| 156 | { |
| 157 | // Validate output |
| 158 | validate(CLAccessor(_target), _reference); |
| 159 | } |
| 160 | TEST_SUITE_END() // F32 |
| 161 | TEST_SUITE_END() // Float |
| 162 | |
| 163 | TEST_SUITE(Quantized) |
| 164 | TEST_SUITE(QASYMM8) |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 165 | FIXTURE_DATA_TEST_CASE(RunSmall, |
| 166 | CLSelectFixture<uint8_t>, |
| 167 | framework::DatasetMode::PRECOMMIT, |
| 168 | combine(run_small_dataset, framework::dataset::make("DataType", DataType::QASYMM8))) |
| 169 | { |
| 170 | // Validate output |
| 171 | validate(CLAccessor(_target), _reference); |
| 172 | } |
| 173 | |
Freddie Liardet | c2d0e20 | 2021-05-07 09:03:12 +0100 | [diff] [blame] | 174 | FIXTURE_DATA_TEST_CASE(RunOneDim, |
| 175 | CLSelectFixture<uint8_t>, |
| 176 | framework::DatasetMode::PRECOMMIT, |
| 177 | combine(combine(framework::dataset::make("Shape", TensorShape(1U, 16U)), |
| 178 | framework::dataset::make("has_same_rank", { false, true })), |
| 179 | framework::dataset::make("DataType", DataType::QASYMM8))) |
| 180 | { |
| 181 | // Validate output |
| 182 | validate(CLAccessor(_target), _reference); |
| 183 | } |
| 184 | |
Georgios Pinitas | aaa2718 | 2018-11-21 16:32:15 +0000 | [diff] [blame] | 185 | FIXTURE_DATA_TEST_CASE(RunLarge, |
| 186 | CLSelectFixture<uint8_t>, |
| 187 | framework::DatasetMode::NIGHTLY, |
| 188 | combine(run_large_dataset, framework::dataset::make("DataType", DataType::QASYMM8))) |
| 189 | { |
| 190 | // Validate output |
| 191 | validate(CLAccessor(_target), _reference); |
| 192 | } |
| 193 | TEST_SUITE_END() // QASYMM8 |
| 194 | TEST_SUITE_END() // Quantized |
| 195 | |
| 196 | TEST_SUITE_END() // Select |
| 197 | TEST_SUITE_END() // CL |
| 198 | } // namespace validation |
| 199 | } // namespace test |
| 200 | } // namespace arm_compute |