mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 20:26:03 +08:00
Replace numext::as_uint with numext::bit_cast<numext::uint32_t>
This commit is contained in:
parent
e265f7ed8e
commit
09f015852b
@ -96,9 +96,6 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Tgt bit_cast(const Src& src) {
|
||||
memcpy(&tgt, &src, sizeof(Tgt));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
/** \internal extract the bits of the float \a x */
|
||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC numext::uint32_t as_uint(float x) { return bit_cast<numext::uint32_t>(x); }
|
||||
} // namespace numext
|
||||
|
||||
/** \class NumTraits
|
||||
|
@ -460,14 +460,14 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __bfloat16_raw float_to_bfloat16_rtne<true
|
||||
#if (defined(EIGEN_HAS_CUDA_BF16) && defined(EIGEN_HAS_HIP_BF16))
|
||||
// Nothing to do here
|
||||
#else
|
||||
unsigned int input = numext::as_uint(ff);
|
||||
numext::uint32_t input = numext::bit_cast<numext::uint32_t>(ff);
|
||||
__bfloat16_raw output;
|
||||
|
||||
// Least significant bit of resulting bfloat.
|
||||
unsigned int lsb = (input >> 16) & 1;
|
||||
unsigned int rounding_bias = 0x7fff + lsb;
|
||||
numext::uint32_t lsb = (input >> 16) & 1;
|
||||
numext::uint32_t rounding_bias = 0x7fff + lsb;
|
||||
input += rounding_bias;
|
||||
output.value = static_cast<unsigned short>(input >> 16);
|
||||
output.value = static_cast<numext::uint16_t>(input >> 16);
|
||||
return output;
|
||||
#endif
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ inline float trig_reduce_huge (float xf, int *quadrant)
|
||||
0x10e41000, 0xe4100000
|
||||
};
|
||||
|
||||
uint32_t xi = numext::as_uint(xf);
|
||||
uint32_t xi = numext::bit_cast<uint32_t>(xf);
|
||||
// Below, -118 = -126 + 8.
|
||||
// -126 is to get the exponent,
|
||||
// +8 is to enable alignment of 2/pi's bits on 8 bits.
|
||||
|
Loading…
x
Reference in New Issue
Block a user