[Mlir-commits] [mlir] [MLIR] fix _f64ElementsAttr in ir.py (PR #91176)

Yuanqiang Liu llvmlistbot at llvm.org
Mon May 6 02:52:41 PDT 2024


https://github.com/qingyunqu updated https://github.com/llvm/llvm-project/pull/91176

>From 2cf59bf728793e83844db46c3b034f83d110267d Mon Sep 17 00:00:00 2001
From: Yuanqiang Liu <liuyuanqiang.yqliu at bytedance.com>
Date: Mon, 6 May 2024 17:13:23 +0800
Subject: [PATCH 1/2] [MLIR] fix _f64ElementsAttr in ir.py

---
 mlir/python/mlir/ir.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/python/mlir/ir.py b/mlir/python/mlir/ir.py
index eb7f035fec7c1f..80c965b2d0eb2c 100644
--- a/mlir/python/mlir/ir.py
+++ b/mlir/python/mlir/ir.py
@@ -274,7 +274,7 @@ def _memref_type_attr(x, context):
     @register_attribute_builder("F64ElementsAttr")
     def _f64ElementsAttr(x, context):
         return DenseElementsAttr.get(
-            np.array(x, dtype=np.int64),
+            np.array(x, dtype=np.float64),
             type=F64Type.get(context=context),
             context=context,
         )

>From 4ea0e32c301985967b014e6e6c7c8c9d6cf1bb4b Mon Sep 17 00:00:00 2001
From: Yuanqiang Liu <liuyuanqiang.yqliu at bytedance.com>
Date: Mon, 6 May 2024 17:52:25 +0800
Subject: [PATCH 2/2] fix test

---
 mlir/test/python/dialects/python_test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/test/python/dialects/python_test.py b/mlir/test/python/dialects/python_test.py
index 88761c9d08fe07..70927b22d4749c 100644
--- a/mlir/test/python/dialects/python_test.py
+++ b/mlir/test/python/dialects/python_test.py
@@ -167,7 +167,7 @@ def attrBuilder():
             x_f32arr=[2.0, 3.0],
             x_f64=4.25,  # CHECK-DAG: x_f64 = 4.250000e+00 : f64
             x_f64arr=[4.0, 8.0],  # CHECK-DAG: x_f64arr = [4.000000e+00, 8.000000e+00]
-            # CHECK-DAG: x_f64elems = dense<[3.952530e-323, 7.905050e-323]> : tensor<2xf64>
+            # CHECK-DAG: x_f64elems = dense<[8.000000e+00, 1.600000e+01]> : tensor<2xf64>
             x_f64elems=[8.0, 16.0],
             # CHECK-DAG: x_flatsymrefarr = [@symbol1, @symbol2]
             x_flatsymrefarr=["symbol1", "symbol2"],



More information about the Mlir-commits mailing list