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