[Mlir-commits] [mlir] [mlir][TosaToLinalg] Ensure valid insertion pointer after op erasure (PR #146908)
Matthias Springer
llvmlistbot at llvm.org
Thu Jul 3 07:39:29 PDT 2025
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/146908
Erasing/replacing an op, which is also the current insertion point, invalidates the insertion point. Explicitly set the insertion point, so that subsequent op insertions do not crash after the One-Shot Dialect Conversion refactoring. (`ConversionPatternRewriter` will start behaving more like a "normal" rewriter.)
>From 743b3a8737e3fe83cb6e8fd9757ebc57059357c2 Mon Sep 17 00:00:00 2001
From: Matthias Springer <me at m-sp.org>
Date: Thu, 3 Jul 2025 14:37:16 +0000
Subject: [PATCH] [mlir][TosaToLinalg] Ensure valid insertion pointer after op
erasure
Erasing/replacing an op, which is also the current insertion point, invalidates the insertion point. Explicitly set the insertion point, so that copy does not crash after the One-Shot Dialect Conversion refactoring. (ConversionPatternRewriter will start behaving more like a "normal" rewriter.)
---
mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
index c460a8bb2f4b2..ca8f6fcb1e122 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp
@@ -815,6 +815,7 @@ class MaxPool2dConverter : public OpConversionPattern<tosa::MaxPool2dOp> {
ValueRange{paddedInput, fakeWindowDims}, filledEmptyTensor, strideAttr,
dilationAttr);
+ rewriter.setInsertionPointAfter(op);
rewriter.replaceOp(op, resultOp);
// NaN propagation has no meaning for non floating point types.
More information about the Mlir-commits
mailing list