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).

Python function

float32_to_bfloat16_as_uint16

float32_to_bfloat16_as_uint16()​

max.driver.float32_to_bfloat16_as_uint16(arr)

source

Converts a float32 array to bfloat16 bit patterns stored as uint16.

Rounds to nearest, ties to even, the same as a compiled float32 to bfloat16 cast. A NaN input becomes the canonical quiet NaN with the input’s sign.

Parameters:

arr (ndarray[tuple[Any, ...], dtype[float32]]) – A float32 array.

Returns:

A uint16 array of bfloat16 bit patterns with the same shape as arr.

Return type:

ndarray[tuple[Any, …], dtype[uint16]]