MLIR: include/mlir/Dialect/Affine/LoopUtils.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef MLIR_DIALECT_AFFINE_LOOPUTILS_H
16#define MLIR_DIALECT_AFFINE_LOOPUTILS_H
17
21#include
22
23namespace mlir {
25class LoopLikeOpInterface;
29
33
34namespace scf {
35class ForOp;
36class ParallelOp;
37}
38
39namespace affine {
40class AffineForOp;
41struct MemRefRegion;
42
43
44
46
47
48
49
50
51
52
54 AffineForOp forOp, uint64_t unrollFactor,
55 function_ref<void(unsigned, Operation *, OpBuilder)> annotateFn = nullptr,
56 bool cleanUpUnroll = false);
57
58
59
61
62
63
64[[maybe_unused]] bool isPerfectlyNested(ArrayRef loops);
65
66
67
68
69
71 AffineForOp root);
72
73
74
75
76
78 uint64_t unrollJamFactor);
79
80
81
83 uint64_t unrollJamFactor);
84
85
86
88
89
90
92
93
94
95
96
97
99 bool unrollPrologueEpilogue = false);
100
101
102
103
104LogicalResult
108
109
110
111
115
116
117
118void interchangeLoops(AffineForOp forOpA, AffineForOp forOpB);
119
120
121
122
125
126
127
128
129
130
131
132
135
136
137
138
139
141
142
143
144
145
146
150
151
152
153
154
157
158
160
162
164
166
168
170};
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
188 std::optional filterMemRef,
190
191
192
193LogicalResult affineDataCopyGenerate(AffineForOp forOp,
195 std::optional filterMemRef,
197
198
199struct CopyGenerateResult {
200
201 uint64_t sizeInBytes;
202
203
205
206
207
209};
210
211
212
213
214
215
216
217
218
219
220
221LogicalResult generateCopyForMemRegion(const MemRefRegion &memrefRegion,
223 const AffineCopyOptions ©Options,
224 CopyGenerateResult &result);
225
226
227
228
229
230
231
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265void mapLoopToProcessorIds(scf::ForOp forOp, ArrayRef processorId,
267
268
269void gatherLoops(func::FuncOp func,
271
272
273
274
280
281
282
283
284
285
286
287
288
289
290
291LogicalResult
294
295
296LogicalResult coalescePerfectlyNestedAffineLoops(AffineForOp op);
297
298
299
300
301
303}
304}
305
306#endif
b
Return true if permutation is a valid permutation of the outer_dims_perm (case OuterOrInnerPerm::Oute...
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
OpListType::iterator iterator
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
LogicalResult loopUnrollFull(AffineForOp forOp)
Unrolls this for operation completely if the trip count is known to be constant.
LogicalResult promoteIfSingleIteration(AffineForOp forOp)
Promotes the loop body of a AffineForOp to its containing block if the loop was known to have a singl...
LogicalResult loopUnrollJamUpToFactor(AffineForOp forOp, uint64_t unrollJamFactor)
Unrolls and jams this loop by the specified factor or by the trip count (if constant),...
LogicalResult loopUnrollByFactor(AffineForOp forOp, uint64_t unrollFactor, function_ref< void(unsigned, Operation *, OpBuilder)> annotateFn=nullptr, bool cleanUpUnroll=false)
Unrolls this for operation by the specified unroll factor.
void getPerfectlyNestedLoops(SmallVectorImpl< AffineForOp > &nestedLoops, AffineForOp root)
Get perfectly nested sequence of loops starting at root of loop nest (the first op being another Affi...
LogicalResult affineForOpBodySkew(AffineForOp forOp, ArrayRef< uint64_t > shifts, bool unrollPrologueEpilogue=false)
Skew the operations in an affine.for's body with the specified operation-wise shifts.
bool isValidLoopInterchangePermutation(ArrayRef< AffineForOp > loops, ArrayRef< unsigned > loopPermMap)
Checks if the loop interchange permutation 'loopPermMap', of the perfectly nested sequence of loops i...
LogicalResult loopUnrollUpToFactor(AffineForOp forOp, uint64_t unrollFactor)
Unrolls this loop by the specified unroll factor or its trip count, whichever is lower.
unsigned permuteLoops(ArrayRef< AffineForOp > inputNest, ArrayRef< unsigned > permMap)
Performs a loop permutation on a perfectly nested loop nest inputNest (where the contained loops appe...
LogicalResult loopUnrollJamByFactor(AffineForOp forOp, uint64_t unrollJamFactor)
Unrolls and jams this loop by the specified factor.
LogicalResult tilePerfectlyNestedParametric(MutableArrayRef< AffineForOp > input, ArrayRef< Value > tileSizes, SmallVectorImpl< AffineForOp > *tiledNest=nullptr)
Tiles the specified band of perfectly nested loops creating tile-space loops and intra-tile loops,...
bool isPerfectlyNested(ArrayRef< AffineForOp > loops)
Returns true if loops is a perfectly nested loop nest, where loops appear in it from outermost to inn...
void promoteSingleIterationLoops(func::FuncOp f)
Promotes all single iteration AffineForOp's in the Function, i.e., moves their body into the containi...
int64_t numEnclosingInvariantLoops(OpOperand &operand)
Performs explicit copying for the contiguous sequence of operations in the block iterator range [‘beg...
SmallVector< SmallVector< AffineForOp, 8 >, 8 > tile(ArrayRef< AffineForOp > forOps, ArrayRef< uint64_t > sizes, ArrayRef< AffineForOp > targets)
Performs tiling fo imperfectly nested loops (with interchange) by strip-mining the forOps by sizes an...
AffineForOp sinkSequentialLoops(AffineForOp forOp)
LogicalResult tilePerfectlyNested(MutableArrayRef< AffineForOp > input, ArrayRef< unsigned > tileSizes, SmallVectorImpl< AffineForOp > *tiledNest=nullptr)
Tiles the specified band of perfectly nested loops creating tile-space loops and intra-tile loops.
void interchangeLoops(AffineForOp forOpA, AffineForOp forOpB)
Performs loop interchange on 'forOpA' and 'forOpB'.
Definition LoopUtils.h:30
Include the generated interface declarations.
llvm::DenseSet< ValueT, ValueInfoT > DenseSet
LogicalResult coalesceLoops(MutableArrayRef< scf::ForOp > loops)
Replace a perfect nest of "for" loops with a single linearized loop.
llvm::function_ref< Fn > function_ref
Explicit copy / DMA generation options for mlir::affineDataCopyGenerate.
Definition LoopUtils.h:159
unsigned tagMemorySpace
Definition LoopUtils.h:167
uint64_t fastMemCapacityBytes
Definition LoopUtils.h:169
unsigned fastMemorySpace
Definition LoopUtils.h:165
unsigned slowMemorySpace
Definition LoopUtils.h:163
bool generateDma
Definition LoopUtils.h:161