-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[MLIR][DialectConversion] Export isOpIgnored in ConversionPatternRewriter #154300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-mlir Author: William Moses (wsmoses) ChangesThis is particularly helpful for more complex dialect conversion patterns which conditionally apply given the subject of an analysis of the non-deleted operations Full diff: https://github.com/llvm/llvm-project/pull/154300.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index 536b23f5c33c1..5de58b89130a2 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -862,6 +862,9 @@ class ConversionPatternRewriter final : public PatternRewriter {
/// Return a reference to the internal implementation.
detail::ConversionPatternRewriterImpl &getImpl();
+ /// Return "true" if the given operation was replaced or erased.
+ bool isOpIgnored(Operation *op) const;
+
private:
// Allow OperationConverter to construct new rewriters.
friend struct OperationConverter;
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 7494ca9ec3784..f95340c718409 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2245,6 +2245,10 @@ detail::ConversionPatternRewriterImpl &ConversionPatternRewriter::getImpl() {
return *impl;
}
+bool ConversionPatternRewriter::isOpIgnored(Operation *op) const {
+ return getImpl()->isOpIgnored(op);
+}
+
//===----------------------------------------------------------------------===//
// ConversionPattern
//===----------------------------------------------------------------------===//
|
@llvm/pr-subscribers-mlir-core Author: William Moses (wsmoses) ChangesThis is particularly helpful for more complex dialect conversion patterns which conditionally apply given the subject of an analysis of the non-deleted operations Full diff: https://github.com/llvm/llvm-project/pull/154300.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index 536b23f5c33c1..5de58b89130a2 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -862,6 +862,9 @@ class ConversionPatternRewriter final : public PatternRewriter {
/// Return a reference to the internal implementation.
detail::ConversionPatternRewriterImpl &getImpl();
+ /// Return "true" if the given operation was replaced or erased.
+ bool isOpIgnored(Operation *op) const;
+
private:
// Allow OperationConverter to construct new rewriters.
friend struct OperationConverter;
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 7494ca9ec3784..f95340c718409 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2245,6 +2245,10 @@ detail::ConversionPatternRewriterImpl &ConversionPatternRewriter::getImpl() {
return *impl;
}
+bool ConversionPatternRewriter::isOpIgnored(Operation *op) const {
+ return getImpl()->isOpIgnored(op);
+}
+
//===----------------------------------------------------------------------===//
// ConversionPattern
//===----------------------------------------------------------------------===//
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write a test upstream?
I don't quite get the usage of this right now.
Can you describe a bit when this function is useful? This is an implementation detail of the conversion driver and we should expose it only if needed. (E.g., "ignoredOps" in the new conversion driver ( Can you work with |
This is particularly helpful for more complex dialect conversion patterns which conditionally apply given the subject of an analysis of the non-deleted operations