Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | a1f7e33 | 2018-01-22 17:26:36 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +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 CONNECTION 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/CLActivationLayer.h" |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 30 | #include "tests/datasets/ActivationFunctionsDataset.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/ActivationLayerFixture.h" |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
| 46 | /** Define tolerance of the activation layer. |
| 47 | * |
| 48 | * @param[in] activation The activation function used. |
| 49 | * @param[in] data_type Data type. |
| 50 | * |
| 51 | * @return Tolerance depending on the activation function. |
| 52 | */ |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 53 | AbsoluteTolerance<float> tolerance(ActivationLayerInfo::ActivationFunction activation, DataType data_type) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 54 | { |
Moritz Pflanzer | f07f145 | 2017-08-08 17:28:39 +0100 | [diff] [blame] | 55 | constexpr float epsilon = 1e-6f; |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 56 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 57 | switch(activation) |
| 58 | { |
| 59 | case ActivationLayerInfo::ActivationFunction::LINEAR: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 60 | return AbsoluteTolerance<float>(data_type == DataType::F16 ? 0.2f : epsilon); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 61 | case ActivationLayerInfo::ActivationFunction::SQUARE: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 62 | return AbsoluteTolerance<float>(data_type == DataType::F16 ? 0.1f : epsilon); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 63 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 64 | if(is_data_type_fixed_point(data_type)) |
| 65 | { |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 66 | return AbsoluteTolerance<float>(5.f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 67 | } |
| 68 | else |
| 69 | { |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 70 | return AbsoluteTolerance<float>(data_type == DataType::F16 ? 0.001f : epsilon); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 71 | } |
| 72 | case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 73 | return AbsoluteTolerance<float>(data_type == DataType::F16 ? 0.00001f : epsilon); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 74 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
| 75 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 76 | if(is_data_type_fixed_point(data_type)) |
| 77 | { |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 78 | return AbsoluteTolerance<float>(5.f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 79 | } |
| 80 | else |
| 81 | { |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 82 | return AbsoluteTolerance<float>(data_type == DataType::F16 ? 0.01f : 0.00001f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 83 | } |
| 84 | case ActivationLayerInfo::ActivationFunction::TANH: |
| 85 | if(is_data_type_fixed_point(data_type)) |
| 86 | { |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 87 | return AbsoluteTolerance<float>(5.f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 88 | } |
| 89 | else |
| 90 | { |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 91 | return AbsoluteTolerance<float>(data_type == DataType::F16 ? 0.001f : 0.00001f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 92 | } |
| 93 | default: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 94 | return AbsoluteTolerance<float>(epsilon); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 95 | } |
| 96 | } |
| 97 | |
| 98 | /** CNN data types */ |
| 99 | const auto CNNDataTypes = framework::dataset::make("DataType", |
| 100 | { |
| 101 | DataType::F16, |
| 102 | DataType::F32, |
| 103 | DataType::QS8, |
| 104 | DataType::QS16, |
| 105 | }); |
| 106 | |
| 107 | /** Input data sets. */ |
| 108 | const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); |
| 109 | } // namespace |
| 110 | |
| 111 | TEST_SUITE(CL) |
| 112 | TEST_SUITE(ActivationLayer) |
| 113 | |
| 114 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), |
| 115 | shape, data_type, in_place) |
| 116 | { |
| 117 | // Set fixed point position data type allowed |
| 118 | const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; |
| 119 | |
| 120 | // Create tensors |
| 121 | CLTensor src = create_tensor<CLTensor>(shape, data_type, 1, fixed_point_position); |
| 122 | CLTensor dst = create_tensor<CLTensor>(shape, data_type, 1, fixed_point_position); |
| 123 | |
| 124 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 125 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 126 | |
| 127 | // Create and configure function |
| 128 | CLActivationLayer act_layer; |
| 129 | |
| 130 | if(in_place) |
| 131 | { |
| 132 | act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); |
| 137 | } |
| 138 | |
| 139 | // Validate valid region |
| 140 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 141 | validate(src.info()->valid_region(), valid_region); |
| 142 | |
| 143 | if(!in_place) |
| 144 | { |
| 145 | validate(dst.info()->valid_region(), valid_region); |
| 146 | } |
| 147 | |
| 148 | // Validate padding |
| 149 | const int step = 16 / arm_compute::data_size_from_type(data_type); |
| 150 | const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); |
| 151 | validate(src.info()->padding(), padding); |
| 152 | |
| 153 | if(!in_place) |
| 154 | { |
| 155 | validate(dst.info()->padding(), padding); |
| 156 | } |
| 157 | } |
| 158 | |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 159 | // *INDENT-OFF* |
| 160 | // clang-format off |
| 161 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
| 162 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data types |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 163 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Window shrink |
| 164 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 165 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 166 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), // Unsupported activation |
| 167 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes |
| 168 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 2), // Mismatching fixed point |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 169 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), |
| 170 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 171 | }), |
| 172 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), |
| 173 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 174 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 175 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 176 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), |
| 177 | TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), |
| 178 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QS8, 3), |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 179 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QS8, 2), |
| 180 | TensorInfo(), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 181 | })), |
| 182 | framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 183 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 184 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 185 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), |
Michele Di Giorgio | a1f7e33 | 2018-01-22 17:26:36 +0000 | [diff] [blame] | 186 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 187 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 188 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 189 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 190 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 191 | })), |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 192 | framework::dataset::make("Expected", { false, false, true, true, false, false, false, true, true })), |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 193 | input_info, output_info, act_info, expected) |
| 194 | { |
Giorgio Arena | 2995f5b | 2017-11-29 17:33:59 +0000 | [diff] [blame] | 195 | ARM_COMPUTE_EXPECT(bool(CLActivationLayer::validate(&input_info.clone()->set_is_resizable(false), (output_info.total_size() == 0) ? nullptr : &output_info.clone()->set_is_resizable(false), act_info)) == expected, framework::LogLevel::ERRORS); |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 196 | } |
| 197 | // clang-format on |
| 198 | // *INDENT-ON* |
| 199 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 200 | template <typename T> |
| 201 | using CLActivationLayerFixture = ActivationValidationFixture<CLTensor, CLAccessor, CLActivationLayer, T>; |
| 202 | |
| 203 | TEST_SUITE(Float) |
| 204 | TEST_SUITE(FP16) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 205 | FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), |
| 206 | framework::dataset::make("DataType", |
| 207 | DataType::F16))) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 208 | { |
| 209 | // Validate output |
| 210 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 211 | } |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 212 | FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), |
| 213 | framework::dataset::make("DataType", |
| 214 | DataType::F16))) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 215 | { |
| 216 | // Validate output |
| 217 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 218 | } |
| 219 | TEST_SUITE_END() |
| 220 | |
| 221 | TEST_SUITE(FP32) |
| 222 | FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", |
| 223 | DataType::F32))) |
| 224 | { |
| 225 | // Validate output |
| 226 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 227 | } |
| 228 | FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", |
| 229 | DataType::F32))) |
| 230 | { |
| 231 | // Validate output |
| 232 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 233 | } |
| 234 | TEST_SUITE_END() |
| 235 | TEST_SUITE_END() |
| 236 | |
| 237 | template <typename T> |
| 238 | using CLActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture<CLTensor, CLAccessor, CLActivationLayer, T>; |
| 239 | |
Michel Iwaniec | 66cc12f | 2017-12-07 17:26:40 +0000 | [diff] [blame] | 240 | TEST_SUITE(FixedPoint) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 241 | TEST_SUITE(QS8) |
| 242 | // We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause |
| 243 | // overflowing issues in most of the transcendentals functions. |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 244 | FIXTURE_DATA_TEST_CASE(RunTiny, CLActivationLayerFixedPointFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::TinyShapes(), ActivationDataset), |
| 245 | framework::dataset::make("DataType", |
| 246 | DataType::QS8)), |
| 247 | framework::dataset::make("FractionalBits", 3, 6))) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 248 | { |
| 249 | // Validate output |
| 250 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 251 | } |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 252 | FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 253 | framework::dataset::make("DataType", |
| 254 | DataType::QS8)), |
| 255 | framework::dataset::make("FractionalBits", 3, 6))) |
| 256 | { |
| 257 | // Validate output |
| 258 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 259 | } |
| 260 | TEST_SUITE_END() |
| 261 | |
| 262 | TEST_SUITE(QS16) |
| 263 | // Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 264 | FIXTURE_DATA_TEST_CASE(RunTiny, CLActivationLayerFixedPointFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::TinyShapes(), ActivationDataset), |
| 265 | framework::dataset::make("DataType", |
| 266 | DataType::QS16)), |
| 267 | framework::dataset::make("FractionalBits", 1, 14))) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 268 | { |
| 269 | // Validate output |
| 270 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 271 | } |
Anthony Barbier | 1c0d0ff | 2018-01-31 13:05:09 +0000 | [diff] [blame] | 272 | FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 273 | framework::dataset::make("DataType", |
| 274 | DataType::QS16)), |
| 275 | framework::dataset::make("FractionalBits", 1, 14))) |
| 276 | { |
| 277 | // Validate output |
| 278 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 279 | } |
| 280 | TEST_SUITE_END() |
| 281 | TEST_SUITE_END() |
| 282 | |
Michel Iwaniec | 66cc12f | 2017-12-07 17:26:40 +0000 | [diff] [blame] | 283 | template <typename T> |
| 284 | using CLActivationLayerQuantizedFixture = ActivationValidationQuantizedFixture<CLTensor, CLAccessor, CLActivationLayer, T>; |
| 285 | |
| 286 | /** Input data sets. */ |
Michele Di Giorgio | a1f7e33 | 2018-01-22 17:26:36 +0000 | [diff] [blame] | 287 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationFunction", { ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 288 | ActivationLayerInfo::ActivationFunction::RELU, |
| 289 | ActivationLayerInfo::ActivationFunction::BOUNDED_RELU |
| 290 | }); |
| 291 | |
| 292 | const auto QuantizedActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), QuantizedActivationFunctionsDataset), |
Michel Iwaniec | 66cc12f | 2017-12-07 17:26:40 +0000 | [diff] [blame] | 293 | framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); |
| 294 | |
| 295 | TEST_SUITE(Quantized) |
| 296 | TEST_SUITE(QASYMM8) |
| 297 | FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), QuantizedActivationDataset), |
| 298 | framework::dataset::make("DataType", |
| 299 | DataType::QASYMM8)), |
| 300 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.1f, 128.0f) }))) |
| 301 | { |
| 302 | // Validate output |
| 303 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 304 | } |
| 305 | FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), QuantizedActivationDataset), |
| 306 | framework::dataset::make("DataType", |
| 307 | DataType::QASYMM8)), |
| 308 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.1f, 128.0f) }))) |
| 309 | { |
| 310 | // Validate output |
| 311 | validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); |
| 312 | } |
| 313 | TEST_SUITE_END() |
| 314 | TEST_SUITE_END() |
| 315 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 316 | TEST_SUITE_END() |
| 317 | TEST_SUITE_END() |
| 318 | } // namespace validation |
| 319 | } // namespace test |
| 320 | } // namespace arm_compute |