Skip to content
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

Clarify the meaning of Shuffle::is_broadcast() #8158

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

abadams
Copy link
Member

@abadams abadams commented Mar 17, 2024

I was poking at the Shuffle node, and checking its usage, and it seems that despite the comment, Shuffles that return true for is_broadcast are not the same as Broadcast nodes. Instead of repeating the input vector some number of times, it repeats a shuffle of the input vector. This means IRPrinter was incorrect. The other usages were fine.

This PR makes this clearer in the comment, and fixes IRPrinter.

I was poking at the Shuffle node, and checking its usage, and it seems
that despite the comment, Shuffles that return true for is_broadcast are
not the same as a Broadcast node. Instead of repeating the input vector
some number of times, it repeats a shuffle of the input vector. This
means IRPrinter was incorrect. None of the other usages were bad.

This PR makes this clearer in the comment, and fixes IRPrinter.
@@ -502,7 +502,7 @@ Expr lossless_cast(Type t, Expr e) {
Expr a = lossless_cast(t.narrow(), sub->a);
Expr b = lossless_cast(t.narrow(), sub->b);
if (a.defined() && b.defined()) {
return cast(t, a) + cast(t, b);
return cast(t, a) - cast(t, b);
Copy link
Contributor

Choose a reason for hiding this comment

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

uh, what

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, a local change from the other PR snuck in. Will revert.

@steven-johnson steven-johnson self-requested a review March 18, 2024 16:03
Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

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

LGTM but IMHO we'd be better off renaming this method further; having two different things both named "broadcast" is needlessly confusing

@abadams
Copy link
Member Author

abadams commented Mar 18, 2024

A Broadcast node is already capable of repeating vectors, so I actually think this shuffle pattern should be a Broadcast node wrapped around a smaller shuffle, but it's used in ways I don't entirely understand in HexagonOptimize, so it's not a trivial change. I was in the middle of trying to fix the lossless_cast bug though, so I though I'd at least fix the comment rather than get side-tracked.

@steven-johnson
Copy link
Contributor

Ready to land?

@abadams abadams merged commit 14ae082 into main Apr 5, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants