Fix for failure in D68425364 (#145304)

Summary: Back out change from #145166 which causes an internal model to fail.

Differential Revision: D68459095

Pull Request resolved: https://github.com/pytorch/pytorch/pull/145304
Approved by: https://github.com/izaitsevfb
This commit is contained in:
Aaron Orenstein
2025-01-22 23:33:02 +00:00
committed by PyTorch MergeBot
parent e6a84be3d3
commit 35c8c31f11
2 changed files with 10 additions and 8 deletions

View File

@ -2768,7 +2768,7 @@ class TestFX(JitTestCase):
return self.other(x)
traced = symbolic_trace(ReturnTypeModule())
self.assertIn("-> list[str]", traced._code)
self.assertIn("-> typing_List[str]", traced._code)
scripted = torch.jit.script(traced)
self.assertIn("-> List[str]", scripted.code)
@ -3567,8 +3567,8 @@ class TestFX(JitTestCase):
traced(x, y)
FileCheck().check("tuple[()]") \
.check("tuple[str,tuple[()]]") \
FileCheck().check("typing_Tuple[()]") \
.check("typing_Tuple[str,typing_Tuple[()]]") \
.run(traced.code)
scripted = torch.jit.script(traced)

View File

@ -9,6 +9,7 @@ import keyword
import math
import os
import re
import typing
import warnings
from collections import defaultdict
from collections.abc import Iterable
@ -33,12 +34,13 @@ if TYPE_CHECKING:
# Mapping of builtins to their `typing` equivalent.
# (PEP585: See D68459095 test plan)
_origin_type_map = {
list: list,
dict: dict,
set: set,
frozenset: frozenset,
tuple: tuple,
list: typing.List,
dict: typing.Dict,
set: typing.Set,
frozenset: typing.FrozenSet,
tuple: typing.Tuple,
}
_legal_ops = dict.fromkeys(