[Mlir-commits] [mlir] [mlir] Allow folding dynamic full size subviews (PR #140619)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue May 20 07:22:48 PDT 2025


================
@@ -3206,7 +3215,7 @@ class TrivialSubViewOpFolder final : public OpRewritePattern<SubViewOp> {
 
   LogicalResult matchAndRewrite(SubViewOp subViewOp,
                                 PatternRewriter &rewriter) const override {
-    if (!isTrivialSubViewOp(subViewOp))
+    if (!isTrivialSubViewOp(rewriter, subViewOp))
       return failure();
----------------
Max191 wrote:

Yeah, it is difficult to compare the dynamic sizes without doing this. The other option I considered was using the ValueBoundsOpInterface, but that seems like an expensive check to run in a canonicalization. It would be nice if there were a version of `reifyResultShapes` that did not create IR, and returned failure if creating new IR was necessary, but that seems like a lot of work to plumb through.

These are the ways I know of to compare the result sizes of a tensor, but if you have any better suggestions, then that would be very helpful!

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


More information about the Mlir-commits mailing list