Skip to content

Commit 4de93d1

Browse files
Skylion007pytorchmergebot
authored andcommitted
[BE][Ez]: Fix bad TypeIs conversion (pytorch#138990)
Fixes on TypeIs / TypeGuard conversion error. Follow up to pytorch#133814 Thanks for @ezyang for reminding me to double check the side conditions here. Pull Request resolved: pytorch#138990 Approved by: https://github.com/malfet
1 parent 705f5b3 commit 4de93d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torch/_subclasses/fake_tensor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
TypeVar,
3333
Union,
3434
)
35-
from typing_extensions import Self, TypeIs
35+
from typing_extensions import Self, TypeGuard, TypeIs
3636
from weakref import ReferenceType
3737

3838
import torch
@@ -1214,7 +1214,7 @@ def reset_nt_tensor_id_counter(self) -> None:
12141214
# In this case, it's insufficient to test only one FakeTensor: you need
12151215
# to distinguish between our fake tensor and other fake tensors. That's
12161216
# what this function does.
1217-
def is_our_fake(self, t: object) -> TypeIs[FakeTensor]:
1217+
def is_our_fake(self, t: object) -> TypeGuard[FakeTensor]:
12181218
return isinstance(t, FakeTensor) and t.fake_mode is self
12191219

12201220
# If we should avoid device init. This changes the behavior of various APIs:

0 commit comments

Comments
 (0)