Skip to content

Commit 01128d4

Browse files
[mlir][vector][NFC] Clean up headers
Certain functions were declared in `VectorOps.h` instead of `VectorTransforms.h` or `VectorRewritePatterns.h`. Differential Revision: https://reviews.llvm.org/D152146
1 parent f69110d commit 01128d4

File tree

4 files changed

+54
-60
lines changed

4 files changed

+54
-60
lines changed

mlir/include/mlir/Dialect/Vector/IR/VectorOps.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -74,54 +74,6 @@ isBroadcastableTo(Type srcType, VectorType dstVectorType,
7474
void populateVectorToVectorCanonicalizationPatterns(RewritePatternSet &patterns,
7575
PatternBenefit benefit = 1);
7676

77-
/// Collect a set of vector.shape_cast folding patterns.
78-
void populateShapeCastFoldingPatterns(RewritePatternSet &patterns,
79-
PatternBenefit benefit = 1);
80-
81-
/// Cast away the leading unit dim, if exists, for the given contract op.
82-
/// Return success if the transformation applies; return failure otherwise.
83-
LogicalResult castAwayContractionLeadingOneDim(vector::ContractionOp contractOp,
84-
RewriterBase &rewriter);
85-
86-
/// Collect a set of leading one dimension removal patterns.
87-
///
88-
/// These patterns insert vector.shape_cast to remove leading one dimensions
89-
/// to expose more canonical forms of read/write/insert/extract operations.
90-
/// With them, there are more chances that we can cancel out extract-insert
91-
/// pairs or forward write-read pairs.
92-
void populateCastAwayVectorLeadingOneDimPatterns(RewritePatternSet &patterns,
93-
PatternBenefit benefit = 1);
94-
95-
/// Collect a set of one dimension removal patterns.
96-
///
97-
/// These patterns insert rank-reducing memref.subview ops to remove one
98-
/// dimensions. With them, there are more chances that we can avoid
99-
/// potentially exensive vector.shape_cast operations.
100-
void populateVectorTransferDropUnitDimsPatterns(RewritePatternSet &patterns,
101-
PatternBenefit benefit = 1);
102-
103-
/// Collect a set of patterns to flatten n-D vector transfers on contiguous
104-
/// memref.
105-
///
106-
/// These patterns insert memref.collapse_shape + vector.shape_cast patterns
107-
/// to transform multiple small n-D transfers into a larger 1-D transfer where
108-
/// the memref contiguity properties allow it.
109-
void populateFlattenVectorTransferPatterns(RewritePatternSet &patterns,
110-
PatternBenefit benefit = 1);
111-
112-
/// Collect a set of patterns that bubble up/down bitcast ops.
113-
///
114-
/// These patterns move vector.bitcast ops to be before insert ops or after
115-
/// extract ops where suitable. With them, bitcast will happen on smaller
116-
/// vectors and there are more chances to share extract/insert ops.
117-
void populateBubbleVectorBitCastOpPatterns(RewritePatternSet &patterns,
118-
PatternBenefit benefit = 1);
119-
120-
/// These patterns materialize masks for various vector ops such as transfers.
121-
void populateVectorMaskMaterializationPatterns(RewritePatternSet &patterns,
122-
bool force32BitVectorIndices,
123-
PatternBenefit benefit = 1);
124-
12577
/// Returns the integer type required for subscripts in the vector dialect.
12678
IntegerType getVectorSubscriptType(Builder &builder);
12779

mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#include <utility>
1414

1515
#include "mlir/Dialect/Vector/IR/VectorOps.h"
16-
#include "mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc"
1716
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
18-
#include "mlir/IR/BuiltinOps.h"
1917
#include "mlir/IR/PatternMatch.h"
2018
#include "mlir/Support/LogicalResult.h"
2119

20+
#include "mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc"
21+
2222
namespace mlir {
2323
class RewritePatternSet;
2424

@@ -57,7 +57,7 @@ struct UnrollVectorOptions {
5757
}
5858

5959
/// Function that returns the traversal order (in terms of "for loop order",
60-
/// i.e. slowest varying dimension to fastest varying dimension) that shoudl
60+
/// i.e. slowest varying dimension to fastest varying dimension) that should
6161
/// be used when unrolling the given operation into units of the native vector
6262
/// size.
6363
using UnrollTraversalOrderFnType =
@@ -70,10 +70,6 @@ struct UnrollVectorOptions {
7070
}
7171
};
7272

73-
//===----------------------------------------------------------------------===//
74-
// Vector transformation exposed as populate functions over rewrite patterns.
75-
//===----------------------------------------------------------------------===//
76-
7773
/// Canonicalization of a `vector.contraction %a, %b, %c` with row-major matmul
7874
/// semantics to a contraction with MMT semantics (matrix matrix multiplication
7975
/// with the RHS transposed). This specific form is meant to have the vector
@@ -134,10 +130,6 @@ void populateVectorReductionToContractPatterns(RewritePatternSet &patterns,
134130
void populateVectorTransferFullPartialPatterns(
135131
RewritePatternSet &patterns, const VectorTransformsOptions &options);
136132

137-
//===----------------------------------------------------------------------===//
138-
// Vector.transfer patterns.
139-
//===----------------------------------------------------------------------===//
140-
141133
/// Collect a set of patterns to reduce the rank of the operands of vector
142134
/// transfer ops to operate on the largest contigious vector.
143135
/// These patterns are useful when lowering to dialects with 1d vector type
@@ -263,6 +255,49 @@ void populateVectorUnrollPatterns(RewritePatternSet &patterns,
263255
const UnrollVectorOptions &options,
264256
PatternBenefit benefit = 1);
265257

258+
/// Collect a set of vector.shape_cast folding patterns.
259+
void populateShapeCastFoldingPatterns(RewritePatternSet &patterns,
260+
PatternBenefit benefit = 1);
261+
262+
/// Collect a set of leading one dimension removal patterns.
263+
///
264+
/// These patterns insert vector.shape_cast to remove leading one dimensions
265+
/// to expose more canonical forms of read/write/insert/extract operations.
266+
/// With them, there are more chances that we can cancel out extract-insert
267+
/// pairs or forward write-read pairs.
268+
void populateCastAwayVectorLeadingOneDimPatterns(RewritePatternSet &patterns,
269+
PatternBenefit benefit = 1);
270+
271+
/// Collect a set of one dimension removal patterns.
272+
///
273+
/// These patterns insert rank-reducing memref.subview ops to remove one
274+
/// dimensions. With them, there are more chances that we can avoid
275+
/// potentially expensive vector.shape_cast operations.
276+
void populateVectorTransferDropUnitDimsPatterns(RewritePatternSet &patterns,
277+
PatternBenefit benefit = 1);
278+
279+
/// Collect a set of patterns to flatten n-D vector transfers on contiguous
280+
/// memref.
281+
///
282+
/// These patterns insert memref.collapse_shape + vector.shape_cast patterns
283+
/// to transform multiple small n-D transfers into a larger 1-D transfer where
284+
/// the memref contiguity properties allow it.
285+
void populateFlattenVectorTransferPatterns(RewritePatternSet &patterns,
286+
PatternBenefit benefit = 1);
287+
288+
/// Collect a set of patterns that bubble up/down bitcast ops.
289+
///
290+
/// These patterns move vector.bitcast ops to be before insert ops or after
291+
/// extract ops where suitable. With them, bitcast will happen on smaller
292+
/// vectors and there are more chances to share extract/insert ops.
293+
void populateBubbleVectorBitCastOpPatterns(RewritePatternSet &patterns,
294+
PatternBenefit benefit = 1);
295+
296+
/// These patterns materialize masks for various vector ops such as transfers.
297+
void populateVectorMaskMaterializationPatterns(RewritePatternSet &patterns,
298+
bool force32BitVectorIndices,
299+
PatternBenefit benefit = 1);
300+
266301
} // namespace vector
267302
} // namespace mlir
268303

mlir/include/mlir/Dialect/Vector/Transforms/VectorTransforms.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace vector {
2727
//===----------------------------------------------------------------------===//
2828
// Vector transformation options exposed as auxiliary structs.
2929
//===----------------------------------------------------------------------===//
30+
3031
/// Structure to control the behavior of vector transform patterns.
3132
struct VectorTransformsOptions {
3233
/// Option to control the lowering of vector.contract.
@@ -63,6 +64,7 @@ struct VectorTransformsOptions {
6364
//===----------------------------------------------------------------------===//
6465
// Standalone transformations and helpers.
6566
//===----------------------------------------------------------------------===//
67+
6668
/// Split a vector.transfer operation into an in-bounds (i.e., no
6769
/// out-of-bounds masking) fastpath and a slowpath. If `ifOp` is not null and
6870
/// the result is `success, the `ifOp` points to the newly created conditional
@@ -106,6 +108,11 @@ LogicalResult splitFullAndPartialTransfer(
106108
/// optimizations.
107109
void transferOpflowOpt(RewriterBase &rewriter, Operation *rootOp);
108110

111+
/// Cast away the leading unit dim, if exists, for the given contract op.
112+
/// Return success if the transformation applies; return failure otherwise.
113+
LogicalResult castAwayContractionLeadingOneDim(vector::ContractionOp contractOp,
114+
RewriterBase &rewriter);
115+
109116
} // namespace vector
110117
} // namespace mlir
111118

mlir/lib/Dialect/Vector/Transforms/VectorDropLeadUnitDim.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include "mlir/Dialect/Utils/StructuredOpsUtils.h"
1010
#include "mlir/Dialect/Vector/IR/VectorOps.h"
1111
#include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h"
12+
#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
1213
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
1314
#include "mlir/IR/Builders.h"
14-
#include "mlir/IR/ImplicitLocOpBuilder.h"
1515
#include "mlir/IR/TypeUtilities.h"
1616

1717
#define DEBUG_TYPE "vector-drop-unit-dim"

0 commit comments

Comments
 (0)