We shouldn't broadcast the original value when doing reduction. Instead
we compute the reduction and then combine it with the original value.
Details
Diff Detail
Event Timeline
LGTM so putting a stamp, but please be sure to really refactor the code I point out, with good names to be super easy to come back to in the future.
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | ||
---|---|---|
259 | the new code above and below this line feel quite dry. |
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | ||
---|---|---|
184 | typo: two | |
203 | This is highly non-trivial, please add a comment with a detailed example with all the steps involved. | |
212 | This is adding a new read + broadcast that didn't exist before, right? | |
242 | typo: match |
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | ||
---|---|---|
263 | This should be return vectorizeBinaryReductionOp(reduceOp) where this code gets hoisted. |
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | ||
---|---|---|
212 | Correct, the problem is that the value we get at this stage is already loaded + broadcast and added (for a reduction add) to the input so there is nothing I can't extra bak the original value. |
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp | ||
---|---|---|
263 | I'm not sure I understand. Do you mean the whole creation of multiDimReduce + the extra op to combine with the initial value should go into vectorizeBinaryReductionOp or just the code creating the last instruction? |
typo: two