已合并
move_type_checking_import #40343
cuiduo创建于 7月7日
move_type_checking_import #40343
已合并
共 2 个文件变更+2-4
| @@ -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): |
| @@ -11,9 +11,6 @@ import torch_npu | |||
| 11 | from torch import _TorchCompileWrapper | 11 | from torch import _TorchCompileWrapper |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | -if TYPE_CHECKING: | ||
| 15 | - from torch._dynamo.symbolic_convert import InstructionTranslator | ||
| 16 | - | ||
| 17 | use_jit_script = False | 14 | use_jit_script = False |
| 18 | log = logging.getLogger(__name__) | 15 | log = logging.getLogger(__name__) |
| 19 | 16 | ||
| @@ -276,6 +273,8 @@ def patch_npu_stream_context(): | |||
| 276 | from torch._dynamo.variables.base import VariableTracker | 273 | from torch._dynamo.variables.base import VariableTracker |
| 277 | from torch._dynamo.variables.streams import StreamContextVariable, StreamVariable | 274 | from torch._dynamo.variables.streams import StreamContextVariable, StreamVariable |
| 278 | from torch._dynamo.variables.torch import TorchInGraphFunctionVariable | 275 | from torch._dynamo.variables.torch import TorchInGraphFunctionVariable |
| 276 | + if TYPE_CHECKING: | ||
| 277 | + from torch._dynamo.symbolic_convert import InstructionTranslator | ||
| 279 | 278 | ||
| 280 | class NpuStreamContextVariable(StreamContextVariable): | 279 | class NpuStreamContextVariable(StreamContextVariable): |
| 281 | """This represents NPU stream context with FX graph set_stream node creation.""" | 280 | """This represents NPU stream context with FX graph set_stream node creation.""" |