-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Replace manual cache in _python_dispatch.get_alias_info with functools.cache #161286
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
…s.cache In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161286
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fe95fdf with merge base ffa1ce7 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…th functools.cache" In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit. [ghstack-poisoned]
…th functools.cache" In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit. [ghstack-poisoned]
|
||
# Given an OpOverload, returns schema information on it. | ||
# This is cached for efficiency, since it can involve running torchgen | ||
@functools.cache |
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.
for my education- is this purely a "its more idiomatic this way" thing or is this faster too?
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.
for my education- is this purely a "its more idiomatic this way" thing or is this faster too?
both -- functools.cache does only one lookup. It's pretty neat, check it out
…th functools.cache" In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit. [ghstack-poisoned]
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…s.cache (#161286) In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit. Pull Request resolved: #161286 Approved by: https://github.com/wconstab
…161300) Shouldn't be any generated code impact, just fixing bad practice. Pull Request resolved: #161300 Approved by: https://github.com/wconstab, https://github.com/malfet ghstack dependencies: #161286
…s.cache (pytorch#161286) In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit. Pull Request resolved: pytorch#161286 Approved by: https://github.com/wconstab
…ytorch#161300) Shouldn't be any generated code impact, just fixing bad practice. Pull Request resolved: pytorch#161300 Approved by: https://github.com/wconstab, https://github.com/malfet ghstack dependencies: pytorch#161286
…ytorch#161300) Shouldn't be any generated code impact, just fixing bad practice. Pull Request resolved: pytorch#161300 Approved by: https://github.com/wconstab, https://github.com/malfet ghstack dependencies: pytorch#161286
Stack from ghstack (oldest at bottom):
is
, not ==, to check exact type matches in _python_dispatch #161304In addition to being more code, the manual cache was doing an extra dictionary lookup on each cache hit.