correctly import torch.version (#157584)

The structure is

```
torch/
  __init__.py
  version.py
```

When we import torch, only `torch/__init__.py` is executed by default.

The submodules like `version.py` are not automatically imported or attached to the torch module.

So without anything in `__init__.py`, `torch.version` may not be found. So in this PR, we make the import explicit.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157584
Approved by: https://github.com/ezyang
This commit is contained in:
Zeina Migeed
2025-07-07 21:43:31 +00:00
committed by PyTorch MergeBot
parent 5c79a55e7e
commit ed6df0e324

View File

@ -34,6 +34,8 @@ from typing import (
) )
from typing_extensions import ParamSpec as _ParamSpec, TypeIs as _TypeIs from typing_extensions import ParamSpec as _ParamSpec, TypeIs as _TypeIs
from . import version
if TYPE_CHECKING: if TYPE_CHECKING:
from .types import Device, IntLikeType from .types import Device, IntLikeType