[Mlir-commits] [mlir] [mlir] Convert `expand_shape` to more static form (PR #112265)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Oct 15 09:59:01 PDT 2024


================
@@ -1982,14 +1982,74 @@ struct FoldDimOfCollapseShape : public OpRewritePattern<DimOp> {
     return success();
   }
 };
+
+struct ConvertToStaticExpandShape : public OpRewritePattern<ExpandShapeOp> {
+  using OpRewritePattern<ExpandShapeOp>::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(ExpandShapeOp expandOp,
+                                PatternRewriter &rewriter) const override {
+    SmallVector<int64_t> newOutputShape(expandOp.getResultType().getShape());
----------------
MaheshRavishankar wrote:

You should look for source of `expandOp` is a `tensor.cast` operation where the source of the cast has a more static shape than the result (using https://github.com/llvm/llvm-project/blob/fb858b4f6ba454565abecbc107364a444668840b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h#L88 ). 

https://github.com/llvm/llvm-project/pull/112265


More information about the Mlir-commits mailing list