-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR] Clean up pass options for test-loop-fusion and affine-super-vectorizer-test #87606
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
Conversation
Signed-off-by: philass <[email protected]>
Signed-off-by: philass <[email protected]>
@llvm/pr-subscribers-mlir-affine @llvm/pr-subscribers-mlir Author: Philip Lassen (philass) ChangesBefore the change Before the change
After the change
Full diff: https://github.com/llvm/llvm-project/pull/87606.diff 9 Files Affected:
diff --git a/mlir/test/Dialect/Affine/SuperVectorize/compose_maps.mlir b/mlir/test/Dialect/Affine/SuperVectorize/compose_maps.mlir
index b53fc55fdac910..d998ed874f416f 100644
--- a/mlir/test/Dialect/Affine/SuperVectorize/compose_maps.mlir
+++ b/mlir/test/Dialect/Affine/SuperVectorize/compose_maps.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -compose-maps -split-input-file 2>&1 | FileCheck %s
+// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test=compose-maps -split-input-file 2>&1 | FileCheck %s
// For all these cases, the test traverses the `test_affine_map` ops and
// composes them in order one-by-one.
diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir
index e58de9fdaa762e..bd71164244c00b 100644
--- a/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir
+++ b/mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir
@@ -1,6 +1,6 @@
-// RUN: mlir-opt %s -affine-super-vectorizer-test -vector-shape-ratio 4 -vector-shape-ratio 8 2>&1 | FileCheck %s
-// RUN: mlir-opt %s -affine-super-vectorizer-test -vector-shape-ratio 2 -vector-shape-ratio 5 -vector-shape-ratio 2 2>&1 | FileCheck %s -check-prefix=TEST-3x4x5x8
-// RUN: mlir-opt %s -affine-super-vectorizer-test -vectorize-affine-loop-nest 2>&1 | FileCheck %s -check-prefix=VECNEST
+// RUN: mlir-opt %s -affine-super-vectorizer-test="vector-shape-ratio=4,8" 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -affine-super-vectorizer-test="vector-shape-ratio=2,5,2" 2>&1 | FileCheck %s -check-prefix=TEST-3x4x5x8
+// RUN: mlir-opt %s -affine-super-vectorizer-test=vectorize-affine-loop-nest 2>&1 | FileCheck %s -check-prefix=VECNEST
func.func @vector_add_2d(%arg0: index, %arg1: index) -> f32 {
// Nothing should be matched in this first block.
diff --git a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir
index c117bfc82ca079..6c1a7c48c4cb13 100644
--- a/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir
+++ b/mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -affine-super-vectorizer-test -vectorize-affine-loop-nest -split-input-file 2>&1 | FileCheck %s
+// RUN: mlir-opt %s -affine-super-vectorizer-test=vectorize-affine-loop-nest -split-input-file 2>&1 | FileCheck %s
func.func @unparallel_loop_reduction_unsupported(%in: memref<256x512xf32>, %out: memref<256xf32>) {
// CHECK: Outermost loop cannot be parallel
diff --git a/mlir/test/Dialect/Affine/loop-fusion-dependence-check.mlir b/mlir/test/Dialect/Affine/loop-fusion-dependence-check.mlir
index aa872b0f6911ac..2c53852a8cec9f 100644
--- a/mlir/test/Dialect/Affine/loop-fusion-dependence-check.mlir
+++ b/mlir/test/Dialect/Affine/loop-fusion-dependence-check.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-fusion -test-loop-fusion-dependence-check -split-input-file -verify-diagnostics | FileCheck %s
+// RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-fusion=test-loop-fusion-dependence-check -split-input-file -verify-diagnostics | FileCheck %s
// -----
diff --git a/mlir/test/Dialect/Affine/loop-fusion-slice-computation.mlir b/mlir/test/Dialect/Affine/loop-fusion-slice-computation.mlir
index c303dd0c01eced..aa79ee26928e29 100644
--- a/mlir/test/Dialect/Affine/loop-fusion-slice-computation.mlir
+++ b/mlir/test/Dialect/Affine/loop-fusion-slice-computation.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -test-loop-fusion -test-loop-fusion-slice-computation -split-input-file -verify-diagnostics | FileCheck %s
+// RUN: mlir-opt %s -test-loop-fusion=test-loop-fusion-slice-computation -split-input-file -verify-diagnostics | FileCheck %s
// -----
diff --git a/mlir/test/Dialect/Affine/loop-fusion-transformation.mlir b/mlir/test/Dialect/Affine/loop-fusion-transformation.mlir
index c8e0918e6bfd6f..4f4163a2bbd528 100644
--- a/mlir/test/Dialect/Affine/loop-fusion-transformation.mlir
+++ b/mlir/test/Dialect/Affine/loop-fusion-transformation.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s -allow-unregistered-dialect -test-loop-fusion -test-loop-fusion-transformation -split-input-file -canonicalize | FileCheck %s
+// RUN: mlir-opt %s -allow-unregistered-dialect -test-loop-fusion=test-loop-fusion-transformation -split-input-file -canonicalize | FileCheck %s
// CHECK-LABEL: func @slice_depth1_loop_nest() {
func.func @slice_depth1_loop_nest() {
diff --git a/mlir/test/Dialect/Affine/slicing-utils.mlir b/mlir/test/Dialect/Affine/slicing-utils.mlir
index 71bd8ad4ef9daa..74379978fdf8c3 100644
--- a/mlir/test/Dialect/Affine/slicing-utils.mlir
+++ b/mlir/test/Dialect/Affine/slicing-utils.mlir
@@ -1,6 +1,6 @@
-// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test -forward-slicing=true 2>&1 | FileCheck %s --check-prefix=FWD
-// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test -backward-slicing=true 2>&1 | FileCheck %s --check-prefix=BWD
-// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test -slicing=true 2>&1 | FileCheck %s --check-prefix=FWDBWD
+// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test="forward-slicing=true" 2>&1 | FileCheck %s --check-prefix=FWD
+// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test="backward-slicing=true" 2>&1 | FileCheck %s --check-prefix=BWD
+// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test="slicing=true" 2>&1 | FileCheck %s --check-prefix=FWDBWD
/// 1 2 3 4
/// |_______| |______|
diff --git a/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp b/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp
index f4f1593dc53e2b..19011803a793ac 100644
--- a/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp
@@ -22,23 +22,6 @@
using namespace mlir;
using namespace mlir::affine;
-static llvm::cl::OptionCategory clOptionsCategory(DEBUG_TYPE " options");
-
-static llvm::cl::opt<bool> clTestDependenceCheck(
- "test-loop-fusion-dependence-check",
- llvm::cl::desc("Enable testing of loop fusion dependence check"),
- llvm::cl::cat(clOptionsCategory));
-
-static llvm::cl::opt<bool> clTestSliceComputation(
- "test-loop-fusion-slice-computation",
- llvm::cl::desc("Enable testing of loop fusion slice computation"),
- llvm::cl::cat(clOptionsCategory));
-
-static llvm::cl::opt<bool> clTestLoopFusionTransformation(
- "test-loop-fusion-transformation",
- llvm::cl::desc("Enable testing of loop fusion transformation"),
- llvm::cl::cat(clOptionsCategory));
-
namespace {
struct TestLoopFusion
@@ -50,6 +33,24 @@ struct TestLoopFusion
return "Tests loop fusion utility functions.";
}
void runOnOperation() override;
+
+ TestLoopFusion() = default;
+ TestLoopFusion(const TestLoopFusion &pass) : PassWrapper(pass){};
+
+ Option<bool> clTestDependenceCheck{
+ *this, "test-loop-fusion-dependence-check",
+ llvm::cl::desc("Enable testing of loop fusion dependence check"),
+ llvm::cl::init(false)};
+
+ Option<bool> clTestSliceComputation{
+ *this, "test-loop-fusion-slice-computation",
+ llvm::cl::desc("Enable testing of loop fusion slice computation"),
+ llvm::cl::init(false)};
+
+ Option<bool> clTestLoopFusionTransformation{
+ *this, "test-loop-fusion-transformation",
+ llvm::cl::desc("Enable testing of loop fusion transformation"),
+ llvm::cl::init(false)};
};
} // namespace
diff --git a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
index b497f8d75fde75..598678f64cb467 100644
--- a/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
+++ b/mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp
@@ -37,39 +37,6 @@ using namespace mlir::affine;
static llvm::cl::OptionCategory clOptionsCategory(DEBUG_TYPE " options");
-static llvm::cl::list<int> clTestVectorShapeRatio(
- "vector-shape-ratio",
- llvm::cl::desc("Specify the HW vector size for vectorization"),
- llvm::cl::cat(clOptionsCategory));
-static llvm::cl::opt<bool> clTestForwardSlicingAnalysis(
- "forward-slicing",
- llvm::cl::desc("Enable testing forward static slicing and topological sort "
- "functionalities"),
- llvm::cl::cat(clOptionsCategory));
-static llvm::cl::opt<bool> clTestBackwardSlicingAnalysis(
- "backward-slicing",
- llvm::cl::desc("Enable testing backward static slicing and "
- "topological sort functionalities"),
- llvm::cl::cat(clOptionsCategory));
-static llvm::cl::opt<bool> clTestSlicingAnalysis(
- "slicing",
- llvm::cl::desc("Enable testing static slicing and topological sort "
- "functionalities"),
- llvm::cl::cat(clOptionsCategory));
-static llvm::cl::opt<bool> clTestComposeMaps(
- "compose-maps",
- llvm::cl::desc(
- "Enable testing the composition of AffineMap where each "
- "AffineMap in the composition is specified as the affine_map attribute "
- "in a constant op."),
- llvm::cl::cat(clOptionsCategory));
-static llvm::cl::opt<bool> clTestVecAffineLoopNest(
- "vectorize-affine-loop-nest",
- llvm::cl::desc(
- "Enable testing for the 'vectorizeAffineLoopNest' utility by "
- "vectorizing the outermost loops found"),
- llvm::cl::cat(clOptionsCategory));
-
namespace {
struct VectorizerTestPass
: public PassWrapper<VectorizerTestPass, OperationPass<func::FuncOp>> {
@@ -85,6 +52,37 @@ struct VectorizerTestPass
return "Tests vectorizer standalone functionality.";
}
+ VectorizerTestPass() = default;
+ VectorizerTestPass(const VectorizerTestPass &pass) : PassWrapper(pass){};
+
+ ListOption<int> clTestVectorShapeRatio{
+ *this, "vector-shape-ratio",
+ llvm::cl::desc("Specify the HW vector size for vectorization")};
+ Option<bool> clTestForwardSlicingAnalysis{
+ *this, "forward-slicing",
+ llvm::cl::desc(
+ "Enable testing forward static slicing and topological sort "
+ "functionalities")};
+ Option<bool> clTestBackwardSlicingAnalysis{
+ *this, "backward-slicing",
+ llvm::cl::desc("Enable testing backward static slicing and "
+ "topological sort functionalities")};
+ Option<bool> clTestSlicingAnalysis{
+ *this, "slicing",
+ llvm::cl::desc("Enable testing static slicing and topological sort "
+ "functionalities")};
+ Option<bool> clTestComposeMaps{
+ *this, "compose-maps",
+ llvm::cl::desc("Enable testing the composition of AffineMap where each "
+ "AffineMap in the composition is specified as the "
+ "affine_map attribute "
+ "in a constant op.")};
+ Option<bool> clTestVecAffineLoopNest{
+ *this, "vectorize-affine-loop-nest",
+ llvm::cl::desc(
+ "Enable testing for the 'vectorizeAffineLoopNest' utility by "
+ "vectorizing the outermost loops found")};
+
void runOnOperation() override;
void testVectorShapeRatio(llvm::raw_ostream &outs);
void testForwardSlicing(llvm::raw_ostream &outs);
|
Thanks for the review @ftynse. Could you merge for me? |
Before the change
test-loop-fusion
andaffine-super-vectorizer-test
options were in their own category. This was because they used the standard llvm command line parsing withllvm::cl::opt
. This PR moves them over to the mlirPass::Option
class.Before the change
After the change