[llvm] [mlir] [mlir][tensor] Fold consumer linalg transpose with producer tensor pack (PR #74206)
Han-Chung Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 11:24:51 PST 2023
================
@@ -81,10 +82,91 @@ struct FoldUnpackWithExtractSliceOp : public OpRewritePattern<ExtractSliceOp> {
return success();
}
};
+
+/// Fold 'pack' -> 'transpose' into 'pack' since 'pack' already has transpose
+/// semantics.
+struct FoldProducerPackWithConsumerLinalgTransposeOp
+ : public OpRewritePattern<linalg::TransposeOp> {
+ using OpRewritePattern<linalg::TransposeOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(linalg::TransposeOp transposeOp,
+ PatternRewriter &rewriter) const override {
+ auto transposeInputTensor = transposeOp.getOperand(0);
+ auto packOp = transposeInputTensor.getDefiningOp<PackOp>();
----------------
hanhanW wrote:
`transposeInputTensor` is not meaningful and it is only used once. Can you merge these two lines?
https://github.com/llvm/llvm-project/pull/74206
More information about the llvm-commits
mailing list