IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

e4m3_magnitude_lut

def e4m3_magnitude_lut(scale: Float32) -> SIMD[.uint32, 2]

e4m3(m * scale) for the e2m1 magnitudes {0, .5, 1, 1.5, 2, 3, 4, 6}.

Byte i is the entry for magnitude code i, laid out as the two words byte_permute indexes. m * scale is exact in f32 and is rounded once to e4m3 (nearest even, which is sign-symmetric), so e4m3(-x) == e4m3(x) | 0x80. The product needs up to 6 significant bits, so it is not always exact in e4m3; a scale from a real quantizer keeps 6 * scale inside the e4m3 range.

Returns:

SIMD[.uint32, 2]

Was this page helpful?