diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -81,6 +81,9 @@ /// Patterns that are used to inline constant operands into linalg generic ops. void populateInlineConstantOperandsPatterns(RewritePatternSet &patterns); +/// Pattern to convert TiledLoopOp to SCF loops. +void populateTiledLoopToSCFPattern(RewritePatternSet &patterns); + /// Options that control fusion of elementwise operations. struct LinalgElementwiseFusionOptions { /// Enable fusion of reshapes into the shape with elementwise operations. By diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp @@ -597,12 +597,16 @@ void runOnFunction() override { MLIRContext *context = &getContext(); RewritePatternSet patterns(context); - patterns.add(context); + populateTiledLoopToSCFPattern(patterns); (void)applyPatternsAndFoldGreedily(getFunction(), std::move(patterns)); } }; } // namespace +void mlir::linalg::populateTiledLoopToSCFPattern(RewritePatternSet &patterns) { + patterns.add(patterns.getContext()); +} + std::unique_ptr> mlir::createConvertLinalgTiledLoopsToSCFPass() { return std::make_unique();