aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/Validation.h
diff options
context:
space:
mode:
authorMoritz Pflanzer <moritz.pflanzer@arm.com>2017-09-12 15:51:33 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit5b61fd3fbaf41031232296abde56258d12ba3340 (patch)
treea44cc3071d4d7b91480cb672c3ed4536857bb4e6 /tests/validation/Validation.h
parenta3adb3a3bdce1f2ef764c5d5098e99695323f0a3 (diff)
downloadComputeLibrary-5b61fd3fbaf41031232296abde56258d12ba3340.tar.gz
COMPMID-417: Fix validation
Change-Id: I7a745037136bc6e02d177f65fe4f4cd43873b98e Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87406 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation/Validation.h')
-rw-r--r--tests/validation/Validation.h16
1 files changed, 10 insertions, 6 deletions
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 <typename T, typename U>
+template <typename T>
struct compare;
template <typename U>
-struct compare<AbsoluteTolerance<U>, U> : public compare_base<AbsoluteTolerance<U>>
+struct compare<AbsoluteTolerance<U>> : public compare_base<AbsoluteTolerance<U>>
{
using compare_base<AbsoluteTolerance<U>>::compare_base;
@@ -245,12 +245,16 @@ struct compare<AbsoluteTolerance<U>, U> : public compare_base<AbsoluteTolerance<
return true;
}
- return static_cast<U>(std::abs(this->_target - this->_reference)) <= static_cast<U>(this->_tolerance);
+ using comparison_type = typename std::conditional<std::is_integral<U>::value, int64_t, U>::type;
+
+ const comparison_type abs_difference(std::abs(static_cast<comparison_type>(this->_target) - static_cast<comparison_type>(this->_reference)));
+
+ return abs_difference <= static_cast<comparison_type>(this->_tolerance);
}
};
template <typename U>
-struct compare<RelativeTolerance<U>, U> : public compare_base<RelativeTolerance<U>>
+struct compare<RelativeTolerance<U>> : public compare_base<RelativeTolerance<U>>
{
using compare_base<RelativeTolerance<U>>::compare_base;
@@ -325,7 +329,7 @@ void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const V
const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
- if(!compare<U, typename U::value_type>(target_value, reference_value, tolerance_value))
+ if(!compare<U>(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<typename U::value_type>(tolerance)));
- ARM_COMPUTE_EXPECT((compare<U, typename U::value_type>(target, reference, tolerance)), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT((compare<U>(target, reference, tolerance)), framework::LogLevel::ERRORS);
}
} // namespace validation
} // namespace test