diff options
Diffstat (limited to 'tests/validation/Validation.h')
-rw-r--r-- | tests/validation/Validation.h | 31 |
1 files changed, 24 insertions, 7 deletions
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)); |