diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2018-02-26 15:22:16 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:48:12 +0000 |
commit | ff6c260a65a1341e96e5cbf60dc492172530002f (patch) | |
tree | 5474cebfbdca3dfa3d9904193f3a804009c7d477 /tests/validation | |
parent | 88627fbe2502018f6a93fcfc686b5a7f2d54a2a9 (diff) | |
download | ComputeLibrary-ff6c260a65a1341e96e5cbf60dc492172530002f.tar.gz |
COMPMID-945: Fix GEMM CL FP32 mismatch - V2
The approach used in e415fc13 was not correct. Switch to allowing to use an
absolute tolerance if the relative tolerance comparison fails.
Change-Id: I8d94d2f8edd3e0eb7388d3d8ac3ebfc37790e267
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/122269
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/CL/GEMM.cpp | 6 | ||||
-rw-r--r-- | tests/validation/Validation.h | 31 |
2 files changed, 28 insertions, 9 deletions
diff --git a/tests/validation/CL/GEMM.cpp b/tests/validation/CL/GEMM.cpp index 6539090fcf..217edf4438 100644 --- a/tests/validation/CL/GEMM.cpp +++ b/tests/validation/CL/GEMM.cpp @@ -49,7 +49,9 @@ namespace validation { namespace { -RelativeTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ +RelativeTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ +constexpr float abs_tolerance_f32( + 0.0001f); /**< Absolute tolerance value for comparing reference's output against implementation's output for floating point data types in case using relative tolerance fails because of small values */ RelativeTolerance<half_float::half> tolerance_f16(half(0.2)); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ constexpr AbsoluteTolerance<float> tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ constexpr float tolerance_num = 0.02f; /**< Tolerance number */ @@ -200,7 +202,7 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture<float>, framework::DatasetMode::P FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) { // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); + validate(CLAccessor(_target), _reference, tolerance_f32, 0.f, abs_tolerance_f32); } TEST_SUITE_END() TEST_SUITE_END() diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index 651b7e5b3c..506318018d 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -180,7 +180,7 @@ void validate(const arm_compute::PaddingSize &padding, const arm_compute::Paddin * other test cases. */ template <typename T, typename U = AbsoluteTolerance<T>> -void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value = U(), float tolerance_number = 0.f); +void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value = U(), float tolerance_number = 0.f, float absolute_tolerance_value = 0.f); /** Validate tensors with valid region. * @@ -193,7 +193,7 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U toler * other test cases. */ template <typename T, typename U = AbsoluteTolerance<T>> -void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f); +void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f, float absolute_tolerance_value = 0.f); /** Validate tensors with valid mask. * @@ -206,7 +206,8 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const V * other test cases. */ template <typename T, typename U = AbsoluteTolerance<T>> -void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value = U(), float tolerance_number = 0.f); +void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value = U(), float tolerance_number = 0.f, + float absolute_tolerance_value = 0.f); /** Validate tensors against constant value. * @@ -317,10 +318,10 @@ struct compare<RelativeTolerance<U>> : public compare_base<RelativeTolerance<U>> }; template <typename T, typename U> -void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number) +void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number, float absolute_tolerance_value) { // Validate with valid region covering the entire shape - validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number); + validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number, absolute_tolerance_value); } template <typename T, typename U, typename = typename std::enable_if<std::is_integral<T>::value>::type> @@ -331,7 +332,7 @@ void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, U } template <typename T, typename U> -void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number) +void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number, float absolute_tolerance_value) { int64_t num_mismatches = 0; int64_t num_elements = 0; @@ -365,6 +366,14 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const V if(!compare<U>(target_value, reference_value, tolerance_value)) { + if(absolute_tolerance_value != 0.f) + { + const AbsoluteTolerance<float> abs_tolerance(absolute_tolerance_value); + if(compare<AbsoluteTolerance<float>>(target_value, reference_value, abs_tolerance)) + { + continue; + } + } ARM_COMPUTE_TEST_INFO("id = " << id); ARM_COMPUTE_TEST_INFO("channel = " << c); ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value)); @@ -474,7 +483,7 @@ void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, co } template <typename T, typename U> -void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value, float tolerance_number) +void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value, float tolerance_number, float absolute_tolerance_value) { int64_t num_mismatches = 0; int64_t num_elements = 0; @@ -508,6 +517,14 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const S if(!compare<U>(target_value, reference_value, tolerance_value)) { + if(absolute_tolerance_value != 0.f) + { + const AbsoluteTolerance<float> abs_tolerance(absolute_tolerance_value); + if(compare<AbsoluteTolerance<float>>(target_value, reference_value, abs_tolerance)) + { + continue; + } + } ARM_COMPUTE_TEST_INFO("id = " << id); ARM_COMPUTE_TEST_INFO("channel = " << c); ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value)); |