[Mlir-commits] [mlir] [mlir][Bindings] Fix missing return value of functions and incorrect type hint in pyi. (PR #116731)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Nov 18 19:58:02 PST 2024


https://github.com/annuasd updated https://github.com/llvm/llvm-project/pull/116731

>From 59ecc466bfdcf2d5a5dd4c862e752d1730e546ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=89=9B=E5=A5=95=E5=8D=9A?=
 <niuyibo at niuyibodeMacBook-Pro.local>
Date: Tue, 19 Nov 2024 09:56:06 +0800
Subject: [PATCH 1/3] [mlir][Bindings]Fixed the issue of the function not
 returning a value in bindings

---
 mlir/lib/Bindings/Python/DialectQuant.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mlir/lib/Bindings/Python/DialectQuant.cpp b/mlir/lib/Bindings/Python/DialectQuant.cpp
index af9cdc7bdd2d89..9a871f2c122d12 100644
--- a/mlir/lib/Bindings/Python/DialectQuant.cpp
+++ b/mlir/lib/Bindings/Python/DialectQuant.cpp
@@ -250,6 +250,7 @@ static void populateDialectQuantSubmodule(const py::module &m) {
           double scale = mlirUniformQuantizedPerAxisTypeGetScale(type, i);
           scales.push_back(scale);
         }
+        return scales;
       },
       "The scales designate the difference between the real values "
       "corresponding to consecutive quantized values differing by 1. The ith "
@@ -265,6 +266,7 @@ static void populateDialectQuantSubmodule(const py::module &m) {
               mlirUniformQuantizedPerAxisTypeGetZeroPoint(type, i);
           zeroPoints.push_back(zeroPoint);
         }
+        return zeroPoints;
       },
       "the storage values corresponding to the real value 0 in the affine "
       "equation. The ith zero point corresponds to the ith slice in the "

>From c0a7898f48a4d6b30016519bdaff326b3fe4a37d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=89=9B=E5=A5=95=E5=8D=9A?=
 <niuyibo at niuyibodeMacBook-Pro.local>
Date: Tue, 19 Nov 2024 10:01:21 +0800
Subject: [PATCH 2/3] [mlir][Bindings]Fixed the incorrect type hints.

---
 mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi b/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi
index a10bc693ba6001..47168d49c5568b 100644
--- a/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi
+++ b/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi
@@ -101,7 +101,7 @@ class UniformQuantizedPerAxisType(QuantizedType):
   def scales(self) -> list[float]: ...
 
   @property
-  def zero_points(self) -> list[float]: ...
+  def zero_points(self) -> list[int]: ...
 
   @property
   def quantized_dimension(self) -> int: ...

>From f77596fc65fd5fe7b74519478742ce921a85ea8a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=89=9B=E5=A5=95=E5=8D=9A?=
 <niuyibo at niuyibodeMacBook-Pro.local>
Date: Tue, 19 Nov 2024 11:57:45 +0800
Subject: [PATCH 3/3] [mlir][python][quant] update test of
 uniform_per_axis_type

---
 mlir/test/python/dialects/quant.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/test/python/dialects/quant.py b/mlir/test/python/dialects/quant.py
index 0ee3327dec1521..b1d6e85f519b5d 100644
--- a/mlir/test/python/dialects/quant.py
+++ b/mlir/test/python/dialects/quant.py
@@ -108,9 +108,9 @@ def test_uniform_per_axis_type():
             ),
         )
 
-        # CHECK: scales: None
+        # CHECK: scales: [200.0, 0.99872]
         print(f"scales: {per_axis.scales}")
-        # CHECK: zero_points: None
+        # CHECK: zero_points: [0, 120]
         print(f"zero_points: {per_axis.zero_points}")
         # CHECK: quantized dim: 1
         print(f"quantized dim: {per_axis.quantized_dimension}")



More information about the Mlir-commits mailing list