If there are reductions only along unit dimensions, then they are folded
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for adding this canonicalizer pattern! LGTM overall. Just a couple of comments.
mlir/lib/Dialect/Vector/IR/VectorOps.cpp | ||
---|---|---|
313 | nit: Elide -> Fold? (I'm not the best one to provide this feedback but elide sounds more like skip to me)? Can you also please add doc to this class about the cases that are folded and the ones that are not? | |
321 | I understand this will only fold multi reductions when all the reduction dims are 1. Would it make sense to also support partial folding (e.g., [0, 1], vector<1x64>)? | |
mlir/test/Dialect/Vector/canonicalize.mlir | ||
1360 | I would add a test for the partial folding case even if we don't support it for now. |
mlir/lib/Dialect/Vector/IR/VectorOps.cpp | ||
---|---|---|
313 | I used elide because of https://github.com/vmurali/llvm-project/blob/murali_llvm/mlir/lib/Dialect/Vector/IR/VectorOps.cpp#L452 (it's literally doing the same thing). I will see about adding the documentation. I didn't bother earlier because it's literally mimicking ReductionOp's canonicalizer. | |
321 | I don't think I understand what partial folding is. Can you give an example? |
Explicitly state that this transform happens only if all the reduction dimensions are unit dimensions.
I see this failure in some of our tests after this change. Any pointers?
assert.h assertion failed at third_party/llvm/llvm-project/mlir/include/mlir/IR/Value.h:434 in mlir::detail::TypedValue<mlir::VectorType>::TypedValue(Value) [Ty = mlir::VectorType]: !val || val.getType().template isa<Ty>()
nit: Elide -> Fold? (I'm not the best one to provide this feedback but elide sounds more like skip to me)?
Can you also please add doc to this class about the cases that are folded and the ones that are not?