-
Notifications
You must be signed in to change notification settings - Fork 14.4k
assert with more information to help debug #132194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert with more information to help debug #132194
Conversation
@llvm/pr-subscribers-mlir Author: drazi (fengxie) ChangesThis PR output debug message to assertion to help debug user python code. Will print out more friendly information
Full diff: https://github.com/llvm/llvm-project/pull/132194.diff 1 Files Affected:
diff --git a/mlir/python/mlir/dialects/_ods_common.py b/mlir/python/mlir/dialects/_ods_common.py
index 1e7e8244ed442..11c363abe2ecd 100644
--- a/mlir/python/mlir/dialects/_ods_common.py
+++ b/mlir/python/mlir/dialects/_ods_common.py
@@ -104,7 +104,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
@@ -137,11 +137,10 @@ def get_op_result_or_op_results(
return (
list(get_op_results_or_values(op))
if len(op.results) > 1
- else get_op_result_or_value(op)
- if len(op.results) > 0
- else op
+ else get_op_result_or_value(op) if len(op.results) > 0 else op
)
+
ResultValueTypeTuple = _cext.ir.Operation, _cext.ir.OpView, _cext.ir.Value
ResultValueT = _Union[ResultValueTypeTuple]
VariadicResultValueT = _Union[ResultValueT, _Sequence[ResultValueT]]
|
Do we need more input to approve this PR? It's a small change. |
It's approved - you're saying you would like to merge it? |
Yes, I would like to merge it. |
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'> ```
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'> ```
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'> ```
This PR output debug message to assertion to help debug user python code. Will print out more friendly information