32 #include "tests/datasets/ActivationFunctionsDataset.h" 33 #include "tests/datasets/ShapeDatasets.h" 38 #include "tests/validation/fixtures/ActivationLayerFixture.h" 50 RelativeTolerance<float> tolerance_float_sqrt(0.0001f);
71 #if defined(__ARM_FEATURE_SVE) 72 return RelativeTolerance<float>(0.25f);
73 #else // !defined(__ARM_FEATURE_SVE) 74 return RelativeTolerance<float>(0.1f);
75 #endif // defined(__ARM_FEATURE_SVE) 77 return RelativeTolerance<float>(0.05f);
83 #if defined(__ARM_FEATURE_SVE) 84 return RelativeTolerance<float>(0.9f);
85 #else // !defined(__ARM_FEATURE_SVE) 86 return RelativeTolerance<float>(0.01f);
87 #endif // defined(__ARM_FEATURE_SVE) 89 return RelativeTolerance<float>(0.00001f);
92 return RelativeTolerance<float>(0.f);
114 #if defined(__ARM_FEATURE_SVE) 115 return AbsoluteTolerance<float>(0.25f);
116 #else // !defined(__ARM_FEATURE_SVE) 117 return AbsoluteTolerance<float>(0.01f);
118 #endif // defined(__ARM_FEATURE_SVE) 120 return AbsoluteTolerance<float>(0.00001f);
126 #if defined(__ARM_FEATURE_SVE) 127 return AbsoluteTolerance<float>(0.9f);
128 #else // !defined(__ARM_FEATURE_SVE) 129 return AbsoluteTolerance<float>(0.01f);
130 #endif // defined(__ARM_FEATURE_SVE) 132 return AbsoluteTolerance<float>(0.00001f);
135 return AbsoluteTolerance<float>(0.f);
155 return AbsoluteTolerance<uint8_t>(1);
157 return AbsoluteTolerance<uint8_t>(0);
161 constexpr AbsoluteTolerance<int16_t> tolerance_qsymm16(1);
166 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 177 template <typename T, ARM_COMPUTE_REQUIRES_TA(arm_compute::utils::traits::is_floating_point<T>::value)>
178 void test_float_sqrt_boundary_value()
180 constexpr
auto vector_size = uint32_t{ 16 };
183 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 187 const auto boundary_value_vector = std::vector<T>
189 std::numeric_limits<T>::min(),
192 std::numeric_limits<T>::max(),
197 auto shape = TensorShape{ vector_size + boundary_value_vector.size() };
201 auto act = NEActivationLayer{};
202 act.configure(&
src,
nullptr,
info);
203 src.allocator()->allocate();
204 library->fill_static_values(Accessor(
src), boundary_value_vector);
207 auto reference_src = SimpleTensor<T> {
shape, data_type };
208 library->fill_static_values(reference_src, boundary_value_vector);
209 auto reference_dst = reference::activation_layer<T>(reference_src,
info);
211 validate(Accessor(
src), reference_dst, tolerance_float_sqrt);
242 template <
typename T>
246 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 250 test_float_sqrt_boundary_value<half>();
257 validate(
Accessor(_target), _reference, relative_tolerance(_data_type, _function), 0.f, absolute_tolerance(_data_type, _function));
265 test_float_sqrt_boundary_value<float>();
272 validate(
Accessor(_target), _reference, relative_tolerance(_data_type, _function), 0.f, absolute_tolerance(_data_type, _function));
277 template <
typename T>
278 using NEActivationLayerQuantizedFixture = ActivationValidationQuantizedFixture<Tensor, Accessor, NEActivationLayer, T>;
310 DataType::QASYMM8_SIGNED)),
quantized, symmetric fixed-point 16-bit number
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
[NEActivationLayer snippet]
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
const auto QuantizedActivationDataset
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Activation Layer Information class.
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
ActivationFunction
Available activation functions.
1 channel, 1 F16 per channel
ActivationValidationFixture< Tensor, Accessor, NEActivationLayer, T > NEActivationLayerFixture
Quantization information.
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
Accessor implementation for Tensor objects.
DatasetMode
Possible dataset modes.
Exponential Linear Unit ( )
std::unique_ptr< AssetsLibrary > library
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
quantized, asymmetric fixed-point 8-bit number unsigned
const auto QuantizedActivationFunctionsDataset
Input data sets.
TEST_SUITE(U8_to_S8) FIXTURE_DATA_TEST_CASE(RunSmall
validate(CLAccessor(output_state), expected_output)
const auto Int16QuantizedActivationDataset
Lower and Upper Bounded Rectifier ( )
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Upper Bounded Rectifier ( )
Store the tensor's metadata.
JoinDataset< T, U > concat(T &&dataset1, U &&dataset2)
Helper function to create a JoinDataset.
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
quantized, asymmetric fixed-point 8-bit number signed
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
DataType
Available data types.
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))