-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Improve efficiency of _python_dispatch.return_and_correct_aliasing #161240
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161240
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 75fa587 with merge base a85711d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…aliasing" get_write_alias() call count reduction explained briefly in code comment. We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check. [ghstack-poisoned]
…aliasing" get_write_alias() call count reduction explained briefly in code comment. We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check. [ghstack-poisoned]
if not all(x is not None for x in schema_info_outs_write_aliases): | ||
raise RuntimeError("Unsupported schema: " + str(func._schema)) | ||
|
||
if len(func._schema.returns) == 1: |
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.
why do you change this line? it may indeed be the same length as schema_info_outs_write_aliases but this doesn't seem clearly perf motivated and i'm not actually sure they are the same
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 seems ok upon closer look
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.
func._schema.returns is a pybind; accessing it will cost more than the alternative
Starting merge as part of PR stack under #161285 |
…ly_alias_match (#161284) Containers are truthy iff they're non-empty. Pull Request resolved: #161284 Approved by: https://github.com/Skylion007, https://github.com/wconstab ghstack dependencies: #161231, #161234, #161235, #161240
…ytorch#161240) get_write_alias() call count reduction explained briefly in code comment. We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check. Pull Request resolved: pytorch#161240 Approved by: https://github.com/wconstab ghstack dependencies: pytorch#161231, pytorch#161234, pytorch#161235
…ly_alias_match (pytorch#161284) Containers are truthy iff they're non-empty. Pull Request resolved: pytorch#161284 Approved by: https://github.com/Skylion007, https://github.com/wconstab ghstack dependencies: pytorch#161231, pytorch#161234, pytorch#161235, pytorch#161240
…#161285) Drives down the overhead of return_and_correct_storage_aliasing slightly. Hopefully you'll agree it doesn't compromise readability. Pull Request resolved: pytorch#161285 Approved by: https://github.com/wconstab ghstack dependencies: pytorch#161231, pytorch#161234, pytorch#161235, pytorch#161240, pytorch#161284
Stack from ghstack (oldest at bottom):
is
, not ==, to check exact type matches in _python_dispatch #161304__hash__
and__eq__
#161234get_write_alias() call count reduction explained briefly in code comment.
We don't need to check write_aliases against None in the final outs_to_return calculation because we just did that check.