Skip to main content

Module mixed_precision

Module mixed_precision 

Source
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§

DynamicLossScaler
Dynamic loss scaler with the standard grow/back-off schedule.
MixedPrecisionConfig
Configuration for dynamic loss scaling.
OverflowStats
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 binary16 bit patterns back to f32.
f16_bits_to_f32
Convert IEEE-754 binary16 bits to f32. Exact for every input.
f32_slice_to_f16_bits
Convert a slice of f32 to binary16 bit patterns.
f32_to_f16_bits
Convert an f32 to IEEE-754 binary16 bits with round-half-to-even.
saturate_to_f16_range
Clamp to the binary16 finite range before conversion.