mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-06 14:14:46 +08:00
Make sure we take the little-endian path if __BYTE_ORDER__ is not defined.
This commit is contained in:
parent
0e1a33a461
commit
bed7fbe854
@ -319,7 +319,7 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __bfloat16_raw truncate_to_bfloat16(const
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(&v);
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(&v);
|
||||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
output.value = p[0];
|
output.value = p[0];
|
||||||
#else
|
#else
|
||||||
output.value = p[1];
|
output.value = p[1];
|
||||||
@ -532,7 +532,7 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC __bfloat16_raw float_to_bfloat16_rtne<true
|
|||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float bfloat16_to_float(__bfloat16_raw h) {
|
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC float bfloat16_to_float(__bfloat16_raw h) {
|
||||||
float result = 0;
|
float result = 0;
|
||||||
unsigned short* q = reinterpret_cast<unsigned short*>(&result);
|
unsigned short* q = reinterpret_cast<unsigned short*>(&result);
|
||||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
q[0] = h.value;
|
q[0] = h.value;
|
||||||
#else
|
#else
|
||||||
q[1] = h.value;
|
q[1] = h.value;
|
||||||
|
Loading…
Reference in New Issue
Block a user