[Mlir-commits] [mlir] [mlir] Convert `expand_shape` to more static form (PR #112265)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Oct 21 22:53:45 PDT 2024
================
@@ -1982,14 +1983,91 @@ struct FoldDimOfCollapseShape : public OpRewritePattern<DimOp> {
return success();
}
};
+
+struct ConvertToStaticExpandShape : public OpRewritePattern<ExpandShapeOp> {
+ using OpRewritePattern<ExpandShapeOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(ExpandShapeOp expandOp,
+ PatternRewriter &rewriter) const override {
+ auto castOp = expandOp.getSrc().getDefiningOp<CastOp>();
+ if (!canFoldIntoConsumerOp(castOp))
+ return failure();
+
+ const ArrayRef<int64_t> castSrcShape =
+ castOp.getSource().getType().getShape();
+ const SmallVector<ReassociationIndices, 4> reassoc =
----------------
MaheshRavishankar wrote:
Same here. Drop the `const`.
https://github.com/llvm/llvm-project/pull/112265
More information about the Mlir-commits
mailing list