[Mlir-commits] [mlir] [mlir][tensor] Fold producer linalg transpose with consumer tensor pack (PR #75658)
lorenzo chelini
llvmlistbot at llvm.org
Mon Dec 18 01:10:04 PST 2023
================
@@ -142,11 +173,48 @@ struct FoldProducerPackWithConsumerLinalgTransposeOp
return success();
}
};
+
+/// Fold 'transpose' -> 'pack' into 'pack' since 'pack' already has transpose
+/// semantics.
+struct FoldConsumerPackWithProducerLinalgTransposeOp
+ : public OpRewritePattern<PackOp> {
+ using OpRewritePattern<PackOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(PackOp packOp,
+ PatternRewriter &rewriter) const override {
+ auto transposeOp = packOp.getSource().getDefiningOp<linalg::TransposeOp>();
+
+ if (!transposeOp)
+ return failure();
+
+ SmallVector<int64_t> newOuterDimsPermVec;
+ SmallVector<int64_t> newInnerDimsPosVec;
+ SmallVector<OpFoldResult> newMixedInnerTilesVec;
+
+ bool foldingPossible = getRemappedPermutationForTransposeAndPack(
+ packOp, transposeOp, newOuterDimsPermVec, newInnerDimsPosVec,
+ newMixedInnerTilesVec, /*isTransposeProducer*/ true);
----------------
chelini wrote:
nit: /*isTransposeProducer =*/
https://github.com/llvm/llvm-project/pull/75658
More information about the Mlir-commits
mailing list