Skip to content

Include tensor shapes in get_broadcast_target_size error message #7944

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

Merged
merged 12 commits into from
Feb 7, 2025

Conversation

swolchok
Copy link
Contributor

This is the motivating example for #7902.

Test Plan: Injected failure to new broadcast_test and saw shapes in error message.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@swolchok
Copy link
Contributor Author

swolchok commented Jan 24, 2025

Copy link

pytorch-bot bot commented Jan 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/7944

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 4 Pending

As of commit f2538df with merge base 77f18b2 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

swolchok added a commit that referenced this pull request Jan 24, 2025
This is the motivating example for #7902.

Test Plan: Injected failure to new broadcast_test and saw shapes in error message.

ghstack-source-id: 7f41462
ghstack-comment-id: 2613189501
Pull Request resolved: #7944
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 24, 2025
@swolchok
Copy link
Contributor Author

would like feedback on this one before sending more PRs to log tensor shapes broadly

[ghstack-poisoned]
[ghstack-poisoned]
swolchok added a commit that referenced this pull request Jan 29, 2025
This is the motivating example for #7902.

Test Plan: Injected failure to new broadcast_test and saw shapes in error message.

ghstack-source-id: 3802db8
ghstack-comment-id: 2613189501
Pull Request resolved: #7944
[ghstack-poisoned]
[ghstack-poisoned]
swolchok added a commit that referenced this pull request Jan 31, 2025
This is the motivating example for #7902.

Test Plan: Injected failure to new broadcast_test and saw shapes in error message.

ghstack-source-id: c599767
ghstack-comment-id: 2613189501
Pull Request resolved: #7944
[ghstack-poisoned]
[ghstack-poisoned]
swolchok added a commit that referenced this pull request Feb 5, 2025
This is the motivating example for #7902.

Test Plan: Injected failure to new broadcast_test and saw shapes in error message.

ghstack-source-id: 6ae4789
ghstack-comment-id: 2613189501
Pull Request resolved: #7944
Base automatically changed from gh/swolchok/203/head to main February 6, 2025 02:24
[ghstack-poisoned]
InvalidArgument,
"Two input tensors should be broadcastable.\n");
if (!tensors_are_broadcastable_between(a_size, b_size)) {
const auto a_shape_str = tensor_shape_to_c_string(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new API is great, keeping the caller totally ignorant of how big a buffer to allocate.

tensors_are_broadcastable_between(a_size, b_size),
InvalidArgument,
"Two input tensors should be broadcastable.\n");
if (!tensors_are_broadcastable_between(a_size, b_size)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe thrown an UNLIKELY on this, but compared to the work done during broadcasting this is probably inconsequential

Suggested change
if (!tensors_are_broadcastable_between(a_size, b_size)) {
if (ET_UNLIKELY(!tensors_are_broadcastable_between(a_size, b_size))) {

[ghstack-poisoned]
@swolchok swolchok added the release notes: devtools Changes to dev tooling, for example the debugger & profiler label Feb 7, 2025
[ghstack-poisoned]
Comment on lines +224 to +229
#endif
ET_LOG(
Error,
"Two input tensors should be broadcastable but got shapes %s and %s.",
a_shape_str.data(),
b_shape_str.data());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be less surprising for readers if the if/endif completely covered the scopes of the locals that are defined in it, so they don't need to do the extra mental jump of "I guess ET_LOG evaluates to nothing when ET_LOG_ENABLED is false"

Suggested change
#endif
ET_LOG(
Error,
"Two input tensors should be broadcastable but got shapes %s and %s.",
a_shape_str.data(),
b_shape_str.data());
ET_LOG(
Error,
"Two input tensors should be broadcastable but got shapes %s and %s.",
a_shape_str.data(),
b_shape_str.data());
#endif

@swolchok swolchok merged commit ef30176 into main Feb 7, 2025
44 of 45 checks passed
@swolchok swolchok deleted the gh/swolchok/204/head branch February 7, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: devtools Changes to dev tooling, for example the debugger & profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants