Support unary not on lists (#102210)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/102210
Approved by: https://github.com/anijain2305
This commit is contained in:
Michael Lazos 2023-05-25 02:45:36 +00:00 committed by PyTorch MergeBot
parent a0e44284de
commit 2434a205de
2 changed files with 8 additions and 0 deletions

View File

@ -807,6 +807,10 @@ class FunctionTests(torch._dynamo.test_case.TestCase):
tmp.append(a + b)
return tmp
@make_test
def test_not_list(a):
return not [a + 1]
@make_test
def test_islice_chain(a, b):
tmp1 = [a + 1, a + 2]

View File

@ -1314,6 +1314,10 @@ class BuiltinVariable(VariableTracker):
),
sym_num=None,
)
if isinstance(a, ListVariable):
return ConstantVariable(len(a.items) == 0).add_options(self, a)
return None
call_eq = _comparison