widen.bend checks
raw source on the hub · import bend-safetensors-reader@0.1.0.0/widen.bend as Widen
16-bit floats to F32, on bits: a BF16 or F16 value in the low 16 bits of a U32 to the bits of the same value as F32 (exact: F32 holds every BF16 and F16 value). Pure, no IO.
1 import
import Base
Definitions
def bf16 source · line 6 · raw
@+h:U32 -> U32
BF16 is the top half of an F32
def f16_sub source · line 10 · raw
@+sign:U32 -> @+m:U32 -> @+p:Nat -> U32
an F16 subnormal (exponent 0, mantissa m > 0) is m * 2^-24: normalize on its highest bit p
def f16_lo source · line 13 · raw
@zero:Bool -> @+sign:U32 -> @+m:U32 -> U32
def f16_go source · line 20 · raw
@+sign:U32 -> @+e:U32 -> @+m:U32 -> U32
def f16 source · line 25 · raw
@+h:U32 -> U32