Expand description
Mixed-precision (AMP) building blocks: IEEE-754 binary16 conversion and dynamic loss scaling.
This module is pure Rust and has no device dependency, so it is usable from
CPU code paths and from the GPU optimizer path alike. The conversions are
full IEEE-754 binary16 implementations — subnormals, infinities, NaN
payload preservation and round-half-to-even are all handled — not the
truncating placeholder they replace.
Structs§
- Dynamic
Loss Scaler - Dynamic loss scaler with the standard grow/back-off schedule.
- Mixed
Precision Config - Configuration for dynamic loss scaling.
- Overflow
Stats - Aggregate overflow statistics over the scaler’s rolling window.
Constants§
- F16_MAX
- Largest finite magnitude representable in
binary16.
Functions§
- f16_
bits_ slice_ to_ f32 - Convert a slice of
binary16bit patterns back tof32. - f16_
bits_ to_ f32 - Convert IEEE-754
binary16bits tof32. Exact for every input. - f32_
slice_ to_ f16_ bits - Convert a slice of
f32tobinary16bit patterns. - f32_
to_ f16_ bits - Convert an
f32to IEEE-754binary16bits with round-half-to-even. - saturate_
to_ f16_ range - Clamp to the
binary16finite range before conversion.