diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-07-03 14:38:50 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | 6410fb2a14427713251f5d97144ac5d4f17c988c (patch) | |
tree | 7f5c4e6f4a197a7510dbd19aeee13d2db7252167 /tests/validation | |
parent | f0dea703ce3e2b465e79298bca95c4952a60f608 (diff) | |
download | ComputeLibrary-6410fb2a14427713251f5d97144ac5d4f17c988c.tar.gz |
COMPMID-417: Revert invsqrt validation implementation.
Change-Id: I7da949aaddef8cbd25b3d05727839b7b82b08eb5
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79530
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/FixedPoint.h | 14 | ||||
-rw-r--r-- | tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp | 4 | ||||
-rw-r--r-- | tests/validation/UNIT/FixedPoint.cpp | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/tests/validation/FixedPoint.h b/tests/validation/FixedPoint.h index dca6e7ed2f..53f532cd8c 100644 --- a/tests/validation/FixedPoint.h +++ b/tests/validation/FixedPoint.h @@ -753,18 +753,22 @@ struct functions shift += std::numeric_limits<T>::is_signed ? 1 : 0; - const auto three_half = fixed_point<T>(1.5f, p); - fixed_point<T> a = shift < 0 ? shift_left(x, -shift) : shift_right(x, shift); - const fixed_point<T> x_half = shift_right(a, 1); + // Use volatile to restrict compiler optimizations on shift as compiler reports maybe-uninitialized error on Android + volatile int8_t *shift_ptr = &shift; + + auto const_three = fixed_point<T>(3, p); + auto a = (*shift_ptr < 0) ? shift_left(x, -(shift)) : shift_right(x, shift); + fixed_point<T> x2 = a; // We need three iterations to find the result for QS8 and five for QS16 constexpr int num_iterations = std::is_same<T, int8_t>::value ? 3 : 5; for(int i = 0; i < num_iterations; ++i) { - a = mul(a, sub(three_half, mul(x_half, mul(a, a)))); + fixed_point<T> three_minus_dx = sub(const_three, mul(a, mul(x2, x2))); + x2 = shift_right(mul(x2, three_minus_dx), 1); } - return (shift < 0) ? shift_left(a, -shift >> 1) : shift_right(a, shift >> 1); + return (shift < 0) ? shift_left(x2, -shift >> 1) : shift_right(x2, shift >> 1); } /** Calculate the hyperbolic tangent of a fixed point number * diff --git a/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp b/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp index 6b674860d8..fc79db08aa 100644 --- a/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp +++ b/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp @@ -102,8 +102,10 @@ BOOST_AUTO_TEST_SUITE(QS16) BOOST_AUTO_TEST_SUITE(Invsqrt) BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 14), shape, fixed_point_position) +BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::xrange(1, 14), fixed_point_position) { + TensorShape shape(8192U); + // Compute function Tensor dst = compute_invsqrt_qs16(shape, fixed_point_position); diff --git a/tests/validation/UNIT/FixedPoint.cpp b/tests/validation/UNIT/FixedPoint.cpp index 9206863ec6..0cac9bda9d 100644 --- a/tests/validation/UNIT/FixedPoint.cpp +++ b/tests/validation/UNIT/FixedPoint.cpp @@ -82,7 +82,7 @@ BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::l // The last input argument specifies the expected number of failures for a // given combination of (function name, number of fractional bits) as defined // by the first two arguments. -BOOST_DATA_TEST_CASE(FixedPointQS8Outputs, (boost::unit_test::data::make(func_names) * boost::unit_test::data::xrange(1, 7)) ^ (boost::unit_test::data::make({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 32, 67 })), +BOOST_DATA_TEST_CASE(FixedPointQS8Outputs, (boost::unit_test::data::make(func_names) * boost::unit_test::data::xrange(1, 7)) ^ (boost::unit_test::data::make({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 33, 96 })), func_name, frac_bits, expected_failures) { const std::string base_file_name = user_config.path.get() + "/dumps/" + func_name + "_Q8." + support::cpp11::to_string(frac_bits); |