-
Notifications
You must be signed in to change notification settings - Fork 130
Rewrite specifically for Sum and Prod to remove Join #951
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
This may overlap/be redundant with #888 |
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.
My rewrite depends on #346 to get to the final value for Sum
as the implementation introduces a MakeVector
. For it to work for Prod, I need to add a similar one for Prod
.
@register_canonicalize | ||
@register_uncanonicalize | ||
@register_specialize | ||
@node_rewriter([Sum, Prod]) |
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.
When there's nothing special about Sum and Prod we should apply the rewrites to all CAReduce operations, which also include stuff like Max, All, Any, ..., of which Sum/Prod are just two more instances
See the related PR I linked to in the comment
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.
Oops, 2nd time. I did not see this one show up in #59 😄.
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.
No they are not the same exactly.
There's a rewrite for reduction along axis0 for a join along axis 0.
My PR extends this to any axis.
There's then the question of multiple axis, of which axis=None is the most extreme (all axes). This PR can cover that case.
We may also want to think about multiple but not all axis. In what cases can we reduce first and join later?
Description
Rewrite specifically for Sum and Prod to remove Join. So graph that starts as
will become
Related Issue
Sum
s ofMakeVector
s andJoin
s #59Checklist
Type of change