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
cast_uint_to_fp4e2m1
def cast_uint_to_fp4e2m1[in_dtype: DType, in_width: SIMDLength, //, *, out_dtype: DType, out_width: Int](x: SIMD[in_dtype, in_width]) -> SIMD[out_dtype, out_width]
Unpacks FP4 E2M1 nibbles packed inside unsigned integers to floating-point values.
Each input integer (uint8, uint16, or uint32) holds multiple packed 4-bit E2M1 values.
The function extracts each nibble, looks up its float32 value in E2M1_TO_FLOAT32,
casts to out_dtype, and assembles the result vector.
Parameters:
- βin_dtype (
DType): Unsigned integer type holding packed FP4 nibbles (uint8, uint16, or uint32). - βin_width (
SIMDLength): Number of input integer elements. - βout_dtype (
DType): Output floating-point element type. - βout_width (
Int): Total output elements; must equalin_width * (bit_width(in_dtype) // 4).
Args:
- βx (
SIMD[in_dtype, in_width]): Packed FP4 E2M1 input vector.
Returns:
SIMD[out_dtype, out_width]: Decoded floating-point vector of length out_width.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!