| 1 | Prevent implicit conversion of float to double to avoid precision
|
| 2 | error on i686.
|
| 3 |
|
| 4 | https://github.com/Maratyszcza/FP16/issues/20
|
| 5 |
|
| 6 | Taken from Debian:
|
| 7 |
|
| 8 | https://salsa.debian.org/deeplearning-team/fp16/-/blob/master/debian/patches/ftbfs-i386.patch
|
| 9 |
|
| 10 | Index: fp16/include/fp16/fp16.h
|
| 11 | ===================================================================
|
| 12 | |
| 13 | |
| 14 | @@ -228,7 +228,8 @@ static inline uint16_t fp16_ieee_from_fp
|
| 15 | const float scale_to_inf = fp32_from_bits(UINT32_C(0x77800000));
|
| 16 | const float scale_to_zero = fp32_from_bits(UINT32_C(0x08800000));
|
| 17 | #endif
|
| 18 | - float base = (fabsf(f) * scale_to_inf) * scale_to_zero;
|
| 19 | + const volatile float base_inf = fabsf(f) * scale_to_inf;
|
| 20 | + float base = base_inf * scale_to_zero;
|
| 21 |
|
| 22 | const uint32_t w = fp32_to_bits(f);
|
| 23 | const uint32_t shl1_w = w + w;
|