Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 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" |
Sang-Hoon Park | e728058 | 2020-10-13 23:34:09 +0100 | [diff] [blame^] | 25 | #include "arm_compute/core/utils/misc/Requires.h" |
| 26 | #include "arm_compute/core/utils/misc/Traits.h" |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 27 | #include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" |
Georgios Pinitas | 12833d0 | 2019-07-25 13:31:10 +0100 | [diff] [blame] | 28 | #include "arm_compute/runtime/RuntimeContext.h" |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 29 | #include "arm_compute/runtime/Tensor.h" |
| 30 | #include "arm_compute/runtime/TensorAllocator.h" |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 31 | #include "tests/NEON/Accessor.h" |
| 32 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 33 | #include "tests/datasets/ActivationFunctionsDataset.h" |
| 34 | #include "tests/datasets/ShapeDatasets.h" |
| 35 | #include "tests/framework/Asserts.h" |
| 36 | #include "tests/framework/Macros.h" |
| 37 | #include "tests/framework/datasets/Datasets.h" |
| 38 | #include "tests/validation/Validation.h" |
| 39 | #include "tests/validation/fixtures/ActivationLayerFixture.h" |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 40 | |
| 41 | namespace arm_compute |
| 42 | { |
| 43 | namespace test |
| 44 | { |
| 45 | namespace validation |
| 46 | { |
| 47 | namespace |
| 48 | { |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 49 | /** Define relative tolerance of the activation layer. |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 50 | * |
| 51 | * @param[in] data_type The data type used. |
| 52 | * @param[in] activation The activation function used. |
| 53 | * |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 54 | * @return Relative tolerance depending on the activation function. |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 55 | */ |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 56 | RelativeTolerance<float> relative_tolerance(DataType data_type, ActivationLayerInfo::ActivationFunction activation) |
| 57 | { |
| 58 | switch(activation) |
| 59 | { |
| 60 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 61 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
Georgios Pinitas | fb0fdcd | 2019-08-22 17:10:04 +0100 | [diff] [blame] | 62 | case ActivationLayerInfo::ActivationFunction::ELU: |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 63 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 64 | case ActivationLayerInfo::ActivationFunction::TANH: |
SiCong Li | a32e2ae | 2020-06-08 17:30:51 +0100 | [diff] [blame] | 65 | case ActivationLayerInfo::ActivationFunction::HARD_SWISH: |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 66 | switch(data_type) |
| 67 | { |
| 68 | case DataType::F16: |
| 69 | return RelativeTolerance<float>(0.1f); |
| 70 | default: |
| 71 | return RelativeTolerance<float>(0.05f); |
| 72 | } |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 73 | default: |
| 74 | return RelativeTolerance<float>(0.f); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** Define absolute tolerance of the activation layer. |
| 79 | * |
| 80 | * @param[in] data_type The data type used. |
| 81 | * @param[in] activation The activation function used. |
| 82 | * |
| 83 | * @return Absolute tolerance depending on the activation function. |
| 84 | */ |
| 85 | AbsoluteTolerance<float> absolute_tolerance(DataType data_type, ActivationLayerInfo::ActivationFunction activation) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 86 | { |
| 87 | switch(activation) |
| 88 | { |
| 89 | case ActivationLayerInfo::ActivationFunction::LOGISTIC: |
| 90 | case ActivationLayerInfo::ActivationFunction::SOFT_RELU: |
| 91 | case ActivationLayerInfo::ActivationFunction::SQRT: |
| 92 | case ActivationLayerInfo::ActivationFunction::TANH: |
SiCong Li | a32e2ae | 2020-06-08 17:30:51 +0100 | [diff] [blame] | 93 | case ActivationLayerInfo::ActivationFunction::HARD_SWISH: |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 94 | switch(data_type) |
| 95 | { |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 96 | case DataType::F16: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 97 | return AbsoluteTolerance<float>(0.01f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 98 | default: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 99 | return AbsoluteTolerance<float>(0.00001f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 100 | } |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 101 | default: |
Moritz Pflanzer | 6106a4d | 2017-08-02 09:42:27 +0100 | [diff] [blame] | 102 | return AbsoluteTolerance<float>(0.f); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | |
Georgios Pinitas | 151fa87 | 2019-06-06 14:44:44 +0100 | [diff] [blame] | 106 | /** Tolerance for quantized asymmetric operations */ |
| 107 | #if defined(__aarch64__) |
| 108 | constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(0); |
| 109 | #else // defined(__aarch64__) |
| 110 | constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); |
| 111 | #endif // defined(__aarch64__) |
| 112 | |
giuros01 | c9573f3 | 2019-06-20 10:30:17 +0100 | [diff] [blame] | 113 | constexpr AbsoluteTolerance<int16_t> tolerance_qsymm16(1); |
| 114 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 115 | /** CNN data types */ |
| 116 | const auto CNNDataTypes = framework::dataset::make("DataType", |
| 117 | { |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 118 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 119 | DataType::F16, |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 120 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 121 | DataType::F32, |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 122 | }); |
| 123 | |
morgolock | aa85cdf | 2020-02-28 15:38:28 +0000 | [diff] [blame] | 124 | const auto NeonActivationFunctionsDataset = concat(datasets::ActivationFunctions(), framework::dataset::make("ActivationFunction", ActivationLayerInfo::ActivationFunction::HARD_SWISH)); |
morgolock | 07df3d4 | 2020-02-27 11:46:28 +0000 | [diff] [blame] | 125 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 126 | /** Input data sets. */ |
morgolock | 07df3d4 | 2020-02-27 11:46:28 +0000 | [diff] [blame] | 127 | const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), NeonActivationFunctionsDataset), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); |
Sang-Hoon Park | e728058 | 2020-10-13 23:34:09 +0100 | [diff] [blame^] | 128 | |
| 129 | template <typename T, REQUIRES_TA(arm_compute::utils::traits::is_floating_point<T>::value)> |
| 130 | void test_float_sqrt_boundary_value() |
| 131 | { |
| 132 | constexpr auto vector_size = uint32_t{ 16 }; |
| 133 | |
| 134 | auto data_type = DataType::F32; |
| 135 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 136 | data_type = std::is_same<T, half>::value ? DataType::F16 : data_type; |
| 137 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
| 138 | |
| 139 | const auto boundary_value_vector = std::vector<T> |
| 140 | { |
| 141 | std::numeric_limits<T>::min(), |
| 142 | T(0), |
| 143 | std::numeric_limits<T>::epsilon(), |
| 144 | std::numeric_limits<T>::max(), |
| 145 | }; |
| 146 | |
| 147 | // the following size ensures that the whole logic (vector + left-over) to be tested |
| 148 | // using all boundary values iff boundary_value_vecotr.size() is smaller than vector_size. |
| 149 | auto shape = TensorShape{ vector_size + boundary_value_vector.size() }; |
| 150 | auto info = ActivationLayerInfo{ ActivationLayerInfo::ActivationFunction::SQRT }; |
| 151 | auto src = create_tensor<Tensor>(shape, data_type); |
| 152 | |
| 153 | auto act = NEActivationLayer{}; |
| 154 | act.configure(&src, nullptr, info); |
| 155 | src.allocator()->allocate(); |
| 156 | library->fill_static_values(Accessor(src), boundary_value_vector); |
| 157 | act.run(); |
| 158 | |
| 159 | auto reference_src = SimpleTensor<T> { shape, data_type }; |
| 160 | library->fill_static_values(reference_src, boundary_value_vector); |
| 161 | auto reference_dst = reference::activation_layer<T>(reference_src, info); |
| 162 | |
| 163 | validate(Accessor(src), reference_dst); |
| 164 | } |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 165 | } // namespace |
| 166 | |
| 167 | TEST_SUITE(NEON) |
| 168 | TEST_SUITE(ActivationLayer) |
| 169 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 170 | // *INDENT-OFF* |
| 171 | // clang-format off |
| 172 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
| 173 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data types |
| 174 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 175 | TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 176 | }), |
| 177 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), |
| 178 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
| 179 | TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 180 | })), |
| 181 | framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 182 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 183 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 184 | })), |
Vidhya Sudhan Loganathan | 0fc2545 | 2018-06-18 14:40:56 +0100 | [diff] [blame] | 185 | framework::dataset::make("Expected", { false, true, false})), |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 186 | input_info, output_info, act_info, expected) |
| 187 | { |
| 188 | bool is_valid = bool(NEActivationLayer::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), act_info)); |
| 189 | ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); |
| 190 | } |
| 191 | // clang-format on |
| 192 | // *INDENT-ON* |
| 193 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 194 | template <typename T> |
| 195 | using NEActivationLayerFixture = ActivationValidationFixture<Tensor, Accessor, NEActivationLayer, T>; |
| 196 | |
| 197 | TEST_SUITE(Float) |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 198 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 199 | TEST_SUITE(FP16) |
Sang-Hoon Park | e728058 | 2020-10-13 23:34:09 +0100 | [diff] [blame^] | 200 | TEST_CASE(SqrtBoundaryValue, framework::DatasetMode::ALL) |
| 201 | { |
| 202 | test_float_sqrt_boundary_value<half>(); |
| 203 | } |
Sang-Hoon Park | a8a7c1d | 2020-05-12 22:01:23 +0100 | [diff] [blame] | 204 | FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), ActivationDataset), |
| 205 | framework::dataset::make("DataType", |
| 206 | DataType::F16))) |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 207 | { |
| 208 | // Validate output |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 209 | validate(Accessor(_target), _reference, relative_tolerance(_data_type, _function), 0.f, absolute_tolerance(_data_type, _function)); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 210 | } |
Sang-Hoon Park | e728058 | 2020-10-13 23:34:09 +0100 | [diff] [blame^] | 211 | TEST_SUITE_END() // FP16 |
| 212 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 213 | |
| 214 | TEST_SUITE(FP32) |
Sang-Hoon Park | e728058 | 2020-10-13 23:34:09 +0100 | [diff] [blame^] | 215 | TEST_CASE(SqrtBoundaryValue, framework::DatasetMode::ALL) |
| 216 | { |
| 217 | test_float_sqrt_boundary_value<float>(); |
| 218 | } |
Sang-Hoon Park | a8a7c1d | 2020-05-12 22:01:23 +0100 | [diff] [blame] | 219 | FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", |
| 220 | DataType::F32))) |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 221 | |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 222 | { |
| 223 | // Validate output |
Georgios Pinitas | 3463a8b | 2018-08-23 13:11:53 +0100 | [diff] [blame] | 224 | validate(Accessor(_target), _reference, relative_tolerance(_data_type, _function), 0.f, absolute_tolerance(_data_type, _function)); |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 225 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 226 | TEST_SUITE_END() // FP32 |
| 227 | TEST_SUITE_END() // Float |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 228 | |
| 229 | template <typename T> |
Michel Iwaniec | 5dfeae6 | 2017-11-29 10:48:23 +0000 | [diff] [blame] | 230 | using NEActivationLayerQuantizedFixture = ActivationValidationQuantizedFixture<Tensor, Accessor, NEActivationLayer, T>; |
| 231 | |
| 232 | /** Input data sets. */ |
Michele Di Giorgio | dde3ad9 | 2018-01-23 16:55:24 +0000 | [diff] [blame] | 233 | const auto QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationFunction", { ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
Isabella Gottardi | 03bb550 | 2019-01-31 17:45:07 +0000 | [diff] [blame] | 234 | ActivationLayerInfo::ActivationFunction::RELU, |
| 235 | ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, |
Georgios Pinitas | 4b3fba1 | 2019-06-04 17:31:46 +0100 | [diff] [blame] | 236 | ActivationLayerInfo::ActivationFunction::LOGISTIC, |
| 237 | ActivationLayerInfo::ActivationFunction::TANH |
Michele Di Giorgio | dde3ad9 | 2018-01-23 16:55:24 +0000 | [diff] [blame] | 238 | }); |
morgolock | aa85cdf | 2020-02-28 15:38:28 +0000 | [diff] [blame] | 239 | |
| 240 | const auto QuantizedActivationDataset = combine(combine(framework::dataset::make("InPlace", { false }), |
| 241 | concat(QuantizedActivationFunctionsDataset, framework::dataset::make("ActivationFunction", ActivationLayerInfo::ActivationFunction::HARD_SWISH))), |
Michel Iwaniec | 5dfeae6 | 2017-11-29 10:48:23 +0000 | [diff] [blame] | 242 | framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); |
| 243 | |
| 244 | TEST_SUITE(Quantized) |
| 245 | TEST_SUITE(QASYMM8) |
Sang-Hoon Park | a8a7c1d | 2020-05-12 22:01:23 +0100 | [diff] [blame] | 246 | FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallShapes(), QuantizedActivationDataset), |
| 247 | framework::dataset::make("DataType", |
| 248 | DataType::QASYMM8)), |
| 249 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.1f, 128.0f) }))) |
Michel Iwaniec | 5dfeae6 | 2017-11-29 10:48:23 +0000 | [diff] [blame] | 250 | { |
| 251 | // Validate output |
Georgios Pinitas | 151fa87 | 2019-06-06 14:44:44 +0100 | [diff] [blame] | 252 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
Michel Iwaniec | 5dfeae6 | 2017-11-29 10:48:23 +0000 | [diff] [blame] | 253 | } |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 254 | TEST_SUITE_END() // QASYMM8 |
giuros01 | c9573f3 | 2019-06-20 10:30:17 +0100 | [diff] [blame] | 255 | |
Michalis Spyrou | 8d4d1b8 | 2019-11-28 11:31:23 +0000 | [diff] [blame] | 256 | TEST_SUITE(QASYMM8_SIGNED) |
Sang-Hoon Park | a8a7c1d | 2020-05-12 22:01:23 +0100 | [diff] [blame] | 257 | FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallShapes(), QuantizedActivationDataset), |
| 258 | framework::dataset::make("DataType", |
| 259 | DataType::QASYMM8_SIGNED)), |
| 260 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10.0f) }))) |
Michalis Spyrou | 8d4d1b8 | 2019-11-28 11:31:23 +0000 | [diff] [blame] | 261 | { |
| 262 | // Validate output |
| 263 | validate(Accessor(_target), _reference, tolerance_qasymm8); |
| 264 | } |
| 265 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 266 | |
giuros01 | c9573f3 | 2019-06-20 10:30:17 +0100 | [diff] [blame] | 267 | /** Input data sets. */ |
| 268 | const auto Int16QuantizedActivationFunctionsDataset = framework::dataset::make("ActivationFunction", { ActivationLayerInfo::ActivationFunction::LOGISTIC, |
| 269 | ActivationLayerInfo::ActivationFunction::TANH |
| 270 | }); |
| 271 | const auto Int16QuantizedActivationDataset = combine(combine(framework::dataset::make("InPlace", { false }), Int16QuantizedActivationFunctionsDataset), |
| 272 | framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); |
| 273 | |
| 274 | TEST_SUITE(QSYMM16) |
Sang-Hoon Park | a8a7c1d | 2020-05-12 22:01:23 +0100 | [diff] [blame] | 275 | FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerQuantizedFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SmallShapes(), Int16QuantizedActivationDataset), |
| 276 | framework::dataset::make("DataType", |
| 277 | DataType::QSYMM16)), |
| 278 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(1.f / 32768.f, 0.f) }))) |
giuros01 | c9573f3 | 2019-06-20 10:30:17 +0100 | [diff] [blame] | 279 | { |
| 280 | // Validate output |
| 281 | validate(Accessor(_target), _reference, tolerance_qsymm16); |
| 282 | } |
| 283 | TEST_SUITE_END() // QSYMM16 |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 284 | TEST_SUITE_END() // Quantized |
Michel Iwaniec | 5dfeae6 | 2017-11-29 10:48:23 +0000 | [diff] [blame] | 285 | |
Michalis Spyrou | aeebe4a | 2019-01-09 14:21:03 +0000 | [diff] [blame] | 286 | TEST_SUITE_END() // ActivationLayer |
| 287 | TEST_SUITE_END() // NEON |
Moritz Pflanzer | 572ade7 | 2017-07-21 17:36:33 +0100 | [diff] [blame] | 288 | } // namespace validation |
| 289 | } // namespace test |
| 290 | } // namespace arm_compute |