-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dynamo] torch._dynamo.exc.Unsupported: comparison SymNodeVariable() <built-in function is_> ListVariable() #109504
Comments
This is my first issue. Do you mind providing more detail on how I can recreate the bug? |
|
Currently when the 'is' operator is used with a SymNodeVariable, an unimplemented exception is throw because the op isn't currently part of supported_tensor_comparison_ops (line 1442, dynamo/variables/built_in.py). There is an existing if statement to handle 'is' operator called on different types (lines 1458-1461) but the fact that its lower down in the function causes the unimplemented exception to get thrown first. I think moving the catch for 'is' op on different types to the top of the function should fix this issue without any second-order effects. Can you confirm this makes sense? My first Pytorch issue so want to make sure. |
Give it a try |
How about this test case? import torch
@torch.compile(backend='eager', fullgraph=True, dynamic=True)
def f(x, xs):
if x.size(0) is xs:
return x + 1
else:
return x * 2
f(torch.randn(2), 2) We also want to handle the case where it is indeed self-referential etc. For that we need something closer to #111550 |
@vdesai2014 @jon-chuang is this still an open issue? is anyone working on this? |
Feel free to grab this |
still repros as of 0a1b3be |
If this is still free to work on, I would propose adding the following logic to if op in [operator.is_, operator.is_not]:
is_result = (
isinstance(left, SymNodeVariable)
and isinstance(right, SymNodeVariable)
and left.sym_num is right.sym_num
)
if op is operator.is_:
return ConstantVariable.create(is_result)
else:
return ConstantVariable.create(not is_result) This is similar to what is done in |
馃悰 Describe the bug
Self explanatory.
Occurred when implementing self-referentiality check in torch.tensor ref
Versions
main
cc @msaroufim @wconstab @bdhirsh @anijain2305 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng
The text was updated successfully, but these errors were encountered: