Skip to content

Commit 9a8fcc9

Browse files
fengxiesvkeerthy
authored andcommitted
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'> ```
1 parent f4e9cf1 commit 9a8fcc9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mlir/python/mlir/dialects/_ods_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_op_result_or_value(
105105
elif isinstance(arg, _cext.ir.OpResultList):
106106
return arg[0]
107107
else:
108-
assert isinstance(arg, _cext.ir.Value)
108+
assert isinstance(arg, _cext.ir.Value), f"expects Value, got {type(arg)}"
109109
return arg
110110

111111

@@ -147,6 +147,7 @@ def get_op_result_or_op_results(
147147
else:
148148
return op
149149

150+
150151
ResultValueTypeTuple = _cext.ir.Operation, _cext.ir.OpView, _cext.ir.Value
151152
ResultValueT = _Union[ResultValueTypeTuple]
152153
VariadicResultValueT = _Union[ResultValueT, _Sequence[ResultValueT]]

0 commit comments

Comments
 (0)