-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Embed torch.nn typing annotations #43044
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed torch.nn typing annotations #43044
Conversation
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
💊 CI failures summary and remediationsAs of commit a851f01 (more details on the Dr. CI page):
XLA failureJob pytorch_xla_linux_bionic_py3_6_clang9_test is failing. Please create an issue with title prefixed by ci.pytorch.org: 1 failedThis comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 9 times. |
9565caf to
8be5f91
Compare
Also add typing anotations to _check_param_device
8be5f91 to
a851f01
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
rgommers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one question about class attributes.
| name: str | ||
| dim: int | ||
| n_power_iterations: int | ||
| eps: float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These seem unnecessary, mypy is happy with only the annotations of __init__() as far as I can tell. Adding these is harmless, but we want to make a habit of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR just copies existing annotations.
I thought this is done to annotate class members, which are likely to be accessed outside of the class scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's covered in PEP 526; several methods are valid it looks like. One could also leave these out, or use
self.name: str = name
inline instead. I don't have a strong preference either way.
Make it match type-annotated signature from pytorch/pytorch#43044
Make it match type-annotated signature from pytorch/pytorch#43044
I want to re-attempt: * #61467 See: * #10536 (comment) and this is one of the files I would touch. quoting @ezyang: * #91648 (comment) > The back story here is that in #19089 we added pyi stubs for nn modules, but when we got off Python 2 we started merging the pyi stubs directly into the py files, e.g., as in #43044. But not all the modules got the treatment. Pull Request resolved: #131872 Approved by: https://github.com/Skylion007, https://github.com/ezyang
Delete several .pyi files and embed annotations from those files in respective .py