[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
Tue Nov 19 08:36:33 PST 2024


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

>From f1a99a4b63a067def75536fa75de1e5da2767dda 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] [mlir][python][quant] Fixed functions without return value
 and incorrect type hins.

---
 mlir/lib/Bindings/Python/DialectQuant.cpp            | 2 ++
 mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi | 2 +-
 mlir/test/python/dialects/quant.py                   | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)

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 "
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: ...
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