-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Reference implementation for torch.Tensor.sum_to_size #85338
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/85338
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4b634c8: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torch/_refs/__init__.py
Outdated
|
||
def _is_expandable_to(shape, desired): | ||
# Python implementation of | ||
# aten/src/ATen/ExpandUtils.h:is_expandable_to |
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.
Let's still comment here on what the function does
return samples | ||
|
||
|
||
def error_inputs_sum_to_size(op_info, device, **kwargs): |
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.
Nice error input extension
|
||
def sum_to_size( | ||
a: Tensor, | ||
*shape, |
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's the correct type annotation 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.
We haven't been type annotating the *shape
so you needn't bother
I fixed the problem with "is_expandable_to" and added error sample input to verify that the implementation is correct now. @mruberry this is ready for another round. |
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.
Awesome!
@pytorchbot merge -g |
@pytorchbot successfully started a merge job. Check the current status here. |
Hey @IvanYashchuk. |
New ref: `torch._refs.sum_to_size`. View consistency validation is disabled because the ref returns a view instead of returning the input. Pull Request resolved: #85338 Approved by: https://github.com/mruberry
New ref:
torch._refs.sum_to_size
.View consistency validation is disabled because the ref returns a view instead of returning the input.