MLIR  16.0.0git
Transforms.h
Go to the documentation of this file.
1 //===- Transforms.h - Tensor Transformation Patterns ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMS_H
10 #define MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMS_H
11 
13 #include "mlir/IR/PatternMatch.h"
14 
15 namespace mlir {
16 namespace tensor {
17 
18 /// Populates `patterns` with patterns to wrap a tensor.pad op with an scf.if op
19 /// to separate the cases where we don't need padding (all pad sizes are
20 /// actually zeros) and where we indeed need padding.
21 void populateSplitPaddingPatterns(RewritePatternSet &patterns,
22  PatternBenefit baseBenefit = 1);
23 
24 /// Pattern to swap an `tensor.extract_slice` with its producer when the
25 /// producer implements the `TilingInterface`. The pattern itself does not
26 /// provide a mechanism to control where the application happens. With use of
27 /// transform dialect that control is done within the transform dialect. Other
28 /// use cases can inherit from this pattern and add necessary controls.
30  OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producerOp);
31 
32 /// Collects patterns to merge consecutive tensor.insert_slice/extract_slice
33 /// into one. These patterns are in in this separate entry point because the
34 /// bufferization is sensitive over IR structure, particularly those
35 /// tensor.extract_slice and tensor.insert_slice ops for creating the slices.
37  RewritePatternSet &patterns);
38 
39 } // namespace tensor
40 } // namespace mlir
41 
42 #endif // MLIR_DIALECT_TENSOR_TRANSFORMS_TRANSFORMS_H
Include the generated interface declarations.
FailureOr< Value > replaceExtractSliceWithTiledProducer(OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producerOp)
Pattern to swap an tensor.extract_slice with its producer when the producer implements the TilingInte...
void populateSplitPaddingPatterns(RewritePatternSet &patterns, PatternBenefit baseBenefit=1)
Populates patterns with patterns to wrap a tensor.pad op with an scf.if op to separate the cases wher...
void populateMergeConsecutiveInsertExtractSlicePatterns(RewritePatternSet &patterns)
Collects patterns to merge consecutive tensor.insert_slice/extract_slice into one.