IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo function

e8m0_to_bf16_broadcast

def e8m0_to_bf16_broadcast(scale_byte: UInt8) -> UInt32

Convert an e8m0 scale byte to a bf16 value broadcast into both halves of a uint32.

e8m0 format: value = 2^(byte - 127). The bf16 representation is obtained by left-shifting the 8-bit exponent by 7 to place it in the bf16 exponent field (bits 7-14), with sign=0 and mantissa=0. Broadcasting into both halves of a uint32 prepares the value for use with the packed bf16x2 multiply instruction.

Args:

  • scale_byte (UInt8): E8M0 exponent byte encoding the scale as 2^(byte - 127).

Returns:

UInt32

Was this page helpful?