Module prim_f16

Source
🔬This is a nightly-only experimental API. (f16 #116909)
Expand description

A 16-bit floating-point type (specifically, the “binary16” type defined in IEEE 754-2008).

This type is very similar to f32 but has decreased precision because it uses half as many bits. Please see the documentation for f32 or Wikipedia on half-precision values for more information.

Note that most common platforms will not support f16 in hardware without enabling extra target features, with the notable exception of Apple Silicon (also known as M1, M2, etc.) processors. Hardware support on x86/x86-64 requires the avx512fp16 or avx10.1 features, while RISC-V requires Zfh, and Arm/AArch64 requires FEAT_FP16. Usually the fallback implementation will be to use f32 hardware if it exists, and convert between f16 and f32 when performing math.

See also the std::f16::consts module.