commit | 91690983ff3fa956619a4af2c820f1bb78aba1d6 | [log] [tgz] |
---|---|---|
author | lezcano <lezcano-93@hotmail.com> | Mon Jan 29 17:23:43 2024 +0000 |
committer | PyTorch MergeBot <pytorchmergebot@users.noreply.github.com> | Tue Jan 30 13:02:18 2024 +0000 |
tree | 5433eb037faffa86fa90d1a93bc77d645fad8f6c | |
parent | 64efec9953cebfeef2185eaec626ce0db37c6aa6 [diff] |
[easy] Faster empty LIST_LENGTH guard (#118542) Pull Request resolved: https://github.com/pytorch/pytorch/pull/118542 Approved by: https://github.com/peterbell10, https://github.com/jansel
diff --git a/torch/_dynamo/guards.py b/torch/_dynamo/guards.py index 4415d6e..140fc3a 100644 --- a/torch/_dynamo/guards.py +++ b/torch/_dynamo/guards.py
@@ -500,7 +500,10 @@ code = list() code.append(f"___check_type_id({ref}, {self.id_ref(t)})") - code.append(f"len({ref}) == {len(value)}") + if len(value) == 0: + code.append(f"not {ref}") + else: + code.append(f"len({ref}) == {len(value)}") self._produce_guard_code(guard, code)