pytorch
a6f4088c - Hint Tensor._make_subclass as a staticmethod (#101961)

Commit
2 years ago
Hint Tensor._make_subclass as a staticmethod (#101961) Fixes #101862 No more type errors and improved return type value: ```python import torch from torch import nn t = torch.tensor([1, 2, 3], dtype=torch.float32) t2 = torch.Tensor._make_subclass( # OK nn.Parameter, t.data, ) reveal_type(t2) # Type of "t2" is "Parameter" t3 = t._make_subclass( # OK nn.Parameter, t.data, ) reveal_type(t3) # Type of "t3" is "Parameter" ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/101961 Approved by: https://github.com/albanD
Author
Matthew Hoffman
Committer
Parents
Loading