mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Fixes #76772, #144196 Extends #144106 - added type annotations to `lazy_property`. - added type annotation to all `@property` and `@lazy_property` inside `torch.distributions` module. - added simply type-check unit test to ensure type inference is working. - replaced deprecated annotations like `typing.List` with the corresponding counterpart. - simplified `torch.Tensor` hints with plain `Tensor`, otherwise signatures can become very verbose. Pull Request resolved: https://github.com/pytorch/pytorch/pull/144110 Approved by: https://github.com/Skylion007
12 lines
278 B
Python
12 lines
278 B
Python
from typing_extensions import assert_type
|
|
|
|
import torch
|
|
from torch import distributions, Tensor
|
|
|
|
|
|
dist = distributions.Normal(0, 1)
|
|
assert_type(dist.mean, Tensor)
|
|
|
|
dist = distributions.MultivariateNormal(torch.zeros(2), torch.eye(2))
|
|
assert_type(dist.covariance_matrix, Tensor)
|