MLIR  16.0.0git
Passes.h
Go to the documentation of this file.
1 //===- Passes.h - Linalg pass entry points ----------------------*- 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 // This header file defines prototypes that expose pass constructors.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_DIALECT_LINALG_PASSES_H_
14 #define MLIR_DIALECT_LINALG_PASSES_H_
15 
18 #include "mlir/Pass/Pass.h"
19 
20 namespace mlir {
21 namespace func {
22 class FuncOp;
23 } // namespace func
24 
25 namespace bufferization {
26 struct OneShotBufferizationOptions;
27 } // namespace bufferization
28 
29 std::unique_ptr<Pass> createConvertElementwiseToLinalgPass();
30 
31 std::unique_ptr<Pass> createLinalgFoldUnitExtentDimsPass();
32 
33 std::unique_ptr<Pass> createLinalgElementwiseOpFusionPass();
34 std::unique_ptr<Pass> createFoldReshapeOpsByLinearizationPass();
35 
36 std::unique_ptr<Pass> createLinalgNamedOpConversionPass();
37 
38 std::unique_ptr<OperationPass<func::FuncOp>>
39 createLinalgTilingPass(ArrayRef<int64_t> tileSizes = {},
42 
43 std::unique_ptr<OperationPass<func::FuncOp>>
45 
46 /// Create a pass to convert Linalg operations to scf.for loops and
47 /// memref.load/memref.store accesses.
48 std::unique_ptr<OperationPass<func::FuncOp>> createConvertLinalgToLoopsPass();
49 
50 /// Create a pass to convert Linalg operations to scf.parallel loops and
51 /// memref.load/memref.store accesses.
52 std::unique_ptr<OperationPass<func::FuncOp>>
54 
55 /// Create a pass to convert Linalg operations to affine.for loops and
56 /// affine_load/affine_store accesses.
57 /// Placeholder for now, this is NYI.
58 std::unique_ptr<OperationPass<func::FuncOp>>
60 
61 /// Create a pass that rewrites init_tensor to alloc_tensor.
62 std::unique_ptr<Pass> createLinalgInitTensorToAllocTensorPass();
63 
64 /// Create a pass to convert Linalg operations which work on tensors to use
65 /// buffers instead.
66 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgBufferizePass();
67 
68 /// Create a pass to convert named Linalg operations to Linalg generic
69 /// operations.
70 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgGeneralizationPass();
71 
72 /// Create a pass to convert Linalg operations to equivalent operations that
73 /// work on primitive types, if possible.
74 std::unique_ptr<Pass> createLinalgDetensorizePass();
75 
76 //===----------------------------------------------------------------------===//
77 /// Linalg strategy passes.
78 //===----------------------------------------------------------------------===//
79 /// Create a LinalgStrategyTileAndFusePass.
80 std::unique_ptr<OperationPass<func::FuncOp>>
82  StringRef opName = "", const linalg::LinalgTilingAndFusionOptions &opt = {},
83  const linalg::LinalgTransformationFilter &filter =
84  linalg::LinalgTransformationFilter());
85 
86 /// Create a LinalgStrategyTilePass.
87 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyTilePass(
88  StringRef opName = "",
89  const linalg::LinalgTilingOptions &opt = linalg::LinalgTilingOptions(),
90  const linalg::LinalgTransformationFilter &filter =
91  linalg::LinalgTransformationFilter());
92 
93 /// Create a LinalgStrategyPadPass.
94 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyPadPass(
95  StringRef opName = "",
96  const linalg::LinalgPaddingOptions &opt = linalg::LinalgPaddingOptions(),
97  const linalg::LinalgTransformationFilter &filter =
98  linalg::LinalgTransformationFilter());
99 
100 /// Create a LinalgStrategyGeneralizePass.
101 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyGeneralizePass(
102  StringRef opName = "", const linalg::LinalgTransformationFilter &filter =
103  linalg::LinalgTransformationFilter());
104 
105 /// Create a LinalgStrategyDecomposePass.
106 // TODO: if/when we need finer control add an `opName` parameter.
107 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyDecomposePass(
108  const linalg::LinalgTransformationFilter &filter =
109  linalg::LinalgTransformationFilter());
110 
111 /// Create a LinalgStrategyInterchangePass.
112 std::unique_ptr<OperationPass<func::FuncOp>>
114  ArrayRef<int64_t> iteratorInterchange = {},
115  const linalg::LinalgTransformationFilter &filter =
116  linalg::LinalgTransformationFilter());
117 
118 /// Create a LinalgStrategyPeelPass.
119 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyPeelPass(
120  StringRef opName = "",
121  const linalg::LinalgPeelOptions &opt = linalg::LinalgPeelOptions(),
122  const linalg::LinalgTransformationFilter &filter =
123  linalg::LinalgTransformationFilter());
124 
125 /// Create a LinalgStrategyVectorizePass.
126 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyVectorizePass(
127  StringRef opName = "",
128  linalg::LinalgVectorizationOptions opt =
129  linalg::LinalgVectorizationOptions(),
130  const linalg::LinalgTransformationFilter &filter =
131  linalg::LinalgTransformationFilter(),
132  bool padVectorize = false);
133 
134 /// Create a LinalgStrategyEnablePass.
135 std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyEnablePass(
136  linalg::LinalgEnablingOptions opt = linalg::LinalgEnablingOptions(),
137  const linalg::LinalgTransformationFilter &filter =
138  linalg::LinalgTransformationFilter());
139 
140 /// Create a LinalgStrategyLowerVectorsPass.
141 std::unique_ptr<OperationPass<func::FuncOp>>
143  linalg::LinalgVectorLoweringOptions opt =
144  linalg::LinalgVectorLoweringOptions(),
145  const linalg::LinalgTransformationFilter &filter =
146  linalg::LinalgTransformationFilter());
147 
148 /// Create a LinalgStrategyRemoveMarkersPass.
149 std::unique_ptr<OperationPass<func::FuncOp>>
151 
152 //===----------------------------------------------------------------------===//
153 // Registration
154 //===----------------------------------------------------------------------===//
155 
156 /// Generate the code for registering passes.
157 #define GEN_PASS_REGISTRATION
158 #include "mlir/Dialect/Linalg/Passes.h.inc"
159 
160 } // namespace mlir
161 
162 #endif // MLIR_DIALECT_LINALG_PASSES_H_
Include the generated interface declarations.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyInterchangePass(ArrayRef< int64_t > iteratorInterchange={}, const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyInterchangePass.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyPeelPass(StringRef opName="", const linalg::LinalgPeelOptions &opt=linalg::LinalgPeelOptions(), const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyPeelPass.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyVectorizePass(StringRef opName="", linalg::LinalgVectorizationOptions opt=linalg::LinalgVectorizationOptions(), const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter(), bool padVectorize=false)
Create a LinalgStrategyVectorizePass.
std::unique_ptr< Pass > createLinalgElementwiseOpFusionPass()
std::unique_ptr< Pass > createFoldReshapeOpsByLinearizationPass()
std::unique_ptr< OperationPass< func::FuncOp > > createConvertLinalgToLoopsPass()
Create a pass to convert Linalg operations to scf.for loops and memref.load/memref.store accesses.
Definition: Loops.cpp:342
std::unique_ptr< OperationPass< func::FuncOp > > createConvertLinalgToParallelLoopsPass()
Create a pass to convert Linalg operations to scf.parallel loops and memref.load/memref.store accesses.
Definition: Loops.cpp:347
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyGeneralizePass(StringRef opName="", const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyGeneralizePass.
std::unique_ptr< OperationPass< func::FuncOp > > createConvertLinalgToAffineLoopsPass()
Create a pass to convert Linalg operations to affine.for loops and affine_load/affine_store accesses...
Definition: Loops.cpp:352
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgTilingPass(ArrayRef< int64_t > tileSizes={}, linalg::LinalgTilingLoopType loopType=linalg::LinalgTilingLoopType::Loops)
Definition: Tiling.cpp:788
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyLowerVectorsPass(linalg::LinalgVectorLoweringOptions opt=linalg::LinalgVectorLoweringOptions(), const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyLowerVectorsPass.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgGeneralizationPass()
Create a pass to convert named Linalg operations to Linalg generic operations.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyTileAndFusePass(StringRef opName="", const linalg::LinalgTilingAndFusionOptions &opt={}, const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Linalg strategy passes.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgBufferizePass()
Create a pass to convert Linalg operations which work on tensors to use buffers instead.
Definition: Bufferize.cpp:45
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyPadPass(StringRef opName="", const linalg::LinalgPaddingOptions &opt=linalg::LinalgPaddingOptions(), const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyPadPass.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyTilePass(StringRef opName="", const linalg::LinalgTilingOptions &opt=linalg::LinalgTilingOptions(), const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyTilePass.
LinalgTilingLoopType
The type of loops to be generated during tiling.
Definition: Utils.h:162
std::unique_ptr< Pass > createLinalgFoldUnitExtentDimsPass()
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgInlineScalarOperandsPass()
std::unique_ptr< Pass > createLinalgNamedOpConversionPass()
std::unique_ptr< Pass > createLinalgDetensorizePass()
Create a pass to convert Linalg operations to equivalent operations that work on primitive types...
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyEnablePass(linalg::LinalgEnablingOptions opt=linalg::LinalgEnablingOptions(), const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyEnablePass.
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyRemoveMarkersPass()
Create a LinalgStrategyRemoveMarkersPass.
std::unique_ptr< Pass > createConvertElementwiseToLinalgPass()
std::unique_ptr< OperationPass< func::FuncOp > > createLinalgStrategyDecomposePass(const linalg::LinalgTransformationFilter &filter=linalg::LinalgTransformationFilter())
Create a LinalgStrategyDecomposePass.
std::unique_ptr< Pass > createLinalgInitTensorToAllocTensorPass()
Create a pass that rewrites init_tensor to alloc_tensor.