mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
------ - [Generic TypeAlias (PEP 585)](https://peps.python.org/pep-0585): e.g. `typing.List[T] -> list[T]`, `typing.Dict[KT, VT] -> dict[KT, VT]`, `typing.Type[T] -> type[T]`. - [Union Type (PEP 604)](https://peps.python.org/pep-0604): e.g. `Union[X, Y] -> X | Y`, `Optional[X] -> X | None`, `Optional[Union[X, Y]] -> X | Y | None`. Note that in `.pyi` stub files, we do not need `from __future__ import annotations`. So this PR does not violate issue #117449: - #117449 Pull Request resolved: https://github.com/pytorch/pytorch/pull/129419 Approved by: https://github.com/ezyang ghstack dependencies: #129375, #129376
29 lines
877 B
Python
29 lines
877 B
Python
# mypy: allow-untyped-defs
|
|
from typing_extensions import TypeGuard
|
|
|
|
from torch import device, dtype, Tensor
|
|
|
|
class Parameter(Tensor):
|
|
def __init__(self, data: Tensor = ..., requires_grad: bool = ...) -> None: ...
|
|
|
|
def is_lazy(
|
|
param: Tensor,
|
|
) -> TypeGuard[UninitializedParameter | UninitializedBuffer]: ...
|
|
|
|
class UninitializedParameter(Tensor):
|
|
def __init__(self, data: Tensor = ..., requires_grad: bool = ...) -> None: ...
|
|
def materialize(
|
|
self,
|
|
shape: tuple[int, ...],
|
|
device: device | None = None,
|
|
dtype: dtype | None = None,
|
|
) -> None: ...
|
|
|
|
class UninitializedBuffer(Tensor):
|
|
def __init__(self, data: Tensor = ..., requires_grad: bool = ...) -> None: ...
|
|
def materialize(
|
|
self,
|
|
shape: tuple[int, ...],
|
|
device: device | None = None,
|
|
dtype: dtype | None = None,
|
|
) -> None: ...
|