Question about reduce(reshape(x)) swap in algebraic_simplifier.cc HandleReduce #9096
apivovarov
started this conversation in
General
Replies: 1 comment
-
I suspect it's a typo in the comment, it should be: "This is beneficial because the reshape will now operate on less data". |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
I have a question about
AlgebraicSimplifierVisitor::HandleReduce
.Handle
reduce(reshape(x))
cases in particularLets look at the following hlo example:
Input:
Output after
AlgebraicSimplifierVisitor::HandleReduce
:The code comments says:
Case2: This is beneficial because the reduce will now operate on less data.
The statement above is not 100% clear to me.
Why
operate on less data than
???
In the first and the second cases input size is 6,553,600 elems and output size is 1,280 elems. - no difference in the amount of data.
The only diff is in input/output shapes and tensor ranks
I'd say that the first case (without this optimization) looks a bit "simpler" because
reduce
deals with lower rank input/output tensors.Docs and links:
AlgebraicSimplifierVisitor::HandleReduce
Code commentshttps://github.com/openxla/xla/blob/main/xla/service/algebraic_simplifier.cc#L6985
https://github.com/openxla/xla/blob/main/xla/service/algebraic_simplifier.cc#L7041
Handle
reduce(reshape(x))
Case 2 was added on Mar 29, 20234195a90
Justin @jlebar, can you comment on this ? Thank you.
Beta Was this translation helpful? Give feedback.
All reactions