[Mlir-commits] [mlir] [mlir][arith][transforms] Adds Truncf f32 to f4e2m1 (PR #144157)
Jakub Kuderski
llvmlistbot at llvm.org
Tue Jun 17 07:44:38 PDT 2025
================
@@ -0,0 +1,58 @@
+// Check various edge cases for truncf/extf ops involving f32 and f4e2m1 types.
+
+// 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
+
+func.func @check_extf(%in : f32) -> () {
+ %trunc = arith.truncf %in : f32 to f4E2M1FN
+ %res = arith.extf %trunc : f4E2M1FN to f32
+ vector.print %res : f32
+ return
+}
+
+func.func @check_truncf(%in : f32) -> () {
+ %trunc = arith.truncf %in : f32 to f4E2M1FN
+ %bitcast = arith.bitcast %trunc : f4E2M1FN to i4
+ %res = arith.extui %bitcast : i4 to i64
----------------
kuhar wrote:
I think this deserves a comment with explanation for how f4 values map to integers
https://github.com/llvm/llvm-project/pull/144157
More information about the Mlir-commits
mailing list