The output operands will be added to input operands if the generic op (on tensors)
becomes an elementwise operation. The outputs of the generic op is still the same.
They will be cleaned up by ReplaceWithEmptyTensorIfUnused pattern.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
231–261 | Maybe I should move these to StaticValueUtils.h. They are also used in IREE LinalgExt dialect... |
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
153 | I think you can replace all the uses of this with rewriter.getAffineMapArrayAttr https://github.com/llvm/llvm-project/blob/d5844685810980399397a4310b943532361790ef/mlir/include/mlir/IR/Builders.h#L154 | |
157 | Change to Block seems unnecessary? | |
231–261 | You can use tensor::createDimValues https://github.com/llvm/llvm-project/blob/d5844685810980399397a4310b943532361790ef/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h#L31 | |
310 | Instead of adding a separate pattern for reduction (and making the existing pattern handle only parallel iterator types), it might be better to move the code to switch the operand from outs to ins in a separate pattern (if the operation has tensor semantics). Sorry, I should have been more explicit in my recommendation that this the pattern I was thinking about. |
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
310 | After reviewing the lit cases and offline discussion, this makes more sense to me now. Thanks for the suggestion! |
Just a few more clarifications.
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
235 | Actually I am not really sure why we need this separate pattern. SHouldnt it be easier to just add a tensor.empty as the value for the new outs operand added to AddInitOperandsToInput? | |
246 | Instead of using this, use getDpsInits and genericOp.getMatchingBlockArgument to get the argument. | |
259 | I am not sure we need this.... | |
274 | Maybe add some IR to explain this better. Also init have uses should be clarified to say blockArgument corresponding to init is used in the region. |
address comments
remove unneeded pattern
use DPS/StructuredOp methods
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
235 | I don't remember what the issues I hit, but it works now. Removed the pattern. | |
246 | thanks, I haven't touch DSP stuff for a while. They are all replaced with DSP/StructuredOp methods, and look cleaner. Thanks for the suggestion! | |
259 | removed. |
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
684 | LLVM style I think is to not use { } here... |
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp | ||
---|---|---|
684 | good point, it was two lines when having three patterns, so I added braces. I forgot to remove them... |
I think you can replace all the uses of this with rewriter.getAffineMapArrayAttr https://github.com/llvm/llvm-project/blob/d5844685810980399397a4310b943532361790ef/mlir/include/mlir/IR/Builders.h#L154