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