Skip to content

[mlir][Vector][NFC] Add vector-transform-options flag to ConvertVectorToLLVMPass #123491

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
Jan 22, 2025

Conversation

dcaballe
Copy link
Contributor

This flag enables the configuration of some transformation such as the lowering of contractions and transposes. The default configuration preserves the existing behavior.

…torToLLVMPass

This flag enables the configuration of some transformation
such as the lowering of contractions and transposes. The
default configuration preserves the existing behavior.
@llvmbot
Copy link
Member

llvmbot commented Jan 19, 2025

@llvm/pr-subscribers-mlir

Author: Diego Caballero (dcaballe)

Changes

This flag enables the configuration of some transformation such as the lowering of contractions and transposes. The default configuration preserves the existing behavior.


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

3 Files Affected:

  • (modified) mlir/include/mlir/Conversion/Passes.td (+5-1)
  • (modified) mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h (+1)
  • (modified) mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp (+2-3)
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index 0f42ffb3a80266..7600d723c30936 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -1440,7 +1440,11 @@ def ConvertVectorToLLVMPass : Pass<"convert-vector-to-llvm"> {
     Option<"x86Vector", "enable-x86vector",
            "bool", /*default=*/"false",
            "Enables the use of X86Vector dialect while lowering the vector "
-	   "dialect.">
+	   "dialect.">,
+    Option<"vectorTransformsOptions", "vector-transform-options",
+           "vector::VectorTransformsOptions",
+           /*default=*/"vector::VectorTransformsOptions()",
+           "Options to lower some operations like contractions and transposes.">,
   ];
 }
 
diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h
index 4661d31b6364d5..410b881db79590 100644
--- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h
+++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h
@@ -9,6 +9,7 @@
 #define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVMPASS_H_
 
 #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
+#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
 
 namespace mlir {
 class Pass;
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
index 2c4c5ada9815d6..e3a81bd20212d8 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
@@ -69,12 +69,11 @@ void ConvertVectorToLLVMPass::runOnOperation() {
     populateVectorToVectorCanonicalizationPatterns(patterns);
     populateVectorBitCastLoweringPatterns(patterns);
     populateVectorBroadcastLoweringPatterns(patterns);
-    populateVectorContractLoweringPatterns(patterns, VectorTransformsOptions());
+    populateVectorContractLoweringPatterns(patterns, vectorTransformsOptions);
     populateVectorMaskOpLoweringPatterns(patterns);
     populateVectorShapeCastLoweringPatterns(patterns);
     populateVectorInterleaveLoweringPatterns(patterns);
-    populateVectorTransposeLoweringPatterns(patterns,
-                                            VectorTransformsOptions());
+    populateVectorTransposeLoweringPatterns(patterns, vectorTransformsOptions);
     // Vector transfer ops with rank > 1 should be lowered with VectorToSCF.
     populateVectorTransferLoweringPatterns(patterns, /*maxTransferRank=*/1);
     populateVectorMaskMaterializationPatterns(patterns,

Copy link
Contributor

@banach-space banach-space left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dcaballe dcaballe merged commit d25a1f8 into llvm:main Jan 22, 2025
10 checks passed
@Devjiu
Copy link

Devjiu commented Feb 24, 2025

Hello!
This PR causes failure in PassCrashReproducerGenerator with ConvertVectorToLLVMPass. It happens because new field misses parser/printer.

@dcaballe Could you help with this issue? Maybe there are some WA or example how to write printer for this.

@banach-space
Copy link
Contributor

Hello! This PR causes failure in PassCrashReproducerGenerator with ConvertVectorToLLVMPass. It happens because new field misses parser/printer.

@dcaballe Could you help with this issue? Maybe there are some WA or example how to write printer for this.

This was raised on Discourse:

Subsequent fix:

@dcaballe
Copy link
Contributor Author

@dcaballe Could you help with this issue? Maybe there are some WA or example how to write printer for this.

Sorry about that. I just reviewed the fix but it needs more reviewers to take a look. If this is blocking you, please, let me know and I'll revert this PR in the meantime.

@Devjiu
Copy link

Devjiu commented Feb 25, 2025

Ok, got it, thanks. Sorry, google didn't show me the discussion on Discourse for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants