Skip to content

[mlir][Transforms] Mark 1:N conversion driver as deprecated #121102

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

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

matthias-springer
Copy link
Member

Depends on: #121054, #121101

@llvmbot
Copy link
Member

llvmbot commented Dec 25, 2024

@llvm/pr-subscribers-mlir-scf
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Matthias Springer (matthias-springer)

Changes

Depends on: #121054, #121101


Full diff: https://github.com/llvm/llvm-project/pull/121102.diff

2 Files Affected:

  • (modified) mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h (+4)
  • (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+16)
diff --git a/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h b/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h
index b87407d302a823..9c1479d28c305f 100644
--- a/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h
+++ b/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h
@@ -66,6 +66,10 @@ void populateSCFStructuralTypeConversionTarget(
 /// Populates the provided pattern set with patterns that do 1:N type
 /// conversions on (some) SCF ops. This is intended to be used with
 /// applyPartialOneToNConversion.
+/// FIXME: The 1:N dialect conversion is deprecated and will be removed soon.
+/// 1:N support has been added to the regular dialect conversion driver.
+LLVM_DEPRECATED("Use populateSCFStructuralTypeConversions() instead",
+                "populateSCFStructuralTypeConversions")
 void populateSCFStructuralOneToNTypeConversions(
     const TypeConverter &typeConverter, RewritePatternSet &patterns);
 
diff --git a/mlir/include/mlir/Transforms/OneToNTypeConversion.h b/mlir/include/mlir/Transforms/OneToNTypeConversion.h
index 7b4dd65cbff7b2..9c74bf916d971b 100644
--- a/mlir/include/mlir/Transforms/OneToNTypeConversion.h
+++ b/mlir/include/mlir/Transforms/OneToNTypeConversion.h
@@ -6,6 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 //
+// Note: The 1:N dialect conversion is deprecated and will be removed soon.
+// 1:N support has been added to the regular dialect conversion driver.
+//
 // This file provides utils for implementing (poor-man's) dialect conversion
 // passes with 1:N type conversions.
 //
@@ -119,6 +122,10 @@ class OneToNPatternRewriter : public PatternRewriter {
   /// types must be the same as the result types of the op) and the new values
   /// (i.e., the converted types must be the same as the types of the new
   /// values).
+  /// FIXME: The 1:N dialect conversion is deprecated and will be removed soon.
+  /// 1:N support has been added to the regular dialect conversion driver.
+  LLVM_DEPRECATED("Use replaceOpWithMultiple() instead",
+                  "replaceOpWithMultiple")
   void replaceOp(Operation *op, ValueRange newValues,
                  const OneToNTypeMapping &resultMapping);
   using PatternRewriter::replaceOp;
@@ -251,6 +258,10 @@ class OneToNOpConversionPattern : public OneToNConversionPattern {
 /// or illegal types; the function simply applies the given patterns and does
 /// not fail if some ops or types remain unconverted (i.e., the conversion is
 /// only "partial").
+/// FIXME: The 1:N dialect conversion is deprecated and will be removed soon.
+/// 1:N support has been added to the regular dialect conversion driver.
+LLVM_DEPRECATED("Use applyPartialConversion() instead",
+                "applyPartialConversion")
 LogicalResult
 applyPartialOneToNConversion(Operation *op, TypeConverter &typeConverter,
                              const FrozenRewritePatternSet &patterns);
@@ -259,6 +270,11 @@ applyPartialOneToNConversion(Operation *op, TypeConverter &typeConverter,
 /// FunctionOpInterface op with the given type converter. This only supports
 /// ops which use FunctionType to represent their type. This is intended to be
 /// used with the 1:N dialect conversion.
+/// FIXME: The 1:N dialect conversion is deprecated and will be removed soon.
+/// 1:N support has been added to the regular dialect conversion driver.
+LLVM_DEPRECATED(
+    "Use populateFunctionOpInterfaceTypeConversionPattern() instead",
+    "populateFunctionOpInterfaceTypeConversionPattern")
 void populateOneToNFunctionOpInterfaceTypeConversionPattern(
     StringRef functionLikeOpName, const TypeConverter &converter,
     RewritePatternSet &patterns);

Copy link
Member

@zero9178 zero9178 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@matthias-springer matthias-springer merged commit 80ecbaa into main Dec 31, 2024
12 checks passed
@matthias-springer matthias-springer deleted the users/matthias-springer/dialect_conv_depr branch December 31, 2024 12:11
@MaskRay
Copy link
Member

MaskRay commented Jan 1, 2025

@matthias-springer mlir/lib/Dialect/SCF/Transforms/OneToNTypeConversion.cpp now emits some -Wdeprecated-declarations warnings. In llvm-project, we generally fix or work around in-tree
warnings before adding a deprecated attribute.

@matthias-springer
Copy link
Member Author

applyPartialOneToNConversion and a few others are still used in a test case of the 1:N conversion driver. (Not an application of the conversion driver, but the conversion driver itself.) Is there a way to mark it as "deprecated" without removing the test cases? Ideally, I'd like to remove applyPartialOneToNConversion and its tests at the same time to avoid a (temporary) gap in test coverage.

@DanielCChen
Copy link
Contributor

@matthias-springer We are getting build failures as:

llvm-project/mlir/lib/Dialect/SCF/Transforms/OneToNTypeConversion.cpp:53:14: error: 'replaceOp' is deprecated: Use replaceOpWithMultiple() instead [-Werror,-Wdeprecated-declarations]
   53 |     rewriter.replaceOp(op, newOp->getResults(), resultMapping);
      |              ^~~~~~~~~
      |              replaceOpWithMultiple

It seems the two (replaceOp and replaceOpWithMultiple) have different ABI.

@matthias-springer
Copy link
Member Author

matthias-springer commented Jan 8, 2025

The two APIs are slightly different. It is not a 1:1 replacement.

It seems like it was not the best idea to mark these functions as "deprecated" while they are still in use in MLIR because of compiler warnings. This PR turns them into comments.

(Note: The 1:N conversion framework is still deprecated and I plan to delete it in April 2025.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir:scf mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants