[Mlir-commits] [mlir] [mlir][arith][transforms] Adds Truncf f32 to f4e2m1 (PR #144157)

Krzysztof Drewniak llvmlistbot at llvm.org
Tue Jun 17 09:09:30 PDT 2025


================
@@ -322,6 +334,74 @@ struct BFloat16TruncFOpConverter : public OpRewritePattern<arith::TruncFOp> {
   }
 };
 
+struct F4E2M1ExtFOpConverter : public OpRewritePattern<arith::ExtFOp> {
----------------
krzysz00 wrote:

Like, out in rocMLIR we have https://github.com/ROCm/rocMLIR/blob/develop/mlir/lib/Conversion/EmulateFp8ExtTrunc/EmulateFp8ExtTrunc.cpp#L201 - which just creates a lookup table for fp8.

I can't remember why there wasn't an attempt to upstream that ... probably because the reference implementation for truncf is ugly.

And because I wasn't sure people would be happy about getting `@__mlir_arith_f4E2M1FN_to_f32_lookup_table` showing up in their code out of nowhere

https://github.com/llvm/llvm-project/pull/144157


More information about the Mlir-commits mailing list