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

normalize

def normalize(value: BFloat16) -> UInt16

Normalizes a bfloat16 value to an unsigned 16-bit integer for radix sort by flipping the sign bit for positive values and fully inverting negative values.

Returns:

UInt16

def normalize(value: Int32) -> UInt32

Normalizes a signed 32-bit integer to unsigned by flipping the most significant bit so negative values sort before positive ones.

Returns:

UInt32

def normalize(value: UInt16) -> UInt16

Returns a uint16 value unchanged since unsigned integers already sort correctly in radix sort.

Returns:

UInt16

def normalize(value: Float32) -> UInt32

Normalizes a float32 value to an unsigned 32-bit integer for radix sort by reinterpreting its bit pattern and flipping bits for negative values.

Returns:

UInt32

def normalize(value: Scalar) -> Scalar[_uint_type_of_width[bit_width_of[value.dtype]()]()]

Normalize the value to the appropriate unsigned integer type. This is needed for radix sort to work correctly.

Returns:

Scalar[_uint_type_of_width[bit_width_of[value.dtype]()]()]