Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 1 | /* |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 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" |
| 27 | #include "arm_compute/runtime/CL/functions/CLArithmeticSubtraction.h" |
| 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" |
| 36 | #include "tests/validation/fixtures/ArithmeticSubtractionFixture.h" |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
| 46 | /** Input data sets **/ |
| 47 | const auto ArithmeticSubtractionU8Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)), |
| 48 | framework::dataset::make("DataType", |
| 49 | DataType::U8)); |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 50 | const auto ArithmeticSubtractionS16Dataset = combine(combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::S16)), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 51 | framework::dataset::make("DataType", DataType::S16)); |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 52 | const auto ArithmeticSubtractionU8U8S16Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)), |
| 53 | framework::dataset::make("DataType", DataType::S16)); |
| 54 | const auto ArithmeticSubtractionS16U8S16Dataset = combine(combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::U8)), |
| 55 | framework::dataset::make("DataType", DataType::S16)); |
| 56 | const auto ArithmeticSubtractionU8S16S16Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S16)), |
| 57 | framework::dataset::make("DataType", DataType::S16)); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 58 | const auto ArithmeticSubtractionQS8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QS8), framework::dataset::make("DataType", DataType::QS8)), |
| 59 | framework::dataset::make("DataType", DataType::QS8)); |
| 60 | const auto ArithmeticSubtractionQS16Dataset = combine(combine(framework::dataset::make("DataType", DataType::QS16), framework::dataset::make("DataType", DataType::QS16)), |
| 61 | framework::dataset::make("DataType", DataType::QS16)); |
| 62 | const auto ArithmeticSubtractionFP16Dataset = combine(combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::F16)), |
| 63 | framework::dataset::make("DataType", DataType::F16)); |
| 64 | const auto ArithmeticSubtractionFP32Dataset = combine(combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::F32)), |
| 65 | framework::dataset::make("DataType", DataType::F32)); |
| 66 | } // namespace |
| 67 | |
| 68 | TEST_SUITE(CL) |
| 69 | TEST_SUITE(ArithmeticSubtraction) |
| 70 | |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 71 | // *INDENT-OFF* |
| 72 | // clang-format off |
| 73 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 74 | framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 75 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 76 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Window shrink |
| 77 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid data type combination |
| 78 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes |
| 79 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), // Mismatching fixed point |
| 80 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 81 | }), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 82 | framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 83 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 84 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 85 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), |
| 86 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 87 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 3), |
| 88 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 89 | })), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 90 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), |
| 91 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 92 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 93 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 94 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 95 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 3), |
| 96 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 97 | })), |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 98 | framework::dataset::make("Expected", { true, true, false, false, false, false, true })), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 99 | input1_info, input2_info, output_info, expected) |
| 100 | { |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 101 | ARM_COMPUTE_EXPECT(bool(CLArithmeticSubtraction::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] | 102 | } |
| 103 | // clang-format on |
| 104 | // *INDENT-ON* |
| 105 | |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 106 | template <typename T1, typename T2 = T1, typename T3 = T1> |
| 107 | using CLArithmeticSubtractionFixture = ArithmeticSubtractionValidationFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T1, T2, T3>; |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 108 | |
| 109 | TEST_SUITE(U8) |
| 110 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 111 | shape, policy) |
| 112 | { |
| 113 | // Create tensors |
| 114 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::U8); |
| 115 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::U8); |
| 116 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); |
| 117 | |
| 118 | // Create and Configure function |
| 119 | CLArithmeticSubtraction sub; |
| 120 | sub.configure(&ref_src1, &ref_src2, &dst, policy); |
| 121 | |
| 122 | // Validate valid region |
| 123 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 124 | validate(dst.info()->valid_region(), valid_region); |
| 125 | |
| 126 | // Validate padding |
| 127 | const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); |
| 128 | validate(ref_src1.info()->padding(), padding); |
| 129 | validate(ref_src2.info()->padding(), padding); |
| 130 | validate(dst.info()->padding(), padding); |
| 131 | } |
| 132 | |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 133 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), |
| 134 | ArithmeticSubtractionU8Dataset), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 135 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 136 | { |
| 137 | // Validate output |
| 138 | validate(CLAccessor(_target), _reference); |
| 139 | } |
| 140 | TEST_SUITE_END() |
| 141 | |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 142 | template <typename T1, typename T2 = T1> |
| 143 | using CLArithmeticSubtractionToS16Fixture = CLArithmeticSubtractionFixture<T1, T2, int16_t>; |
| 144 | |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 145 | TEST_SUITE(S16) |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 146 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), |
| 147 | framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), |
| 148 | framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 149 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 150 | shape, data_type1, data_type2, policy) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 151 | { |
| 152 | // Create tensors |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 153 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, data_type1); |
| 154 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, data_type2); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 155 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::S16); |
| 156 | |
| 157 | // Create and Configure function |
| 158 | CLArithmeticSubtraction sub; |
| 159 | sub.configure(&ref_src1, &ref_src2, &dst, policy); |
| 160 | |
| 161 | // Validate valid region |
| 162 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 163 | validate(dst.info()->valid_region(), valid_region); |
| 164 | |
| 165 | // Validate padding |
| 166 | const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); |
| 167 | validate(ref_src1.info()->padding(), padding); |
| 168 | validate(ref_src2.info()->padding(), padding); |
| 169 | validate(dst.info()->padding(), padding); |
| 170 | } |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 171 | TEST_SUITE(S16_S16_S16) |
| 172 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionToS16Fixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ArithmeticSubtractionS16Dataset), |
| 173 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 174 | { |
| 175 | // Validate output |
| 176 | validate(CLAccessor(_target), _reference); |
| 177 | } |
| 178 | |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 179 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionToS16Fixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ArithmeticSubtractionS16Dataset), |
| 180 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 181 | { |
| 182 | // Validate output |
| 183 | validate(CLAccessor(_target), _reference); |
| 184 | } |
| 185 | TEST_SUITE_END() |
| 186 | |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 187 | TEST_SUITE(U8_U8_S16) |
| 188 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionToS16Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), |
| 189 | ArithmeticSubtractionU8U8S16Dataset), |
| 190 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 191 | { |
| 192 | // Validate output |
| 193 | validate(CLAccessor(_target), _reference); |
| 194 | } |
| 195 | |
| 196 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionToS16Fixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), |
| 197 | ArithmeticSubtractionU8U8S16Dataset), |
| 198 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 199 | { |
| 200 | // Validate output |
| 201 | validate(CLAccessor(_target), _reference); |
| 202 | } |
| 203 | TEST_SUITE_END() |
| 204 | |
| 205 | TEST_SUITE(S16_U8_S16) |
| 206 | using CLAriSubS16U8ToS16Fixture = CLArithmeticSubtractionToS16Fixture<int16_t, uint8_t>; |
| 207 | FIXTURE_DATA_TEST_CASE(RunSmall, CLAriSubS16U8ToS16Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), |
| 208 | ArithmeticSubtractionS16U8S16Dataset), |
| 209 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 210 | { |
| 211 | // Validate output |
| 212 | validate(CLAccessor(_target), _reference); |
| 213 | } |
| 214 | |
| 215 | FIXTURE_DATA_TEST_CASE(RunLarge, CLAriSubS16U8ToS16Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), |
| 216 | ArithmeticSubtractionS16U8S16Dataset), |
| 217 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 218 | { |
| 219 | // Validate output |
| 220 | validate(CLAccessor(_target), _reference); |
| 221 | } |
| 222 | TEST_SUITE_END() |
| 223 | |
| 224 | TEST_SUITE(U8_S16_S16) |
| 225 | using CLAriSubU8S16ToS16Fixture = CLArithmeticSubtractionToS16Fixture<uint8_t, int16_t>; |
| 226 | FIXTURE_DATA_TEST_CASE(RunSmall, CLAriSubU8S16ToS16Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), |
| 227 | ArithmeticSubtractionU8S16S16Dataset), |
| 228 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 229 | { |
| 230 | // Validate output |
| 231 | validate(CLAccessor(_target), _reference); |
| 232 | } |
| 233 | |
| 234 | FIXTURE_DATA_TEST_CASE(RunLarge, CLAriSubU8S16ToS16Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), |
| 235 | ArithmeticSubtractionU8S16S16Dataset), |
| 236 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 237 | { |
| 238 | // Validate output |
| 239 | validate(CLAccessor(_target), _reference); |
| 240 | } |
| 241 | TEST_SUITE_END() |
| 242 | TEST_SUITE_END() |
| 243 | |
| 244 | template <typename T1, typename T2 = T1, typename T3 = T1> |
| 245 | using CLArithmeticSubtractionFixedPointFixture = ArithmeticSubtractionValidationFixedPointFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T1, T2, T3>; |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 246 | |
| 247 | TEST_SUITE(Quantized) |
| 248 | TEST_SUITE(QS8) |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame^] | 249 | FIXTURE_DATA_TEST_CASE(RunTiny, CLArithmeticSubtractionFixedPointFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::TinyShapes(), |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 250 | ArithmeticSubtractionQS8Dataset), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 251 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 252 | framework::dataset::make("FractionalBits", 1, 7))) |
| 253 | { |
| 254 | // Validate output |
| 255 | validate(CLAccessor(_target), _reference); |
| 256 | } |
| 257 | |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame^] | 258 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixedPointFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 259 | ArithmeticSubtractionQS8Dataset), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 260 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 261 | framework::dataset::make("FractionalBits", 1, 7))) |
| 262 | { |
| 263 | // Validate output |
| 264 | validate(CLAccessor(_target), _reference); |
| 265 | } |
| 266 | TEST_SUITE_END() |
| 267 | |
| 268 | TEST_SUITE(QS16) |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame^] | 269 | FIXTURE_DATA_TEST_CASE(RunTiny, CLArithmeticSubtractionFixedPointFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::TinyShapes(), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 270 | ArithmeticSubtractionQS16Dataset), |
| 271 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 272 | framework::dataset::make("FractionalBits", 1, 15))) |
| 273 | { |
| 274 | // Validate output |
| 275 | validate(CLAccessor(_target), _reference); |
| 276 | } |
| 277 | |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame^] | 278 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixedPointFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 279 | ArithmeticSubtractionQS16Dataset), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 280 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 281 | framework::dataset::make("FractionalBits", 1, 15))) |
| 282 | { |
| 283 | // Validate output |
| 284 | validate(CLAccessor(_target), _reference); |
| 285 | } |
| 286 | TEST_SUITE_END() |
| 287 | TEST_SUITE_END() |
| 288 | |
| 289 | TEST_SUITE(Float) |
| 290 | TEST_SUITE(FP16) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 291 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<half>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), ArithmeticSubtractionFP16Dataset), |
| 292 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 293 | { |
| 294 | // Validate output |
| 295 | validate(CLAccessor(_target), _reference); |
| 296 | } |
| 297 | TEST_SUITE_END() |
| 298 | |
| 299 | TEST_SUITE(FP32) |
| 300 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 301 | shape, policy) |
| 302 | { |
| 303 | // Create tensors |
| 304 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::F32); |
| 305 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::F32); |
| 306 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::F32); |
| 307 | |
| 308 | // Create and Configure function |
| 309 | CLArithmeticSubtraction sub; |
| 310 | sub.configure(&ref_src1, &ref_src2, &dst, policy); |
| 311 | |
| 312 | // Validate valid region |
| 313 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 314 | validate(dst.info()->valid_region(), valid_region); |
| 315 | |
| 316 | // Validate padding |
| 317 | const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); |
| 318 | validate(ref_src1.info()->padding(), padding); |
| 319 | validate(ref_src2.info()->padding(), padding); |
| 320 | validate(dst.info()->padding(), padding); |
| 321 | } |
| 322 | |
| 323 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ArithmeticSubtractionFP32Dataset), |
| 324 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 325 | { |
| 326 | // Validate output |
| 327 | validate(CLAccessor(_target), _reference); |
| 328 | } |
| 329 | |
| 330 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ArithmeticSubtractionFP32Dataset), |
| 331 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP }))) |
| 332 | { |
| 333 | // Validate output |
| 334 | validate(CLAccessor(_target), _reference); |
| 335 | } |
| 336 | TEST_SUITE_END() |
| 337 | TEST_SUITE_END() |
| 338 | |
| 339 | TEST_SUITE_END() |
| 340 | TEST_SUITE_END() |
| 341 | } // namespace validation |
| 342 | } // namespace test |
| 343 | } // namespace arm_compute |