From 5b61fd3fbaf41031232296abde56258d12ba3340 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Tue, 12 Sep 2017 15:51:33 +0100 Subject: COMPMID-417: Fix validation Change-Id: I7a745037136bc6e02d177f65fe4f4cd43873b98e Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87406 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/validation/Validation.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/validation/Validation.h') diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index e70c970cc1..6bc42a4ed6 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -226,11 +226,11 @@ struct compare_base T _tolerance{}; }; -template +template struct compare; template -struct compare, U> : public compare_base> +struct compare> : public compare_base> { using compare_base>::compare_base; @@ -245,12 +245,16 @@ struct compare, U> : public compare_base(std::abs(this->_target - this->_reference)) <= static_cast(this->_tolerance); + using comparison_type = typename std::conditional::value, int64_t, U>::type; + + const comparison_type abs_difference(std::abs(static_cast(this->_target) - static_cast(this->_reference))); + + return abs_difference <= static_cast(this->_tolerance); } }; template -struct compare, U> : public compare_base> +struct compare> : public compare_base> { using compare_base>::compare_base; @@ -325,7 +329,7 @@ void validate(const IAccessor &tensor, const SimpleTensor &reference, const V const T &target_value = reinterpret_cast(tensor(id))[c]; const T &reference_value = reinterpret_cast(reference(id))[c]; - if(!compare(target_value, reference_value, tolerance_value)) + if(!compare(target_value, reference_value, tolerance_value)) { ARM_COMPUTE_TEST_INFO("id = " << id); ARM_COMPUTE_TEST_INFO("channel = " << c); @@ -359,7 +363,7 @@ void validate(T target, T reference, U tolerance) ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference)); ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target)); ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance))); - ARM_COMPUTE_EXPECT((compare(target, reference, tolerance)), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT((compare(target, reference, tolerance)), framework::LogLevel::ERRORS); } } // namespace validation } // namespace test -- cgit v1.2.1