Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 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, |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +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 | 72898fe | 2017-09-01 11:42:16 +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 | 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 | { |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 46 | constexpr unsigned int num_elems_processed_per_iteration = 16; |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 47 | /** Input data sets **/ |
| 48 | const auto ArithmeticSubtractionU8Dataset = combine(combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)), |
| 49 | framework::dataset::make("DataType", |
| 50 | DataType::U8)); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 51 | const auto ArithmeticSubtractionQASYMM8Dataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::QASYMM8)), |
| 52 | framework::dataset::make("DataType", |
| 53 | DataType::QASYMM8)); |
Kurtis Charnock | ec0c412 | 2019-12-05 14:13:46 +0000 | [diff] [blame] | 54 | const auto ArithmeticSubtractionQASYMM8SignedDataset = combine(combine(framework::dataset::make("DataType", DataType::QASYMM8_SIGNED), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 55 | framework::dataset::make("DataType", |
| 56 | DataType::QASYMM8_SIGNED)); |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 57 | const auto ArithmeticSubtractionQSYMM16Dataset = combine(combine(framework::dataset::make("DataType", DataType::QSYMM16), framework::dataset::make("DataType", DataType::QSYMM16)), |
| 58 | framework::dataset::make("DataType", |
| 59 | DataType::QSYMM16)); |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 60 | const auto ArithmeticSubtractionS16Dataset = combine(combine(framework::dataset::make("DataType", { DataType::U8, DataType::S16 }), framework::dataset::make("DataType", DataType::S16)), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 61 | framework::dataset::make("DataType", DataType::S16)); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 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)); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 66 | const auto EmptyActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 67 | { ActivationLayerInfo() }); |
| 68 | const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 69 | { |
| 70 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.75f, 0.25f), |
| 71 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC, 0.75f, 0.25f) |
| 72 | }); |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 73 | const auto InPlaceDataSet = framework::dataset::make("InPlace", { false, true }); |
| 74 | const auto OutOfPlaceDataSet = framework::dataset::make("InPlace", { false }); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 75 | } // namespace |
| 76 | |
| 77 | TEST_SUITE(CL) |
| 78 | TEST_SUITE(ArithmeticSubtraction) |
| 79 | |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 80 | // *INDENT-OFF* |
| 81 | // clang-format off |
| 82 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 83 | framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 84 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 85 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Window shrink |
| 86 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Invalid data type combination |
| 87 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Mismatching shapes |
| 88 | }), |
| 89 | framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 90 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 91 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), |
| 92 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), |
| 93 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 94 | })), |
| 95 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), |
| 96 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 97 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), |
| 98 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), |
| 99 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 100 | })), |
| 101 | framework::dataset::make("Expected", { true, true, false, false, false})), |
| 102 | input1_info, input2_info, output_info, expected) |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 103 | { |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 104 | 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] | 105 | } |
| 106 | // clang-format on |
| 107 | // *INDENT-ON* |
| 108 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 109 | TEST_SUITE(InPlaceValidate) |
| 110 | TEST_CASE(SingleTensor, framework::DatasetMode::ALL) |
| 111 | { |
| 112 | const auto random_shape = TensorShape{ 9, 9 }; |
| 113 | const auto single_tensor_info = TensorInfo{ random_shape, 1, DataType::F32 }; |
| 114 | |
| 115 | Status result = CLArithmeticSubtraction::validate(&single_tensor_info, &single_tensor_info, &single_tensor_info, ConvertPolicy::WRAP); |
| 116 | ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS); |
| 117 | } |
| 118 | |
| 119 | TEST_CASE(ValidBroadCast, framework::DatasetMode::ALL) |
| 120 | { |
| 121 | const auto larger_shape = TensorShape{ 27U, 13U, 2U }; |
| 122 | const auto smaller_shape = TensorShape{ 1U, 13U, 2U }; |
| 123 | |
| 124 | const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 }; |
| 125 | const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 }; |
| 126 | |
| 127 | Status result = CLArithmeticSubtraction::validate(&larger_tensor_info, &smaller_tensor_info, &larger_tensor_info, ConvertPolicy::WRAP); |
| 128 | ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS); |
| 129 | } |
| 130 | |
| 131 | TEST_CASE(InvalidBroadcastOutput, framework::DatasetMode::ALL) |
| 132 | { |
| 133 | const auto larger_shape = TensorShape{ 27U, 13U, 2U }; |
| 134 | const auto smaller_shape = TensorShape{ 1U, 13U, 2U }; |
| 135 | |
| 136 | const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 }; |
| 137 | const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 }; |
| 138 | |
| 139 | Status result = CLArithmeticSubtraction::validate(&larger_tensor_info, &smaller_tensor_info, &smaller_tensor_info, ConvertPolicy::WRAP); |
| 140 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 141 | } |
| 142 | |
| 143 | TEST_CASE(InvalidBroadcastBoth, framework::DatasetMode::ALL) |
| 144 | { |
| 145 | const auto shape0 = TensorShape{ 9U, 9U }; |
| 146 | const auto shape1 = TensorShape{ 9U, 1U, 2U }; |
| 147 | |
| 148 | const auto info0 = TensorInfo{ shape0, 1, DataType::F32 }; |
| 149 | const auto info1 = TensorInfo{ shape1, 1, DataType::F32 }; |
| 150 | |
| 151 | Status result{}; |
| 152 | |
| 153 | result = CLArithmeticSubtraction::validate(&info0, &info1, &info0, ConvertPolicy::WRAP); |
| 154 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 155 | |
| 156 | result = CLArithmeticSubtraction::validate(&info0, &info1, &info1, ConvertPolicy::WRAP); |
| 157 | ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS); |
| 158 | } |
| 159 | TEST_SUITE_END() // InPlaceValidate |
| 160 | |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 161 | template <typename T> |
| 162 | using CLArithmeticSubtractionFixture = ArithmeticSubtractionValidationFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>; |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 163 | |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 164 | TEST_SUITE(Integer) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 165 | TEST_SUITE(U8) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 166 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 167 | shape, policy) |
| 168 | { |
| 169 | // Create tensors |
| 170 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::U8); |
| 171 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::U8); |
| 172 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); |
| 173 | |
| 174 | // Create and Configure function |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 175 | CLArithmeticSubtraction add; |
| 176 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 177 | |
| 178 | // Validate valid region |
| 179 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 180 | validate(dst.info()->valid_region(), valid_region); |
| 181 | |
| 182 | // Validate padding |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 183 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 184 | validate(ref_src1.info()->padding(), padding); |
| 185 | validate(ref_src2.info()->padding(), padding); |
| 186 | validate(dst.info()->padding(), padding); |
| 187 | } |
| 188 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 189 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ArithmeticSubtractionU8Dataset), |
| 190 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 191 | OutOfPlaceDataSet)) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 192 | { |
| 193 | // Validate output |
| 194 | validate(CLAccessor(_target), _reference); |
| 195 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 196 | TEST_SUITE_END() // U8 |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 197 | |
| 198 | TEST_SUITE(S16) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 199 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 200 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 201 | shape, data_type, policy) |
| 202 | { |
| 203 | // Create tensors |
| 204 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, data_type); |
| 205 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::S16); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 206 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::S16); |
| 207 | |
| 208 | // Create and Configure function |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 209 | CLArithmeticSubtraction add; |
| 210 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 211 | |
| 212 | // Validate valid region |
| 213 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 214 | validate(dst.info()->valid_region(), valid_region); |
| 215 | |
| 216 | // Validate padding |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 217 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 218 | validate(ref_src1.info()->padding(), padding); |
| 219 | validate(ref_src2.info()->padding(), padding); |
| 220 | validate(dst.info()->padding(), padding); |
| 221 | } |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 222 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 223 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ArithmeticSubtractionS16Dataset), |
| 224 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 225 | OutOfPlaceDataSet)) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 226 | { |
| 227 | // Validate output |
| 228 | validate(CLAccessor(_target), _reference); |
| 229 | } |
| 230 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 231 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ArithmeticSubtractionS16Dataset), |
| 232 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
| 233 | OutOfPlaceDataSet)) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 234 | { |
| 235 | // Validate output |
| 236 | validate(CLAccessor(_target), _reference); |
| 237 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 238 | TEST_SUITE_END() // S16 |
| 239 | TEST_SUITE_END() // Integer |
| 240 | |
| 241 | template <typename T> |
| 242 | using CLArithmeticSubtractionQuantizedFixture = ArithmeticSubtractionValidationQuantizedFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>; |
| 243 | |
| 244 | TEST_SUITE(Quantized) |
| 245 | TEST_SUITE(QASYMM8) |
| 246 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 247 | shape, policy) |
| 248 | { |
| 249 | // Create tensors |
| 250 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QASYMM8); |
| 251 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QASYMM8); |
| 252 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::QASYMM8); |
| 253 | |
| 254 | // Create and Configure function |
| 255 | CLArithmeticSubtraction add; |
| 256 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
| 257 | |
| 258 | // Validate valid region |
| 259 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 260 | validate(dst.info()->valid_region(), valid_region); |
| 261 | |
| 262 | // Validate padding |
| 263 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
| 264 | validate(ref_src1.info()->padding(), padding); |
| 265 | validate(ref_src2.info()->padding(), padding); |
| 266 | validate(dst.info()->padding(), padding); |
| 267 | } |
| 268 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 269 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 270 | ArithmeticSubtractionQASYMM8Dataset), |
| 271 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 272 | framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 255.f, 20) })), |
| 273 | framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 274 | framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 255.f, 5) })), |
| 275 | InPlaceDataSet)) |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 276 | { |
| 277 | // Validate output |
| 278 | validate(CLAccessor(_target), _reference); |
| 279 | } |
| 280 | TEST_SUITE_END() // QASYMM8 |
Kurtis Charnock | ec0c412 | 2019-12-05 14:13:46 +0000 | [diff] [blame] | 281 | TEST_SUITE(QASYMM8_SIGNED) |
| 282 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 283 | shape, policy) |
| 284 | { |
| 285 | // Create tensors |
| 286 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED); |
| 287 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED); |
| 288 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::QASYMM8_SIGNED); |
| 289 | |
| 290 | // Create and Configure function |
| 291 | CLArithmeticSubtraction sub; |
| 292 | sub.configure(&ref_src1, &ref_src2, &dst, policy); |
| 293 | |
| 294 | // Validate valid region |
| 295 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 296 | validate(dst.info()->valid_region(), valid_region); |
| 297 | |
| 298 | // Validate padding |
| 299 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
| 300 | validate(ref_src1.info()->padding(), padding); |
| 301 | validate(ref_src2.info()->padding(), padding); |
| 302 | validate(dst.info()->padding(), padding); |
| 303 | } |
| 304 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 305 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), |
Kurtis Charnock | ec0c412 | 2019-12-05 14:13:46 +0000 | [diff] [blame] | 306 | ArithmeticSubtractionQASYMM8SignedDataset), |
| 307 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 308 | framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 255.f, 10) })), |
| 309 | framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 255.f, 10) })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 310 | framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 255.f, 5) })), |
| 311 | InPlaceDataSet)) |
Kurtis Charnock | ec0c412 | 2019-12-05 14:13:46 +0000 | [diff] [blame] | 312 | { |
| 313 | // Validate output |
| 314 | validate(CLAccessor(_target), _reference); |
| 315 | } |
| 316 | TEST_SUITE_END() // QASYMM8_SIGNED |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 317 | TEST_SUITE(QSYMM16) |
| 318 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 319 | shape, policy) |
| 320 | { |
| 321 | // Create tensors |
| 322 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::QSYMM16); |
| 323 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::QSYMM16); |
| 324 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::QSYMM16); |
| 325 | |
| 326 | // Create and Configure function |
| 327 | CLArithmeticSubtraction sub; |
| 328 | sub.configure(&ref_src1, &ref_src2, &dst, policy); |
| 329 | |
| 330 | // Validate valid region |
| 331 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 332 | validate(dst.info()->valid_region(), valid_region); |
| 333 | |
| 334 | // Validate padding |
| 335 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
| 336 | validate(ref_src1.info()->padding(), padding); |
| 337 | validate(ref_src2.info()->padding(), padding); |
| 338 | validate(dst.info()->padding(), padding); |
| 339 | } |
| 340 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 341 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionQuantizedFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 342 | ArithmeticSubtractionQSYMM16Dataset), |
| 343 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })), |
| 344 | framework::dataset::make("Src0QInfo", { QuantizationInfo(1.f / 32768.f, 0), QuantizationInfo(5.f / 32768.f, 0) })), |
| 345 | framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 32768.f, 0), QuantizationInfo(5.f / 32768.f, 0) })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 346 | framework::dataset::make("OutQInfo", { QuantizationInfo(5.f / 32768.f, 0) })), |
| 347 | OutOfPlaceDataSet)) |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 348 | { |
| 349 | // Validate output |
| 350 | validate(CLAccessor(_target), _reference); |
| 351 | } |
| 352 | TEST_SUITE_END() // QSYMM16 |
| 353 | TEST_SUITE_END() // Quantized |
Isabella Gottardi | b5908c2 | 2017-10-30 15:28:13 +0000 | [diff] [blame] | 354 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 355 | template <typename T> |
| 356 | using CLArithmeticSubtractionFloatFixture = ArithmeticSubtractionValidationFloatFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>; |
| 357 | |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 358 | TEST_SUITE(Float) |
| 359 | TEST_SUITE(FP16) |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 360 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFloatFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::SmallShapes(), ArithmeticSubtractionFP16Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 361 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 362 | EmptyActivationFunctionsDataset), |
| 363 | OutOfPlaceDataSet)) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 364 | { |
| 365 | // Validate output |
| 366 | validate(CLAccessor(_target), _reference); |
| 367 | } |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 368 | FIXTURE_DATA_TEST_CASE(RunWithActivation, CLArithmeticSubtractionFloatFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::TinyShapes(), |
| 369 | ArithmeticSubtractionFP16Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 370 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 371 | ActivationFunctionsDataset), |
| 372 | InPlaceDataSet)) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 373 | { |
| 374 | // Validate output |
| 375 | validate(CLAccessor(_target), _reference); |
| 376 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 377 | TEST_SUITE_END() // FP16 |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 378 | |
| 379 | TEST_SUITE(FP32) |
Michalis Spyrou | 8094325 | 2019-01-10 17:19:50 +0000 | [diff] [blame] | 380 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 381 | shape, policy) |
| 382 | { |
| 383 | // Create tensors |
| 384 | CLTensor ref_src1 = create_tensor<CLTensor>(shape, DataType::F32); |
| 385 | CLTensor ref_src2 = create_tensor<CLTensor>(shape, DataType::F32); |
| 386 | CLTensor dst = create_tensor<CLTensor>(shape, DataType::F32); |
| 387 | |
| 388 | // Create and Configure function |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 389 | CLArithmeticSubtraction add; |
| 390 | add.configure(&ref_src1, &ref_src2, &dst, policy); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 391 | |
| 392 | // Validate valid region |
| 393 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 394 | validate(dst.info()->valid_region(), valid_region); |
| 395 | |
| 396 | // Validate padding |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 397 | const PaddingSize padding = PaddingCalculator(shape.x(), num_elems_processed_per_iteration).required_padding(); |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 398 | validate(ref_src1.info()->padding(), padding); |
| 399 | validate(ref_src2.info()->padding(), padding); |
| 400 | validate(dst.info()->padding(), padding); |
| 401 | } |
| 402 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 403 | FIXTURE_DATA_TEST_CASE(RunSmall, CLArithmeticSubtractionFloatFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), |
| 404 | ArithmeticSubtractionFP32Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 405 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 406 | EmptyActivationFunctionsDataset), |
| 407 | OutOfPlaceDataSet)) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 408 | { |
| 409 | // Validate output |
| 410 | validate(CLAccessor(_target), _reference); |
| 411 | } |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 412 | FIXTURE_DATA_TEST_CASE(RunWithActivation, CLArithmeticSubtractionFloatFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::TinyShapes(), |
| 413 | ArithmeticSubtractionFP32Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 414 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 415 | ActivationFunctionsDataset), |
| 416 | InPlaceDataSet)) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 417 | { |
| 418 | // Validate output |
| 419 | validate(CLAccessor(_target), _reference); |
| 420 | } |
| 421 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 422 | FIXTURE_DATA_TEST_CASE(RunLarge, CLArithmeticSubtractionFloatFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapes(), |
| 423 | ArithmeticSubtractionFP32Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 424 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 425 | EmptyActivationFunctionsDataset), |
| 426 | OutOfPlaceDataSet)) |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 427 | { |
| 428 | // Validate output |
| 429 | validate(CLAccessor(_target), _reference); |
| 430 | } |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 431 | |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 432 | template <typename T> |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 433 | using CLArithmeticSubtractionBroadcastFloatFixture = ArithmeticSubtractionBroadcastValidationFloatFixture<CLTensor, CLAccessor, CLArithmeticSubtraction, T>; |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 434 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 435 | FIXTURE_DATA_TEST_CASE(RunSmallBroadcast, CLArithmeticSubtractionBroadcastFloatFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapesBroadcast(), |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 436 | ArithmeticSubtractionFP32Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 437 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 438 | EmptyActivationFunctionsDataset), |
| 439 | OutOfPlaceDataSet)) |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 440 | { |
| 441 | // Validate output |
| 442 | validate(CLAccessor(_target), _reference); |
| 443 | } |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 444 | FIXTURE_DATA_TEST_CASE(RunWithActivationBroadcast, CLArithmeticSubtractionBroadcastFloatFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::TinyShapesBroadcast(), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 445 | ArithmeticSubtractionFP32Dataset), |
| 446 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 447 | ActivationFunctionsDataset), |
| 448 | OutOfPlaceDataSet)) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 449 | { |
| 450 | // Validate output |
| 451 | validate(CLAccessor(_target), _reference); |
| 452 | } |
| 453 | |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 454 | FIXTURE_DATA_TEST_CASE(RunLargeBroadcast, CLArithmeticSubtractionBroadcastFloatFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapesBroadcast(), |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 455 | ArithmeticSubtractionFP32Dataset), |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 456 | framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })), |
Georgios Pinitas | b2842be | 2020-06-22 21:27:14 +0100 | [diff] [blame] | 457 | EmptyActivationFunctionsDataset), |
| 458 | OutOfPlaceDataSet)) |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 459 | { |
| 460 | // Validate output |
| 461 | validate(CLAccessor(_target), _reference); |
| 462 | } |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 463 | TEST_SUITE_END() // FP32 |
| 464 | TEST_SUITE_END() // Float |
Georgios Pinitas | cbf39c6 | 2018-09-10 15:07:45 +0100 | [diff] [blame] | 465 | |
Michele Di Giorgio | 6997fc9 | 2019-06-18 10:23:22 +0100 | [diff] [blame] | 466 | TEST_SUITE_END() // ArithmeticSubtraction |
| 467 | TEST_SUITE_END() // CL |
Sanghoon Lee | 72898fe | 2017-09-01 11:42:16 +0100 | [diff] [blame] | 468 | } // namespace validation |
| 469 | } // namespace test |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 470 | } // namespace arm_compute |