Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +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, |
Sanghoon Lee | a7a5b7b | 2017-09-14 12:11:03 +0100 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 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" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 27 | #include "arm_compute/runtime/CL/functions/CLElementwiseOperations.h" |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/PaddingCalculator.h" |
| 30 | #include "tests/datasets/ConvertPolicyDataset.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" |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 36 | #include "tests/validation/fixtures/ArithmeticOperationsFixture.h" |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 46 | constexpr unsigned int num_elems_processed_per_iteration = 16; |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 47 | /** Input data sets **/ |
| 48 | const auto ArithmeticAdditionU8Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)), framework::dataset::make("DataType", |
| 49 | DataType::U8)); |
Michele Di Giorgio | 4622ac1 | 2018-06-27 16:41:17 +0100 | [diff] [blame] | 50 | const auto ArithmeticAdditionQASYMM8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::QASYMM8)), |
| 51 | framework::dataset::make("DataType", |
| 52 | DataType::QASYMM8)); |
Kurtis Charnock | ec0c412 | 2019-12-05 14:13:46 +0000 | [diff] [blame] | 53 | const auto ArithmeticAdditionQASYMM8SignedDataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
| 54 | framework::dataset::make("DataType", |
| 55 | DataType::QASYMM8_SIGNED)); |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 56 | const auto ArithmeticAdditionQSYMM16Dataset = combine(combine(framework::dataset::make("DataType", DataType::QSYMM16), framework::dataset::make("DataType", DataType::QSYMM16)), |
| 57 | framework::dataset::make("DataType", |
| 58 | DataType::QSYMM16)); |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 59 | const auto ArithmeticAdditionS16Dataset = combine(combine(framework::dataset::make("DataType", { DataType::U8, DataType::S16 }), framework::dataset::make("DataType", DataType::S16)), |
| 60 | framework::dataset::make("DataType", DataType::S16)); |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 61 | const auto ArithmeticAdditionFP16Dataset = combine(combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::F16)), |
| 62 | framework::dataset::make("DataType", DataType::F16)); |
| 63 | const auto ArithmeticAdditionFP32Dataset = combine(combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::F32)), |
| 64 | framework::dataset::make("DataType", DataType::F32)); |
| 65 | } // namespace |
| 66 | |
| 67 | TEST_SUITE(CL) |
| 68 | TEST_SUITE(ArithmeticAddition) |
| 69 | |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 70 | // *INDENT-OFF* |
| 71 | // clang-format off |
| 72 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 73 | framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 74 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 75 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Window shrink |
| 76 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid data type combination |
| 77 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 78 | }), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 79 | framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 80 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 81 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 82 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), |
| 83 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 84 | })), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 85 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), |
| 86 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 87 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 88 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 89 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 90 | })), |
Vidhya Sudhan Loganathan | 0fc2545 | 2018-06-18 14:40:56 +0100 | [diff] [blame] | 91 | framework::dataset::make("Expected", { true, true, false, false, false})), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 92 | input1_info, input2_info, output_info, expected) |
| 93 | { |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 94 | ARM_COMPUTE_EXPECT(bool(CLArithmeticAddition::validate(&input1_info.clone()->set_is_resizable(false), &input2_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), ConvertPolicy::WRAP)) == expected, framework::LogLevel::ERRORS); |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 95 | } |
| 96 | // clang-format on |
| 97 | // *INDENT-ON* |
| 98 | |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 99 | template <typename T> |
| 100 | using CLArithmeticAdditionFixture = ArithmeticAdditionValidationFixture<CLTensor, CLAccessor, CLArithmeticAddition, T>; |
| 101 | |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 102 | TEST_SUITE(Integer) |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 103 | TEST_SUITE(U8) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 104 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 105 | shape, policy) |
| 106 | { |
| 107 | // Create tensors |
| 108 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::U8); |
| 109 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::U8); |
| 110 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); |
| 111 | |
| 112 | // Create and Configure function |
| 113 | CLArithmeticAddition add; |
| 114 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 115 | |
| 116 | // Validate valid region |
| 117 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 118 | validate(dst.info()->valid_region(), valid_region); |
| 119 | |
| 120 | // Validate padding |
Michele Di Giorgio | a1422fb | 2018-10-24 12:20:19 +0100 | [diff] [blame] | 121 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 122 | validate(ref_src1.info()->padding(), padding); |
| 123 | validate(ref_src2.info()->padding(), padding); |
| 124 | validate(dst.info()->padding(), padding); |
| 125 | } |
| 126 | |
| 127 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ArithmeticAdditionU8Dataset), |
| 128 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 129 | { |
| 130 | // Validate output |
| 131 | validate(CLAccessor(_target), _reference); |
| 132 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 133 | TEST_SUITE_END() // U8 |
Michele Di Giorgio | 4622ac1 | 2018-06-27 16:41:17 +0100 | [diff] [blame] | 134 | |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 135 | TEST_SUITE(S16) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 136 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 137 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 138 | shape, data_type, policy) |
| 139 | { |
| 140 | // Create tensors |
| 141 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, data_type); |
| 142 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::S16); |
| 143 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::S16); |
| 144 | |
| 145 | // Create and Configure function |
| 146 | CLArithmeticAddition add; |
| 147 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 148 | |
| 149 | // Validate valid region |
| 150 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 151 | validate(dst.info()->valid_region(), valid_region); |
| 152 | |
| 153 | // Validate padding |
Michele Di Giorgio | a1422fb | 2018-10-24 12:20:19 +0100 | [diff] [blame] | 154 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 155 | validate(ref_src1.info()->padding(), padding); |
| 156 | validate(ref_src2.info()->padding(), padding); |
| 157 | validate(dst.info()->padding(), padding); |
| 158 | } |
| 159 | |
| 160 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ArithmeticAdditionS16Dataset), |
| 161 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 162 | { |
| 163 | // Validate output |
| 164 | validate(CLAccessor(_target), _reference); |
| 165 | } |
| 166 | |
| 167 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticAdditionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ArithmeticAdditionS16Dataset), |
| 168 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 169 | { |
| 170 | // Validate output |
| 171 | validate(CLAccessor(_target), _reference); |
| 172 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 173 | TEST_SUITE_END() // S16 |
| 174 | TEST_SUITE_END() // Integer |
| 175 | |
| 176 | template <typename T> |
| 177 | using CLArithmeticAdditionQuantizedFixture = ArithmeticAdditionValidationQuantizedFixture<CLTensor, CLAccessor, CLArithmeticAddition, T>; |
| 178 | |
| 179 | TEST_SUITE(Quantized) |
| 180 | TEST_SUITE(QASYMM8) |
| 181 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 182 | shape, policy) |
| 183 | { |
| 184 | // Create tensors |
| 185 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QASYMM8); |
| 186 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QASYMM8); |
| 187 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::QASYMM8); |
| 188 | |
| 189 | // Create and Configure function |
| 190 | CLArithmeticAddition add; |
| 191 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 192 | |
| 193 | // Validate valid region |
| 194 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 195 | validate(dst.info()->valid_region(), valid_region); |
| 196 | |
| 197 | // Validate padding |
| 198 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
| 199 | validate(ref_src1.info()->padding(), padding); |
| 200 | validate(ref_src2.info()->padding(), padding); |
| 201 | validate(dst.info()->padding(), padding); |
| 202 | } |
| 203 | |
| 204 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(datasets::SmallShapes(), |
| 205 | ArithmeticAdditionQASYMM8Dataset), |
| 206 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 207 | framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 255.f, 20) })), |
| 208 | framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
| 209 | framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 255.f, 5) }))) |
| 210 | { |
| 211 | // Validate output |
| 212 | validate(CLAccessor(_target), _reference); |
| 213 | } |
| 214 | TEST_SUITE_END() // QASYMM8 |
Kurtis Charnock | ec0c412 | 2019-12-05 14:13:46 +0000 | [diff] [blame] | 215 | TEST_SUITE(QASYMM8_SIGNED) |
| 216 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 217 | shape, policy) |
| 218 | { |
| 219 | // Create tensors |
| 220 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED); |
| 221 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED); |
| 222 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED); |
| 223 | |
| 224 | // Create and Configure function |
| 225 | CLArithmeticAddition add; |
| 226 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 227 | |
| 228 | // Validate valid region |
| 229 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 230 | validate(dst.info()->valid_region(), valid_region); |
| 231 | |
| 232 | // Validate padding |
| 233 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
| 234 | validate(ref_src1.info()->padding(), padding); |
| 235 | validate(ref_src2.info()->padding(), padding); |
| 236 | validate(dst.info()->padding(), padding); |
| 237 | } |
| 238 | |
| 239 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(datasets::SmallShapes(), |
| 240 | ArithmeticAdditionQASYMM8SignedDataset), |
| 241 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 242 | framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 255.f, 10) })), |
| 243 | framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
| 244 | framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 255.f, 5) }))) |
| 245 | { |
| 246 | // Validate output |
| 247 | validate(CLAccessor(_target), _reference); |
| 248 | } |
| 249 | TEST_SUITE_END() // QASYMM8_SIGNED |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 250 | TEST_SUITE(QSYMM16) |
| 251 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 252 | shape, policy) |
| 253 | { |
| 254 | // Create tensors |
| 255 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QSYMM16); |
| 256 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QSYMM16); |
| 257 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::QSYMM16); |
| 258 | |
| 259 | // Create and Configure function |
| 260 | CLArithmeticAddition add; |
| 261 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 262 | |
| 263 | // Validate valid region |
| 264 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 265 | validate(dst.info()->valid_region(), valid_region); |
| 266 | |
| 267 | // Validate padding |
| 268 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
| 269 | validate(ref_src1.info()->padding(), padding); |
| 270 | validate(ref_src2.info()->padding(), padding); |
| 271 | validate(dst.info()->padding(), padding); |
| 272 | } |
| 273 | |
| 274 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionQuantizedFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(datasets::SmallShapes(), |
| 275 | ArithmeticAdditionQSYMM16Dataset), |
| 276 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 277 | framework::dataset::make("Src0QInfo", { QuantizationInfo(1.f / 32768.f, 0), QuantizationInfo(5.f / 32768.f, 0) })), |
| 278 | framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 32768.f, 0), QuantizationInfo(5.f / 32768.f, 0) })), |
| 279 | framework::dataset::make("OutQInfo", { QuantizationInfo(5.f / 32768.f, 0) }))) |
| 280 | { |
| 281 | // Validate output |
| 282 | validate(CLAccessor(_target), _reference); |
| 283 | } |
| 284 | TEST_SUITE_END() // QSYMM16 |
| 285 | TEST_SUITE_END() // Quantized |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 286 | |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 287 | TEST_SUITE(Float) |
| 288 | TEST_SUITE(FP16) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 289 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionFixture<half>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), ArithmeticAdditionFP16Dataset), |
| 290 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 291 | { |
| 292 | // Validate output |
| 293 | validate(CLAccessor(_target), _reference); |
| 294 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 295 | TEST_SUITE_END() // FP16 |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 296 | |
| 297 | TEST_SUITE(FP32) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 298 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 299 | shape, policy) |
| 300 | { |
| 301 | // Create tensors |
| 302 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::F32); |
| 303 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::F32); |
| 304 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::F32); |
| 305 | |
| 306 | // Create and Configure function |
| 307 | CLArithmeticAddition add; |
| 308 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 309 | |
| 310 | // Validate valid region |
| 311 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 312 | validate(dst.info()->valid_region(), valid_region); |
| 313 | |
| 314 | // Validate padding |
Michele Di Giorgio | a1422fb | 2018-10-24 12:20:19 +0100 | [diff] [blame] | 315 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 316 | validate(ref_src1.info()->padding(), padding); |
| 317 | validate(ref_src2.info()->padding(), padding); |
| 318 | validate(dst.info()->padding(), padding); |
| 319 | } |
| 320 | |
| 321 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticAdditionFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ArithmeticAdditionFP32Dataset), |
| 322 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 323 | { |
| 324 | // Validate output |
| 325 | validate(CLAccessor(_target), _reference); |
| 326 | } |
| 327 | |
| 328 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticAdditionFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ArithmeticAdditionFP32Dataset), |
| 329 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 330 | { |
| 331 | // Validate output |
| 332 | validate(CLAccessor(_target), _reference); |
| 333 | } |
Diego Lopez Recas | 0021d75 | 2017-12-18 14:42:56 +0000 | [diff] [blame] | 334 | |
| 335 | template <typename T> |
| 336 | using CLArithmeticAdditionBroadcastFixture = ArithmeticAdditionBroadcastValidationFixture<CLTensor, CLAccessor, CLArithmeticAddition, T>; |
| 337 | |
| 338 | FIXTURE_DATA_TEST_CASE(RunSmallBroadcast, CLArithmeticAdditionBroadcastFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapesBroadcast(), |
| 339 | ArithmeticAdditionFP32Dataset), |
| 340 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 341 | { |
| 342 | // Validate output |
| 343 | validate(CLAccessor(_target), _reference); |
| 344 | } |
| 345 | |
| 346 | FIXTURE_DATA_TEST_CASE(RunLargeBroadcast, CLArithmeticAdditionBroadcastFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapesBroadcast(), |
| 347 | ArithmeticAdditionFP32Dataset), |
| 348 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 349 | { |
| 350 | // Validate output |
| 351 | validate(CLAccessor(_target), _reference); |
| 352 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 353 | TEST_SUITE_END() // FP32 |
| 354 | TEST_SUITE_END() // Float |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 355 | |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 356 | TEST_SUITE_END() // ArithmeticAddition |
| 357 | TEST_SUITE_END() // CL |
Sanghoon Lee | 70f8291 | 2017-08-24 14:21:24 +0100 | [diff] [blame] | 358 | } // namespace validation |
| 359 | } // namespace test |
| 360 | } // namespace arm_compute |