[Mlir-commits] [mlir] ad5be31 - [mlir][Python] fix NV examples after #172892 (#174481)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jan 5 13:47:39 PST 2026


Author: Maksim Levental
Date: 2026-01-05T21:47:35Z
New Revision: ad5be31c30525b70eb0ccea6d0309856417dc7e6

URL: https://github.com/llvm/llvm-project/commit/ad5be31c30525b70eb0ccea6d0309856417dc7e6
DIFF: https://github.com/llvm/llvm-project/commit/ad5be31c30525b70eb0ccea6d0309856417dc7e6.diff

LOG: [mlir][Python] fix NV examples after #172892 (#174481)

Added: 
    

Modified: 
    mlir/docs/Bindings/Python.md
    mlir/test/Examples/NVGPU/tools/nvdsl.py
    mlir/test/Integration/GPU/CUDA/sm90/python/tools/matmulBuilder.py

Removed: 
    


################################################################################
diff  --git a/mlir/docs/Bindings/Python.md b/mlir/docs/Bindings/Python.md
index 4278774933a4a..24284803125c7 100644
--- a/mlir/docs/Bindings/Python.md
+++ b/mlir/docs/Bindings/Python.md
@@ -544,9 +544,9 @@ attribute = <...>
 type = <...>
 
 # No need to handle errors here.
-if ConcreteAttr.isinstance(attribute):
+if isinstance(attribute, ConcreteAttr):
   concrete_attr = ConcreteAttr(attribute)
-if ConcreteType.isinstance(type):
+if isinstance(type, ConcreteType):
   concrete_type = ConcreteType(type)
 ```
 

diff  --git a/mlir/test/Examples/NVGPU/tools/nvdsl.py b/mlir/test/Examples/NVGPU/tools/nvdsl.py
index 856107293470d..16dc12ca1625d 100644
--- a/mlir/test/Examples/NVGPU/tools/nvdsl.py
+++ b/mlir/test/Examples/NVGPU/tools/nvdsl.py
@@ -14,22 +14,20 @@
 
 def const(value: int, ty=None):
     ty = T.index() if ty is None else ty
-    if isinstance(value, ir.Value) and (
-        value.type.isinstance(value.type) or T.bool().isinstance(value.type)
-    ):
+    if isinstance(value, ir.Value):
         return value
     return arith.constant(ty, value)
 
 
 def get_type_size(ty):
-    if ir.MemRefType.isinstance(ty):
+    if isinstance(ty, ir.MemRefType):
         size = get_type_size(ty.element_type)
         for sz in ty.shape:
             size *= sz
         return size
-    if ir.FloatType.isinstance(ty):
+    if isinstance(ty, ir.FloatType):
         return ir.FloatType(ty).width // 8
-    if ir.IntegerType.isinstance(ty):
+    if isinstance(ty, ir.IntegerType):
         return ir.IntegerType(ty).width // 8
     raise NotImplementedError(ty)
 
@@ -341,15 +339,17 @@ def saveIR(module):
             def _binary_op(lhs, rhs, op: str, predAtt="") -> "ArithValue":
                 """Generate MLIR's Arith dialects binary operations."""
                 rhs = const(rhs)
-                if arith._is_float_type(lhs.type) and arith._is_float_type(rhs.type):
+                if isinstance(lhs.type, ir.FloatType) and isinstance(
+                    rhs.type, ir.FloatType
+                ):
                     op += "F"
                     if op.startswith("Cmp"):
                         predicateAttr = getattr(arith, f"CmpFPredicate").__dict__[
                             predAtt
                         ]
-                elif arith._is_integer_like_type(
-                    lhs.type
-                ) and arith._is_integer_like_type(lhs.type):
+                elif isinstance(
+                    lhs.type, (ir.IntegerType, ir.IndexType)
+                ) and isinstance(lhs.type, (ir.IntegerType, ir.IndexType)):
                     if op == "Div" or op == "Rem":
                         op += "U"
                     op += "I"

diff  --git a/mlir/test/Integration/GPU/CUDA/sm90/python/tools/matmulBuilder.py b/mlir/test/Integration/GPU/CUDA/sm90/python/tools/matmulBuilder.py
index 5394d4a327255..e755d6affa469 100644
--- a/mlir/test/Integration/GPU/CUDA/sm90/python/tools/matmulBuilder.py
+++ b/mlir/test/Integration/GPU/CUDA/sm90/python/tools/matmulBuilder.py
@@ -76,9 +76,9 @@ def debug_print(fmt, *args, predicate=None, threadNumber=-1, forcePrint=False):
     type_formats = []
     for arg in args:
         ty_format = None
-        if ir.IndexType.isinstance(arg.type):
+        if isinstance(arg.type, ir.IndexType):
             ty_format = "%llu"
-        if ir.IntegerType.isinstance(arg.type):
+        if isinstance(arg.type, ir.IntegerType):
             width = ir.IntegerType(arg.type).width
             if width == 64:
                 ty_format = "%llu"
@@ -86,7 +86,7 @@ def debug_print(fmt, *args, predicate=None, threadNumber=-1, forcePrint=False):
                 ty_format = "%d"
             elif width == 1:
                 ty_format = "%i"
-        if ir.F32Type.isinstance(arg.type):
+        if isinstance(arg.type, ir.F32Type):
             ty_format = "%f"
         if ty_format is None:
             raise NotImplementedError(arg.type)
@@ -102,9 +102,9 @@ def debug_print(fmt, *args, predicate=None, threadNumber=-1, forcePrint=False):
 
 
 def get_type_size(ty):
-    if ir.FloatType.isinstance(ty):
+    if isinstance(ty, ir.FloatType):
         return ir.FloatType(ty).width // 8
-    if ir.IntegerType.isinstance(ty):
+    if isinstance(ty, ir.IntegerType):
         return ir.IntegerType(ty).width // 8
     raise NotImplementedError(ty)
 


        


More information about the Mlir-commits mailing list