| 68 | } |
| 69 | |
| 70 | float Fp8E5M2::GetFloat() const |
| 71 | { |
| 72 | FloatCast fp32 = {.f = 0}; |
| 73 | // Set the sign bit. |
| 74 | fp32.components.sign = data.components.sign; |
| 75 | |
| 76 | // Standard NaN/Inf case. We just use the fp8 mantissa as there's |
| 77 | // no strong requirements for mantissa in the NaN case. |
| 78 | if (data.components.exponent == (0x1 << fp8ExponentBits) - 1) { |
| 79 | fp32.components.exponent = 0xFF; |
| 80 | fp32.components.mantissa = data.components.mantissa; |
| 81 | return fp32.f; |
| 82 | } |
| 83 | HandleFp8ToFp32ExponentMantissa<Fp8E5M2, Fp8E5M2::Cast>(data, fp32); |
| 84 | HandleFp8ToFp32Denormalize(data, fp32); |
| 85 | return fp32.f; |
| 86 | } |
| 87 | |
| 88 | float Fp8E4M3FN::GetFloat() const |
| 89 | { |