[Mlir-commits] [mlir] [mlir][arith][transforms] Adds Truncf f32 to f4e2m1 (PR #144157)
Jakub Kuderski
llvmlistbot at llvm.org
Tue Jun 17 12:55:29 PDT 2025
================
@@ -3,18 +3,29 @@
// RUN: mlir-opt %s --convert-vector-to-llvm \
// RUN: --convert-func-to-llvm \
// RUN: --arith-expand="include-f4e2m1=true" \
-// RUN: --convert-arith-to-llvm | \
-// RUN: mlir-runner -e entry --entry-point-result=void \
-// RUN: --shared-libs=%mlir_c_runner_utils | \
-// RUN: FileCheck %s --match-full-lines
+// RUN: --convert-arith-to-llvm -reconcile-unrealized-casts | \
+// RUN: mlir-runner -e entry --entry-point-result=void \
+// RUN: --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
-func.func @check_extf(%in : f32) -> () {
- %trunc = arith.truncf %in : f32 to f4E2M1FN
- %res = arith.extf %trunc : f4E2M1FN to f32
+func.func @check_extf(%in : f4E2M1FN) -> () {
+ %res = arith.extf %in : f4E2M1FN to f32
vector.print %res : f32
return
}
+// Note: x is sign bit
+// Format of F4E2M1:
+// [sign bit]{1} [exponent bits]{2} [mantissa bit]{1}
+// | Binary | Value ( + / - )
+// | x000 | 0.0
+// | x001 | 0.5
+// | x010 | 1.0
+// | x011 | 1.5
+// | x100 | 2.0
+// | x101 | 3.0
+// | x110 | 4.0
+// | x111 | 6.0
----------------
kuhar wrote:
Can you point to the c++ file with the same table or some external website?
https://github.com/llvm/llvm-project/pull/144157
More information about the Mlir-commits
mailing list