[Mlir-commits] [mlir] [mlir][linalg] Add folder for transpose(transpose) -> transpose (PR #93606)
donald chen
llvmlistbot at llvm.org
Wed May 29 05:42:36 PDT 2024
================
@@ -1866,6 +1866,36 @@ LogicalResult TransposeOp::fold(FoldAdaptor adaptor,
return failure();
}
+/// Fold transpose with transpose.
+struct FoldTransposeWithTranspose : OpRewritePattern<linalg::TransposeOp> {
+ using OpRewritePattern<linalg::TransposeOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(linalg::TransposeOp transposeOp,
+ PatternRewriter &rewriter) const override {
+ if (auto defTransposeOp =
+ transposeOp.getInput().getDefiningOp<TransposeOp>()) {
+
+ auto defPerms = defTransposeOp.getPermutation();
+ auto perms = transposeOp.getPermutation();
----------------
cxy-1993 wrote:
nit: expand auto unless it is obvious
https://github.com/llvm/llvm-project/pull/93606
More information about the Mlir-commits
mailing list