diff options
author | Antonio Sanchez <cantonios@google.com> | 2021-01-20 19:00:09 -0800 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2021-01-21 19:32:28 +0000 |
commit | b2126fd6b5e232d072ceadb1abb6695ae3352e2e (patch) | |
tree | b86944d559717eeee3589efa21dcfd30cbdd2f3d /Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | |
parent | 25d8498f8ba29c8dc055dd56113facbdbe154345 (diff) |
Fix pfrexp/pldexp for half.
The recent addition of vectorized pow (!330) relies on `pfrexp` and
`pldexp`. This was missing for `Eigen::half` and `Eigen::bfloat16`.
Adding tests for these packet ops also exposed an issue with handling
negative values in `pfrexp`, returning an incorrect exponent.
Added the missing implementations, corrected the exponent in `pfrexp1`,
and added `packetmath` tests.
Diffstat (limited to 'Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h')
-rw-r--r-- | Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 9a1feb0d9..69c92a8cc 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -31,7 +31,7 @@ pfrexp_float(const Packet& a, Packet& exponent) { const Packet cst_126f = pset1<Packet>(126.0f); const Packet cst_half = pset1<Packet>(0.5f); const Packet cst_inv_mant_mask = pset1frombits<Packet>(~0x7f800000u); - exponent = psub(pcast<PacketI,Packet>(plogical_shift_right<23>(preinterpret<PacketI>(a))), cst_126f); + exponent = psub(pcast<PacketI,Packet>(plogical_shift_right<23>(preinterpret<PacketI>(pabs<Packet>(a)))), cst_126f); return por(pand(a, cst_inv_mant_mask), cst_half); } @@ -41,7 +41,7 @@ pfrexp_double(const Packet& a, Packet& exponent) { const Packet cst_1022d = pset1<Packet>(1022.0); const Packet cst_half = pset1<Packet>(0.5); const Packet cst_inv_mant_mask = pset1frombits<Packet>(static_cast<uint64_t>(~0x7ff0000000000000ull)); - exponent = psub(pcast<PacketI,Packet>(plogical_shift_right<52>(preinterpret<PacketI>(a))), cst_1022d); + exponent = psub(pcast<PacketI,Packet>(plogical_shift_right<52>(preinterpret<PacketI>(pabs<Packet>(a)))), cst_1022d); return por(pand(a, cst_inv_mant_mask), cst_half); } |