[Mlir-commits] [mlir] 25c5235 - assert with more information to help debug (#132194)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed May 28 21:14:40 PDT 2025


Author: drazi
Date: 2025-05-29T00:14:37-04:00
New Revision: 25c5235f30f22b9a95e440f16d1671970554df75

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

LOG: assert with more information to help debug (#132194)

This PR output debug message to assertion to help debug user python
code. Will print out more friendly information

```
>           assert isinstance(arg, _cext.ir.Value), f"expects Value, got {type(arg)}"                                                          
E           AssertionError: expected Value, got <class 'UserDefinedClass'>       
```

Added: 
    

Modified: 
    mlir/python/mlir/dialects/_ods_common.py

Removed: 
    


################################################################################
diff  --git a/mlir/python/mlir/dialects/_ods_common.py b/mlir/python/mlir/dialects/_ods_common.py
index d3dbdc604ef4c..a5efa057cfb64 100644
--- a/mlir/python/mlir/dialects/_ods_common.py
+++ b/mlir/python/mlir/dialects/_ods_common.py
@@ -105,7 +105,7 @@ def get_op_result_or_value(
     elif isinstance(arg, _cext.ir.OpResultList):
         return arg[0]
     else:
-        assert isinstance(arg, _cext.ir.Value)
+        assert isinstance(arg, _cext.ir.Value), f"expects Value, got {type(arg)}"
         return arg
 
 
@@ -147,6 +147,7 @@ def get_op_result_or_op_results(
     else:
         return op
 
+
 ResultValueTypeTuple = _cext.ir.Operation, _cext.ir.OpView, _cext.ir.Value
 ResultValueT = _Union[ResultValueTypeTuple]
 VariadicResultValueT = _Union[ResultValueT, _Sequence[ResultValueT]]


        


More information about the Mlir-commits mailing list