mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
dynamo tracing perf: no import on hot path: 47.62 -> 47.26 (#143065)
See #143056 for overall docs. This PR: Removed another `import` in the body of the hot path. Pull Request resolved: https://github.com/pytorch/pytorch/pull/143065 Approved by: https://github.com/jansel
This commit is contained in:
committed by
PyTorch MergeBot
parent
792e6184c5
commit
7d4e7fbfc1
@ -27,6 +27,7 @@ from typing import (
|
||||
Union,
|
||||
)
|
||||
|
||||
import torch
|
||||
from torch.utils import _pytree as pytree
|
||||
from torch.utils._backport_slots import dataclass_slots
|
||||
from torch.utils._traceback import CapturedTraceback, format_frame
|
||||
@ -39,11 +40,6 @@ log = logging.getLogger(__name__)
|
||||
if TYPE_CHECKING:
|
||||
import sympy
|
||||
|
||||
# Import the following modules during type checking to enable code intelligence features,
|
||||
# such as auto-completion in tools like pylance, even when these modules are not explicitly
|
||||
# imported in user code.
|
||||
import torch
|
||||
|
||||
|
||||
"""
|
||||
torch._guards is the definitional source of truth for general purpose guard structures.
|
||||
@ -235,11 +231,10 @@ class Guard:
|
||||
def sort_key(self):
|
||||
# Put the duplicate input guards at the end. The duplicate guards have
|
||||
# two sources while guard.name only considers one source.
|
||||
from torch._dynamo.guards import GuardBuilder
|
||||
|
||||
is_duplicate_input = (
|
||||
isinstance(self.create_fn, functools.partial)
|
||||
and self.create_fn.func is GuardBuilder.DUPLICATE_INPUT
|
||||
and self.create_fn.func is torch._dynamo.guards.GuardBuilder.DUPLICATE_INPUT
|
||||
)
|
||||
return (
|
||||
is_duplicate_input,
|
||||
|
||||
Reference in New Issue
Block a user