-
Notifications
You must be signed in to change notification settings - Fork 24.9k
[jit] Add self to Python printer reserved words #15318
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
Conversation
This adds `self` to the list of reserved words and also sorts the lines
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.
@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@@ -142,19 +142,17 @@ void createTensorToParameterNameMap( | |||
// they are keywords or namespaces used in the output | |||
const static std::unordered_set<std::string> reserved_names = { |
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.
What about new keywords like async?
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.
Maybe follow this list?
https://github.com/python/cpython/blob/3.7/Lib/keyword.py
We are also missing del
here
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.
@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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. Not sure I'm a fan of discarding the name while tracing, but any other solutions would probably be more involved
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.
@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@@ -223,10 +223,10 @@ def _get_interpreter_name_for_var(var): | |||
|
|||
for k, v in f_locals.items(): | |||
if isinstance(v, torch.Tensor) and var is v: | |||
return k | |||
return k if k != 'self' else '' |
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.
A comment for why this is unwanted would be very useful.
Summary: This adds `self` to the list of reserved words and also sorts the lines and prevents the tracer from naming values 'self' (which happens in torch/tensor.py) Fixes #15240 Pull Request resolved: #15318 Differential Revision: D13540192 Pulled By: driazati fbshipit-source-id: 46ae02e51b1b31d5c62110fa83ba258ea6bada27
Summary: This adds `self` to the list of reserved words and also sorts the lines and prevents the tracer from naming values 'self' (which happens in torch/tensor.py) Fixes #15240 Pull Request resolved: #15318 Differential Revision: D13540192 Pulled By: driazati fbshipit-source-id: 46ae02e51b1b31d5c62110fa83ba258ea6bada27
Summary: This adds `self` to the list of reserved words and also sorts the lines and prevents the tracer from naming values 'self' (which happens in torch/tensor.py) Fixes #15240 Pull Request resolved: #15318 Differential Revision: D13540192 Pulled By: driazati fbshipit-source-id: 46ae02e51b1b31d5c62110fa83ba258ea6bada27
This adds
self
to the list of reserved words and also sorts the lines and prevents the tracer from naming values 'self' (which happens in torch/tensor.py)Fixes #15240