fp16 -> fp32, written out rather than using `_cvtsh_ss`, because the F16C intrinsic's behaviour on subnormals is the one place the two can differ and the scales in this artifact are small.
| 26 | /// fp16 -> fp32, written out rather than using `_cvtsh_ss`, because the F16C intrinsic's behaviour on |
| 27 | /// subnormals is the one place the two can differ and the scales in this artifact are small. |
| 28 | inline float h2f(const uint8_t* p) { |
| 29 | uint16_t h; |
| 30 | std::memcpy(&h, p, 2); |
| 31 | const uint32_t sign = (uint32_t) (h >> 15) & 1u; |
| 32 | uint32_t exp = (h >> 10) & 0x1Fu, man = h & 0x3FFu, f; |
| 33 | if (exp == 0) { |
| 34 | if (man == 0) { |
| 35 | f = sign << 31; |
| 36 | } else { |
| 37 | exp = 127 - 15 + 1; |
| 38 | while (!(man & 0x400u)) { man <<= 1; --exp; } |
| 39 | man &= 0x3FFu; |
| 40 | f = (sign << 31) | (exp << 23) | (man << 13); |
| 41 | } |
| 42 | } else if (exp == 31) { |
| 43 | f = (sign << 31) | 0x7F800000u | (man << 13); |
| 44 | } else { |
| 45 | f = (sign << 31) | ((exp - 15 + 127) << 23) | (man << 13); |
| 46 | } |
| 47 | float out; |
| 48 | std::memcpy(&out, &f, 4); |
| 49 | return out; |
| 50 | } |
| 51 | |
| 52 | // quantize_oracle_q8_0 (the oracle path's activation quantiser) is in expert_oracle_parts.hpp. |
| 53 |
no test coverage detected