Skip to content

Commit 608a663

Browse files
authored
[MLIR] Clean up pass options for test-loop-fusion and affine-super-vectorizer-test (#87606)
Before the change `test-loop-fusion` and `affine-super-vectorizer-test` options were in their own category. This was because they used the standard llvm command line parsing with `llvm::cl::opt`. This PR moves them over to the mlir `Pass::Option` class. Before the change ``` $ mlir-opt --help ... General options: ... Compiler passes to run Passes: ... Pass Pipelines: ... Generic Options: .... affine-super-vectorizer-test options: --backward-slicing ... --vectorize-affine-loop-nest test-loop-fusion options: --test-loop-fusion-dependence-check ... --test-loop-fusion-transformation ``` After the change ``` $ mlir-opt --help ... General options: ... Compiler passes to run Passes: ... --affine-super-vectorizer-test --backward-slicing ... --vectorize-affine-loop-nest ... --test-loop-fusion options: --test-loop-fusion-dependence-check ... --test-loop-fusion-transformation ... Pass Pipelines: ... Generic Options: ... ``` --------- Signed-off-by: philass <[email protected]>
1 parent bf2d785 commit 608a663

9 files changed

+60
-61
lines changed

mlir/test/Dialect/Affine/SuperVectorize/compose_maps.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test -compose-maps -split-input-file 2>&1 | FileCheck %s
1+
// RUN: mlir-opt -allow-unregistered-dialect %s -affine-super-vectorizer-test=compose-maps -split-input-file 2>&1 | FileCheck %s
22

33
// For all these cases, the test traverses the `test_affine_map` ops and
44
// composes them in order one-by-one.

mlir/test/Dialect/Affine/SuperVectorize/vector_utils.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: mlir-opt %s -affine-super-vectorizer-test -vector-shape-ratio 4 -vector-shape-ratio 8 2>&1 | FileCheck %s
2-
// 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
3-
// RUN: mlir-opt %s -affine-super-vectorizer-test -vectorize-affine-loop-nest 2>&1 | FileCheck %s -check-prefix=VECNEST
1+
// RUN: mlir-opt %s -affine-super-vectorizer-test="vector-shape-ratio=4,8" 2>&1 | FileCheck %s
2+
// RUN: mlir-opt %s -affine-super-vectorizer-test="vector-shape-ratio=2,5,2" 2>&1 | FileCheck %s -check-prefix=TEST-3x4x5x8
3+
// RUN: mlir-opt %s -affine-super-vectorizer-test=vectorize-affine-loop-nest 2>&1 | FileCheck %s -check-prefix=VECNEST
44

55
func.func @vector_add_2d(%arg0: index, %arg1: index) -> f32 {
66
// Nothing should be matched in this first block.

mlir/test/Dialect/Affine/SuperVectorize/vectorize_unsupported.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -affine-super-vectorizer-test -vectorize-affine-loop-nest -split-input-file 2>&1 | FileCheck %s
1+
// RUN: mlir-opt %s -affine-super-vectorizer-test=vectorize-affine-loop-nest -split-input-file 2>&1 | FileCheck %s
22

33
func.func @unparallel_loop_reduction_unsupported(%in: memref<256x512xf32>, %out: memref<256xf32>) {
44
// CHECK: Outermost loop cannot be parallel

mlir/test/Dialect/Affine/loop-fusion-dependence-check.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-fusion -test-loop-fusion-dependence-check -split-input-file -verify-diagnostics | FileCheck %s
1+
// RUN: mlir-opt -allow-unregistered-dialect %s -test-loop-fusion=test-loop-fusion-dependence-check -split-input-file -verify-diagnostics | FileCheck %s
22

33
// -----
44

mlir/test/Dialect/Affine/loop-fusion-slice-computation.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -test-loop-fusion -test-loop-fusion-slice-computation -split-input-file -verify-diagnostics | FileCheck %s
1+
// RUN: mlir-opt %s -test-loop-fusion=test-loop-fusion-slice-computation -split-input-file -verify-diagnostics | FileCheck %s
22

33
// -----
44

mlir/test/Dialect/Affine/loop-fusion-transformation.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-opt %s -allow-unregistered-dialect -test-loop-fusion -test-loop-fusion-transformation -split-input-file -canonicalize | FileCheck %s
1+
// RUN: mlir-opt %s -allow-unregistered-dialect -test-loop-fusion=test-loop-fusion-transformation -split-input-file -canonicalize | FileCheck %s
22

33
// CHECK-LABEL: func @slice_depth1_loop_nest() {
44
func.func @slice_depth1_loop_nest() {

mlir/test/Dialect/Affine/slicing-utils.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test -forward-slicing=true 2>&1 | FileCheck %s --check-prefix=FWD
2-
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test -backward-slicing=true 2>&1 | FileCheck %s --check-prefix=BWD
3-
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test -slicing=true 2>&1 | FileCheck %s --check-prefix=FWDBWD
1+
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test="forward-slicing=true" 2>&1 | FileCheck %s --check-prefix=FWD
2+
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test="backward-slicing=true" 2>&1 | FileCheck %s --check-prefix=BWD
3+
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -affine-super-vectorizer-test="slicing=true" 2>&1 | FileCheck %s --check-prefix=FWDBWD
44

55
/// 1 2 3 4
66
/// |_______| |______|

mlir/test/lib/Dialect/Affine/TestLoopFusion.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,6 @@
2222
using namespace mlir;
2323
using namespace mlir::affine;
2424

25-
static llvm::cl::OptionCategory clOptionsCategory(DEBUG_TYPE " options");
26-
27-
static llvm::cl::opt<bool> clTestDependenceCheck(
28-
"test-loop-fusion-dependence-check",
29-
llvm::cl::desc("Enable testing of loop fusion dependence check"),
30-
llvm::cl::cat(clOptionsCategory));
31-
32-
static llvm::cl::opt<bool> clTestSliceComputation(
33-
"test-loop-fusion-slice-computation",
34-
llvm::cl::desc("Enable testing of loop fusion slice computation"),
35-
llvm::cl::cat(clOptionsCategory));
36-
37-
static llvm::cl::opt<bool> clTestLoopFusionTransformation(
38-
"test-loop-fusion-transformation",
39-
llvm::cl::desc("Enable testing of loop fusion transformation"),
40-
llvm::cl::cat(clOptionsCategory));
41-
4225
namespace {
4326

4427
struct TestLoopFusion
@@ -50,6 +33,24 @@ struct TestLoopFusion
5033
return "Tests loop fusion utility functions.";
5134
}
5235
void runOnOperation() override;
36+
37+
TestLoopFusion() = default;
38+
TestLoopFusion(const TestLoopFusion &pass) : PassWrapper(pass){};
39+
40+
Option<bool> clTestDependenceCheck{
41+
*this, "test-loop-fusion-dependence-check",
42+
llvm::cl::desc("Enable testing of loop fusion dependence check"),
43+
llvm::cl::init(false)};
44+
45+
Option<bool> clTestSliceComputation{
46+
*this, "test-loop-fusion-slice-computation",
47+
llvm::cl::desc("Enable testing of loop fusion slice computation"),
48+
llvm::cl::init(false)};
49+
50+
Option<bool> clTestLoopFusionTransformation{
51+
*this, "test-loop-fusion-transformation",
52+
llvm::cl::desc("Enable testing of loop fusion transformation"),
53+
llvm::cl::init(false)};
5354
};
5455

5556
} // namespace

mlir/test/lib/Dialect/Affine/TestVectorizationUtils.cpp

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,39 +37,6 @@ using namespace mlir::affine;
3737

3838
static llvm::cl::OptionCategory clOptionsCategory(DEBUG_TYPE " options");
3939

40-
static llvm::cl::list<int> clTestVectorShapeRatio(
41-
"vector-shape-ratio",
42-
llvm::cl::desc("Specify the HW vector size for vectorization"),
43-
llvm::cl::cat(clOptionsCategory));
44-
static llvm::cl::opt<bool> clTestForwardSlicingAnalysis(
45-
"forward-slicing",
46-
llvm::cl::desc("Enable testing forward static slicing and topological sort "
47-
"functionalities"),
48-
llvm::cl::cat(clOptionsCategory));
49-
static llvm::cl::opt<bool> clTestBackwardSlicingAnalysis(
50-
"backward-slicing",
51-
llvm::cl::desc("Enable testing backward static slicing and "
52-
"topological sort functionalities"),
53-
llvm::cl::cat(clOptionsCategory));
54-
static llvm::cl::opt<bool> clTestSlicingAnalysis(
55-
"slicing",
56-
llvm::cl::desc("Enable testing static slicing and topological sort "
57-
"functionalities"),
58-
llvm::cl::cat(clOptionsCategory));
59-
static llvm::cl::opt<bool> clTestComposeMaps(
60-
"compose-maps",
61-
llvm::cl::desc(
62-
"Enable testing the composition of AffineMap where each "
63-
"AffineMap in the composition is specified as the affine_map attribute "
64-
"in a constant op."),
65-
llvm::cl::cat(clOptionsCategory));
66-
static llvm::cl::opt<bool> clTestVecAffineLoopNest(
67-
"vectorize-affine-loop-nest",
68-
llvm::cl::desc(
69-
"Enable testing for the 'vectorizeAffineLoopNest' utility by "
70-
"vectorizing the outermost loops found"),
71-
llvm::cl::cat(clOptionsCategory));
72-
7340
namespace {
7441
struct VectorizerTestPass
7542
: public PassWrapper<VectorizerTestPass, OperationPass<func::FuncOp>> {
@@ -85,6 +52,37 @@ struct VectorizerTestPass
8552
return "Tests vectorizer standalone functionality.";
8653
}
8754

55+
VectorizerTestPass() = default;
56+
VectorizerTestPass(const VectorizerTestPass &pass) : PassWrapper(pass){};
57+
58+
ListOption<int> clTestVectorShapeRatio{
59+
*this, "vector-shape-ratio",
60+
llvm::cl::desc("Specify the HW vector size for vectorization")};
61+
Option<bool> clTestForwardSlicingAnalysis{
62+
*this, "forward-slicing",
63+
llvm::cl::desc(
64+
"Enable testing forward static slicing and topological sort "
65+
"functionalities")};
66+
Option<bool> clTestBackwardSlicingAnalysis{
67+
*this, "backward-slicing",
68+
llvm::cl::desc("Enable testing backward static slicing and "
69+
"topological sort functionalities")};
70+
Option<bool> clTestSlicingAnalysis{
71+
*this, "slicing",
72+
llvm::cl::desc("Enable testing static slicing and topological sort "
73+
"functionalities")};
74+
Option<bool> clTestComposeMaps{
75+
*this, "compose-maps",
76+
llvm::cl::desc("Enable testing the composition of AffineMap where each "
77+
"AffineMap in the composition is specified as the "
78+
"affine_map attribute "
79+
"in a constant op.")};
80+
Option<bool> clTestVecAffineLoopNest{
81+
*this, "vectorize-affine-loop-nest",
82+
llvm::cl::desc(
83+
"Enable testing for the 'vectorizeAffineLoopNest' utility by "
84+
"vectorizing the outermost loops found")};
85+
8886
void runOnOperation() override;
8987
void testVectorShapeRatio(llvm::raw_ostream &outs);
9088
void testForwardSlicing(llvm::raw_ostream &outs);

0 commit comments

Comments
 (0)