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_float_to_fp4e2m1_amd
def cast_float_to_fp4e2m1_amd[dtype: DType, width: SIMDLength, //](input: SIMD[dtype, width], scale: Float32) -> UInt32
Converts up to eight floating-point values to packed FP4 E2M1 using AMD CDNA4 intrinsics.
Applies the provided scale factor before quantization using the
llvm.amdgcn.cvt.scalef32.pk.fp4.* intrinsics, packing pairs of values per call.
Constraints:
Requires AMD CDNA4 or newer (MI355X and above).
Parameters:
- βdtype (
DType): Input element type (bfloat16 or float32). - βwidth (
SIMDLength): Number of input elements; must be even and at most 8.
Args:
- βinput (
SIMD[dtype, width]): Input floating-point vector to convert. - βscale (
Float32): Scale factor applied before FP4 quantization.
Returns:
UInt32: A UInt32 with the converted FP4 E2M1 nibbles packed in order.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!