Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

torch.nn.Module.named_parameters has wrong type annotation #48640

Closed
V3RGANz opened this issue Dec 1, 2020 · 5 comments
Closed

torch.nn.Module.named_parameters has wrong type annotation #48640

V3RGANz opened this issue Dec 1, 2020 · 5 comments
Labels
module: nn Related to torch.nn module: typing Related to mypy type annotations triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@V3RGANz
Copy link

V3RGANz commented Dec 1, 2020

馃悰 Bug

named_parameters(prefix: str = '', recurse: bool = True) -> Iterator[Tuple[str, torch.Tensor]] has torch.Tensor in return type, but seems that it always narrower type - nn.Parameter (as in torch.nn.Module.parameters signature)

Environment

pytorch 1.7

cc @albanD @mruberry @ezyang @malfet @rgommers @xuzhao9 @gramster

@zhangguanheng66 zhangguanheng66 added module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Dec 1, 2020
@mruberry mruberry added the module: typing Related to mypy type annotations label Dec 2, 2020
@mruberry
Copy link
Collaborator

mruberry commented Dec 2, 2020

Thank you for reporting this issue, @V3RGANz. I'll let our typing experts comment.

@rgommers
Copy link
Collaborator

rgommers commented Dec 2, 2020

Based on the implementation, typing as Parameter seems correct. This is more a usage question than a typing question though - are there any Module subclasses floating around that do not return Tuple(str, Parameter) from that method?

@ezyang
Copy link
Contributor

ezyang commented Dec 2, 2020

The intention of the method name seems pretty clear. Let's just update it.

@rgommers
Copy link
Collaborator

This will be fixed by gh-49045

@guilhermeleobas
Copy link
Collaborator

I believe this issue can be closed since gh-49045 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: nn Related to torch.nn module: typing Related to mypy type annotations triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

6 participants