Skip to content

Commit 01f4ca0

Browse files
committed
[MLIR][Linalg] Rename convolution pass (with deprecation notice)
Rename the pass `LinalgNamedOpConversionPass` to `SimplifyDepthwiseConvPass` to avoid conflating it with the new morphisms we are creating between the norms. Keep the old pass/function as deprecated for now, and agree on a timing to remove it from the tree at some point in the future.
1 parent 0732693 commit 01f4ca0

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

mlir/include/mlir/Dialect/Linalg/Passes.td

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,19 @@ def LinalgSpecializeGenericOpsPass : Pass<"linalg-specialize-generic-ops">,
8686
let dependentDialects = ["linalg::LinalgDialect"];
8787
}
8888

89-
def LinalgNamedOpConversionPass: Pass<"linalg-named-op-conversion"> {
89+
def LinalgNamedOpConversionPass: Pass<"linalg-named-op-conversion">,
90+
Deprecated<"Use 'simplify-depthwise-conv' instead."> {
9091
let summary = "Convert from one named linalg op to another.";
9192
let dependentDialects = ["linalg::LinalgDialect", "tensor::TensorDialect"];
9293
}
9394

9495
// ------------------ End of "form" conversions
9596

97+
def SimplifyDepthwiseConvPass: Pass<"simplify-depthwise-conv"> {
98+
let summary = "Simplify depthwise convolution.";
99+
let dependentDialects = ["linalg::LinalgDialect", "tensor::TensorDialect"];
100+
}
101+
96102
def ConvertElementwiseToLinalgPass : Pass<"convert-elementwise-to-linalg", ""> {
97103
let summary = "Convert ElementwiseMappable ops to linalg";
98104
let description = [{

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "mlir/IR/PatternMatch.h"
2525
#include "mlir/Interfaces/TilingInterface.h"
2626
#include "mlir/Transforms/DialectConversion.h"
27+
#include "llvm/Support/Compiler.h"
2728
#include "llvm/ADT/SmallBitVector.h"
2829
#include "llvm/ADT/SmallSet.h"
2930

@@ -1962,8 +1963,11 @@ void populateFoldAddIntoDestPatterns(RewritePatternSet &patterns);
19621963
void populateFuseTensorPadWithProducerLinalgOpPatterns(
19631964
RewritePatternSet &patterns);
19641965

1965-
/// Patterns to convert from one named op to another. These can be seen as
1966-
/// canonicalizations of named ops into another named op.
1966+
/// Patterns to simplify depthwise convolutions.
1967+
void populateSimplifyDepthwiseConvPatterns(RewritePatternSet &patterns);
1968+
1969+
/// Patterns to convert from one named op to another. So far only used on
1970+
/// depthwise convolutions, so deprecated. Use the pattern avove.
19671971
void populateLinalgNamedOpConversionPatterns(RewritePatternSet &patterns);
19681972

19691973
/// Patterns to fold unit-extent dimensions in operands/results of linalg ops on

mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ add_mlir_dialect_library(MLIRLinalgTransforms
2626
MorphOps.cpp
2727
TransposeMatmul.cpp
2828
ShardingInterfaceImpl.cpp
29-
NamedOpConversions.cpp
29+
SimplifyDepthwiseConv.cpp
3030
NamedToElementwise.cpp
3131
BlockPackMatmul.cpp
3232
PackAndUnpackPatterns.cpp

mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp renamed to mlir/lib/Dialect/Linalg/Transforms/SimplifyDepthwiseConv.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
namespace mlir {
2424
#define GEN_PASS_DEF_LINALGNAMEDOPCONVERSIONPASS
25+
#define GEN_PASS_DEF_SIMPLIFYDEPTHWISECONVPASS
2526
#include "mlir/Dialect/Linalg/Passes.h.inc"
2627
} // namespace mlir
2728

@@ -143,6 +144,22 @@ struct SimplifyDepthwiseConvQOp
143144
}
144145
};
145146

147+
struct SimplifyDepthwiseConvPass
148+
: public impl::SimplifyDepthwiseConvPassBase<
149+
SimplifyDepthwiseConvPass> {
150+
using impl::SimplifyDepthwiseConvPassBase<
151+
SimplifyDepthwiseConvPass>::SimplifyDepthwiseConvPassBase;
152+
153+
void runOnOperation() override {
154+
Operation *op = getOperation();
155+
RewritePatternSet patterns(op->getContext());
156+
populateSimplifyDepthwiseConvPatterns(patterns);
157+
if (failed(applyPatternsGreedily(op, std::move(patterns))))
158+
return signalPassFailure();
159+
}
160+
};
161+
162+
// Deprecated, use the one above
146163
struct LinalgNamedOpConversionPass
147164
: public impl::LinalgNamedOpConversionPassBase<
148165
LinalgNamedOpConversionPass> {
@@ -159,6 +176,13 @@ struct LinalgNamedOpConversionPass
159176
};
160177
} // namespace
161178

179+
void mlir::linalg::populateSimplifyDepthwiseConvPatterns(
180+
RewritePatternSet &patterns) {
181+
patterns.add<SimplifyDepthwiseConvOp, SimplifyDepthwiseConvQOp>(
182+
patterns.getContext());
183+
}
184+
185+
// Deprecated, use the one above
162186
void mlir::linalg::populateLinalgNamedOpConversionPatterns(
163187
RewritePatternSet &patterns) {
164188
patterns.add<SimplifyDepthwiseConvOp, SimplifyDepthwiseConvQOp>(

0 commit comments

Comments
 (0)