已合并
move_type_checking_import #40341
cuiduo创建于 7月7日
move_type_checking_import #40341
已合并
共 2 个文件变更+2-5
| @@ -1,7 +1,6 @@ | |||
| 1 | import torch | 1 | import torch |
| 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests | 2 | from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests |
| 3 | from testutils import TestUtils | 3 | from testutils import TestUtils |
| 4 | -import torch_npu | ||
| 5 | 4 | ||
| 6 | 5 | ||
| 7 | class TestAdd(TestUtils): | 6 | class TestAdd(TestUtils): |
| @@ -5,10 +5,6 @@ import sys | |||
| 5 | from typing import Any, Optional, TYPE_CHECKING | 5 | from typing import Any, Optional, TYPE_CHECKING |
| 6 | import importlib | 6 | import importlib |
| 7 | import functools | 7 | import functools |
| 8 | - | ||
| 9 | -if TYPE_CHECKING: | ||
| 10 | - from torch._dynamo.symbolic_convert import InstructionTranslator | ||
| 11 | - | ||
| 12 | import torch | 8 | import torch |
| 13 | import torch_npu | 9 | import torch_npu |
| 14 | from torch import _TorchCompileWrapper | 10 | from torch import _TorchCompileWrapper |
| @@ -266,6 +262,8 @@ def patch_npu_stream_context(): | |||
| 266 | from torch._dynamo.variables.base import VariableTracker | 262 | from torch._dynamo.variables.base import VariableTracker |
| 267 | from torch._dynamo.variables.streams import StreamContextVariable, StreamVariable | 263 | from torch._dynamo.variables.streams import StreamContextVariable, StreamVariable |
| 268 | from torch._dynamo.variables.torch import TorchInGraphFunctionVariable | 264 | from torch._dynamo.variables.torch import TorchInGraphFunctionVariable |
| 265 | + if TYPE_CHECKING: | ||
| 266 | + from torch._dynamo.symbolic_convert import InstructionTranslator | ||
| 269 | 267 | ||
| 270 | class NpuStreamContextVariable(StreamContextVariable): | 268 | class NpuStreamContextVariable(StreamContextVariable): |
| 271 | """This represents NPU stream context with FX graph set_stream node creation.""" | 269 | """This represents NPU stream context with FX graph set_stream node creation.""" |