MLIR  16.0.0git
FusionOnTensors.cpp
Go to the documentation of this file.
1 //===- FusionOnTensors.cpp - Implementation of linalg Fusion --------------===//
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 file implements linalg fusion on tensors
10 //
11 //===----------------------------------------------------------------------===//
12 
21 #include "mlir/IR/AffineExpr.h"
22 #include "mlir/IR/AffineMap.h"
23 #include "mlir/Support/LLVM.h"
24 
25 using namespace mlir;
26 using namespace linalg;
27 
28 //===----------------------------------------------------------------------===//
29 // StructuredOp specific helpers.
30 //===----------------------------------------------------------------------===//
31 
32 /// Returns the tiled slice dimensions given the tiled consumer loop dimensions.
33 /// The slice defines a hyper rectangular iteration space and fusing the
34 /// producer is always possible. However, depending on the consumer indexing
35 /// map, not all slice elements may be consumed and the tiles may overlap. In
36 /// these cases, fusion introduces redundant computation.
38  ArrayRef<int64_t> tiledLoopDims) {
39  // Get the consumer operand indexing map.
40  LinalgOp consumerOp = consumerOperand->getOwner();
41  AffineMap indexingMap = consumerOp.getMatchingIndexingMap(consumerOperand);
42 
43  // Search the slice dimensions tiled by a tile loop dimension.
44  DenseSet<int64_t> tiledSliceDimIndices;
45  for (const auto &en : enumerate(indexingMap.getResults())) {
46  for (auto tiledLoopDim : tiledLoopDims) {
47  if (en.value().isFunctionOfDim(tiledLoopDim))
48  tiledSliceDimIndices.insert(en.index());
49  }
50  }
51  return {tiledSliceDimIndices.begin(), tiledSliceDimIndices.end()};
52 }
53 
54 /// Given a vector of `tiledSliceDimIndices` that represent the tiled dimensions
55 /// of the producer result slice returns the tiled producer loop dimensions.
56 /// Example:
57 /// ```
58 /// %res = linalg.fill(%cst, %input)
59 /// scf.for %i
60 /// scf.for %j
61 /// %slice = tensor.extract_slice %res[%i, %j]
62 /// ```
63 /// getTiledProducerLoops(%res, [0, 1]) returns the loop indices [0, 1].
66  ArrayRef<int64_t> tiledSliceDimIndices) {
67  LinalgOp producerOp = producerResult.getOwner();
68 
69  // Get the indexing map of the `producerOp` output operand that matches
70  // ┬┤producerResult┬┤.
71  AffineMap producerIndexingMap = producerOp.getMatchingIndexingMap(
72  producerOp.getDpsInitOperand(producerResult.getResultNumber()));
73 
74  // Keep only the tiled result slice dimensions of `producerIndexingMap`.
75  AffineMap tiledProducerIndexingSubMap =
76  producerIndexingMap.getSubMap(SmallVector<unsigned>(
77  tiledSliceDimIndices.begin(), tiledSliceDimIndices.end()));
78 
79  // Compute the producer loop indices mapped to the tiled result slice
80  // dimensions. As the output indexing map of structured operations are
81  // projected permutations, `tiledProducerIndexingSubMap` has to be a
82  // projected permutation as well. We can thus obtain the producer loop indices
83  // by getting the positions of the result dimensions.
84  // Example:
85  // (d0, d1, d2) -> (d0, d2) has the result positions [0, 2].
86  assert(tiledProducerIndexingSubMap.isProjectedPermutation() &&
87  "expect slice and producer loop dimensions map one-to-one");
88  SmallVector<int64_t> tiledProducerLoopIndices;
89  llvm::transform(
90  llvm::seq<unsigned>(0, tiledProducerIndexingSubMap.getNumResults()),
91  std::back_inserter(tiledProducerLoopIndices), [&](unsigned idx) {
92  return tiledProducerIndexingSubMap.getDimPosition(idx);
93  });
94 
95  return tiledProducerLoopIndices;
96 }
97 
98 /// Returns the producer fused in place of `sliceOp`. Tile the producer operands
99 /// along the `tiledSliceDimIndices` and clone the producer. Consider the case
100 /// of fusion of an output tensor:
101 /// ```
102 /// %1 = producer ins(...) outs(%0)
103 /// %2 = consumer ins(...) outs(%1)
104 /// ```
105 /// When consumer is tiled, %1 appears in the loop iter_args:
106 /// ```
107 /// %1 = producer ins(...) outs(%0)
108 /// %2 = scf.for ... iter_args(%1) .. (%bbarg) {
109 /// %t1 = tensor.extract_slice %bbarg[..]
110 /// %t2 = consumer ins(...) outs(%t1)
111 /// %r = tensor.insert_slice %t2, %bbarg[...]
112 /// }
113 /// ```
114 /// Fusing %1 into the loop requires updating iter_args(%1) to iter_args(%0):
115 /// ```
116 /// %2 = scf.for ... iter_args(%0) .. (%bbarg) {
117 /// %t0 = tensor.extract_slice %bbarg[..]
118 /// %t1 = producer ins(...) outs(%t0)
119 /// %t2 = consumer ins(...) outs(%t1)
120 /// %r = tensor.insert_slice %t2, %bbarg[...]
121 /// }
122 /// ```
123 /// This transformation is only valid if %bbarg is exclusively used by the
124 /// output ExtractSliceOp / InsertSliceOp pair, which is checked by the
125 /// `fuseProducer` method.
126 /// TODO: instead of check and failure, insert new iter_args each time a
127 /// producer is fused into a consumer and fold away unused iter_args.
128 static LinalgOp getTiledProducer(OpBuilder &b, OpResult producerResult,
129  tensor::ExtractSliceOp sliceOp,
130  ArrayRef<int64_t> tiledSliceDimIndices,
131  ArrayRef<int64_t> tiledProducerLoopIndices,
132  OpOperand *iterArg) {
133  // Clone the producer after `sliceOp` since the slice may be reused to pass in
134  // the producer result.
135  OpBuilder::InsertionGuard guard(b);
136  b.setInsertionPointAfter(sliceOp);
137 
138  // Get the producer.
139  LinalgOp producerOp = producerResult.getOwner();
140  Location loc = producerOp.getLoc();
141 
142  // Obtain the `producerOp` loop bounds and the `sliceOp` ranges.
143  SmallVector<OpFoldResult> producerLoopBounds;
144  llvm::transform(producerOp.createLoopRanges(b, loc),
145  std::back_inserter(producerLoopBounds),
146  [&](Range range) { return range.size; });
147  SmallVector<Range> sliceOpRanges = sliceOp.getOrCreateRanges(b, loc);
148 
149  // Tile the producer operands given the `sliceOp` ranges. Iterate the
150  // `tiledSliceDimIndices` and store the tile offset and size for the tiled
151  // slice dimension.
152  SmallVector<OpFoldResult> tileIvs(producerOp.getNumLoops(), nullptr);
153  SmallVector<OpFoldResult> tileSizes(producerOp.getNumLoops(),
154  b.getIndexAttr(0));
155  SmallVector<OpFoldResult> allIvs(producerOp.getNumLoops(), nullptr);
156  for (auto it : zip(tiledSliceDimIndices, tiledProducerLoopIndices)) {
157  int64_t tiledSliceDim = std::get<0>(it);
158  int64_t tiledProducerLoop = std::get<1>(it);
159  tileIvs[tiledProducerLoop] = sliceOpRanges[tiledSliceDim].offset;
160  tileSizes[tiledProducerLoop] = sliceOpRanges[tiledSliceDim].size;
161  allIvs[tiledProducerLoop] = tileIvs[tiledProducerLoop];
162  }
163  erase_value(tileIvs, OpFoldResult());
164  SmallVector<Value> tiledOperands = producerOp->getOperands();
165  tiledOperands = makeTiledShapes(b, loc, producerOp, tiledOperands, tileIvs,
166  tileSizes, producerLoopBounds,
167  /**omitPartialTileCheck=*/false);
168 
169  // Output fusion has to update the iteration arguments of the tile loop nest.
170  // In particular, the iteration argument of the outermost tile loop needs to
171  // be set to the producer output instead of the producer result and `clonedOp`
172  // shall use the existing `sliceOp` result instead of the tiled producer
173  // output operand.
174  if (iterArg) {
175  OpOperand *outputOperand =
176  producerOp.getDpsInitOperand(producerResult.getResultNumber());
177  iterArg->set(outputOperand->get());
178  tiledOperands[outputOperand->getOperandNumber()] = sliceOp.getResult();
179  }
180 
181  // Clone the producer using the tiled producer operands.
182  TypeRange resultTypes = ValueRange(tiledOperands)
183  .take_back(producerOp.getNumDpsInits())
184  .getTypes();
185  LinalgOp clonedOp = clone(b, producerOp, resultTypes, tiledOperands);
186 
187  // Shift all IndexOp results by the tile offset.
188  offsetIndices(b, clonedOp, allIvs);
189 
190  return clonedOp;
191 }
192 
193 //===----------------------------------------------------------------------===//
194 // TileLoopNest specific helpers.
195 //===----------------------------------------------------------------------===//
196 
197 bool TileLoopNest::isEmpty() { return tileLoopOps.empty(); }
198 
199 bool TileLoopNest::isValid() {
200  // Check if `rootOp` has been tiled at least once.
201  if (isEmpty() || tiledRootAndFusedOpsLoops.count(rootOp) == 0)
202  return false;
203 
204  // Check if the number of loop operations and dimensions match.
205  if (tileLoopOps.size() != tiledRootAndFusedOpsLoops[rootOp].size())
206  return false;
207 
208  // Check if the innermost tile loop is the parent of `tiledOp`.
209  if (rootOp->getParentOp() != tileLoopOps.back())
210  return false;
211 
212  // Check if the tile loops are directly nested.
213  return std::adjacent_find(tileLoopOps.begin(), tileLoopOps.end(),
214  [](Operation *op1, Operation *op2) {
215  return op1 != op2->getParentOp();
216  }) == tileLoopOps.end();
217 }
218 
219 SmallVector<BlockArgument> TileLoopNest::getTiedBBArgs(BlockArgument bbArg) {
220  assert(bbArg && "expect the block argument to be non-zero");
222 
223  // Search all tile loop block arguments from inner to outer.
224  for (auto tileLoop : reverse(tileLoopOps)) {
225  if (bbArg.getOwner()->getParentOp() != tileLoop)
226  return {};
227  bbArgs.push_back(bbArg);
228  OpOperand *iterArg = &tileLoop.getOpOperandForRegionIterArg(bbArg);
229  bbArg = iterArg->get().dyn_cast<BlockArgument>();
230  }
231 
232  // Reverse the block arguments to order them from outer to inner.
233  return {bbArgs.rbegin(), bbArgs.rend()};
234 }
235 
236 OpOperand *TileLoopNest::getTiedIterArg(BlockArgument bbArg) {
237  // Search all block arguments and return the matching iteration argument.
238  SmallVector<BlockArgument> bbArgs = getTiedBBArgs(bbArg);
239  if (bbArgs.size() != tileLoopOps.size())
240  return nullptr;
241  return &tileLoopOps.front().getOpOperandForRegionIterArg(bbArgs.front());
242 }
243 
244 bool TileLoopNest::hasOtherUses(BlockArgument bbArg,
245  tensor::ExtractSliceOp sliceOp) {
246  // Check the innermost block argument is either used by the ExtractSliceOp
247  // `sliceOp`, the matching InsertSliceOp, or by a DimOp. Handle other uses
248  // conservatively.
249  for (Operation *op : bbArg.getUsers()) {
250  if (!isa<tensor::DimOp, tensor::InsertSliceOp, tensor::ExtractSliceOp>(op))
251  return false;
252  if (auto extractSliceOp = dyn_cast<tensor::ExtractSliceOp>(op)) {
253  if (extractSliceOp != sliceOp)
254  return false;
255  }
256  if (auto insertSliceOp = dyn_cast<tensor::InsertSliceOp>(op)) {
257  SetVector<Operation *> backwardSlice;
258  getBackwardSlice(insertSliceOp.getSource(), &backwardSlice,
259  [](Operation *op) {
260  return isa<LinalgOp, tensor::InsertSliceOp>(op);
261  });
262  if (backwardSlice.empty() || backwardSlice.front() != sliceOp)
263  return false;
264  }
265  }
266 
267  // Check the block arguments, except for the innermost one, have one use.
268  SmallVector<BlockArgument> bbArgs = getTiedBBArgs(bbArg);
269  return !all_of(bbArgs, [&](BlockArgument bbArg) {
270  return bbArg.hasOneUse() || bbArg == bbArgs.back();
271  });
272 }
273 
275  OpBuilder &b, ArrayRef<int64_t> tileSizes,
276  ArrayRef<int64_t> tileInterchange,
277  Optional<LinalgLoopDistributionOptions> tileDistribution) {
278  // Exit if all tile sizes are zero.
279  if (tileSizes.size() == static_cast<size_t>(count(tileSizes, 0)))
280  return success();
281 
282  // Tile the root operation.
283  LinalgTilingOptions tilingOptions;
284  tilingOptions = tilingOptions
286  tileInterchange.begin(), tileInterchange.end()))
287  .setTileSizes(tileSizes)
289  if (tileDistribution)
290  tilingOptions = tilingOptions.setDistributionOptions(*tileDistribution);
291 
292  // TODO: Propagate RewriterBase everywhere.
293  IRRewriter rewriter(b);
294  FailureOr<TiledLinalgOp> tiledRootOp =
295  tileLinalgOp(rewriter, rootOp, tilingOptions);
296 
297  // Exit if tiling the root operation fails.
298  if (failed(tiledRootOp))
299  return failure();
300 
301  // Replace all uses of the root operation if it has been tiled before. All
302  // uses of the original untiled root operation are updated by the calling pass
303  // or pattern.
304  if (!isEmpty())
305  rootOp->replaceAllUsesWith(tiledRootOp->tensorResults);
306 
307  // Transfer the stored `rootOp` loop dimensions if it has been tiled before.
308  if (tiledRootAndFusedOpsLoops.count(rootOp) != 0) {
309  tiledRootAndFusedOpsLoops[tiledRootOp->op] =
310  tiledRootAndFusedOpsLoops[rootOp];
311  }
312 
313  // Update the root operation and append the loops and tile loop dimensions.
314  rootOp = tiledRootOp->op;
315  tileLoopOps.append(tiledRootOp->loops.begin(), tiledRootOp->loops.end());
316  for (const auto &en : enumerate(tileSizes)) {
317  // Copy only the tiled loop dimensions with non-zero tile size.
318  if (en.value() == 0)
319  continue;
320  tiledRootAndFusedOpsLoops[rootOp].push_back(tileInterchange[en.index()]);
321  }
322  assert(isValid() && "expect tile loop nest to be valid after tiling");
323  return success();
324 }
325 
327  OpOperand *consumerOpOperand) {
328  // Check if the consumer has been tiled before. For example, it may not have
329  // been tiled if the outermost tile loop is a reduction loop.
330  if (tiledRootAndFusedOpsLoops.count(consumerOpOperand->getOwner()) == 0)
331  return failure();
332 
333  assert(this->isValid() &&
334  "expect the tile loop nest to satisfy all invariants");
335 
336  // Check the tile loop nest is non-empty.
337  if (isEmpty())
338  return failure();
339 
340  // Check `consumerOpOperand` is defined by an ExtractSliceOp.
341  auto sliceOp =
342  consumerOpOperand->get().getDefiningOp<tensor::ExtractSliceOp>();
343  if (!sliceOp)
344  return failure();
345 
346  // Check `sliceOp` and `consumerOp` are in the same block.
347  LinalgOp consumerOp = consumerOpOperand->getOwner();
348  if (sliceOp->getBlock() != rootOp->getBlock() ||
349  consumerOp->getBlock() != rootOp->getBlock())
350  return failure();
351 
352  // Check `consumerOpOperand` is not shape-only to avoid fusion if the data is
353  // not used by the `consumerOp` computation.
354  BlockArgument bbArg = consumerOp.getMatchingBlockArgument(consumerOpOperand);
355  if (bbArg.getUses().empty())
356  return failure();
357 
358  // Check if the producer is a LinalgOp possibly passed by iteration argument.
359  OpOperand *iterArg = nullptr;
360  auto producerResult = sliceOp.getSource().dyn_cast<OpResult>();
361  if (auto bbArg = sliceOp.getSource().dyn_cast<BlockArgument>()) {
362  iterArg = getTiedIterArg(bbArg);
363  // Check the iteration argument may be used to pass in the producer output.
364  if (!iterArg || hasOtherUses(bbArg, sliceOp))
365  return failure();
366  producerResult = iterArg->get().dyn_cast<OpResult>();
367  }
368  if (!producerResult || !isa<LinalgOp>(producerResult.getOwner()))
369  return failure();
370 
371  // Compute the tiled producer slice dimensions given the tiled consumer loops.
372  SmallVector<int64_t> tiledSliceDimIndices = getTiledSliceDims(
373  consumerOpOperand, tiledRootAndFusedOpsLoops[consumerOp]);
374  if (tiledSliceDimIndices.empty())
375  return failure();
376 
377  // Compute the tiled producer loop indices.
378  SmallVector<int64_t> tiledProducerLoopIndices =
379  getTiledProducerLoops(producerResult, tiledSliceDimIndices);
380 
381  // Tile the producer operands and clone the producer in place of `sliceOp`.
382  LinalgOp clonedOp =
383  getTiledProducer(b, producerResult, sliceOp, tiledSliceDimIndices,
384  tiledProducerLoopIndices, iterArg);
385  tiledRootAndFusedOpsLoops[clonedOp] = tiledProducerLoopIndices;
386 
387  // Cast the `clonedOp` result to gap type mismatches before canonicalization.
388  Type consumerOperandType = consumerOpOperand->get().getType();
389  Value newResult = clonedOp->getResult(producerResult.getResultNumber());
390  if (newResult.getType() != consumerOperandType) {
391  OpBuilder::InsertionGuard guard(b);
392  b.setInsertionPointAfter(clonedOp);
393  newResult = b.create<tensor::CastOp>(producerResult.getLoc(),
394  consumerOperandType, newResult);
395  }
396 
397  // Replace the `sliceOp` uses except for the `clonedOp` output uses.
398  sliceOp.getResult().replaceAllUsesExcept(newResult, clonedOp);
399  return clonedOp;
400 }
401 
403  assert(!isEmpty() && "expect tile loop nest to be non-empty");
404  return tileLoopOps.front()->getOpResults();
405 }
406 
408  SmallVector<LinalgOp> result;
409  for (const auto &kvp : tiledRootAndFusedOpsLoops) {
410  auto linalgOp = dyn_cast<LinalgOp>(kvp.getFirst());
411  assert(linalgOp &&
412  "expect all tiled and fused operations are linalg operations");
413  result.push_back(linalgOp);
414  }
415  return result;
416 }
static LinalgOp getTiledProducer(OpBuilder &b, OpResult producerResult, tensor::ExtractSliceOp sliceOp, ArrayRef< int64_t > tiledSliceDimIndices, ArrayRef< int64_t > tiledProducerLoopIndices, OpOperand *iterArg)
Returns the producer fused in place of sliceOp.
static SmallVector< int64_t > getTiledSliceDims(OpOperand *consumerOperand, ArrayRef< int64_t > tiledLoopDims)
Returns the tiled slice dimensions given the tiled consumer loop dimensions.
static SmallVector< int64_t > getTiledProducerLoops(OpResult producerResult, ArrayRef< int64_t > tiledSliceDimIndices)
Given a vector of tiledSliceDimIndices that represent the tiled dimensions of the producer result sli...
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
Definition: AffineMap.h:42
bool isProjectedPermutation(bool allowZeroInResults=false) const
Returns true if the AffineMap represents a subset (i.e.
Definition: AffineMap.cpp:494
ArrayRef< AffineExpr > getResults() const
Definition: AffineMap.cpp:319
unsigned getNumResults() const
Definition: AffineMap.cpp:314
AffineMap getSubMap(ArrayRef< unsigned > resultPos) const
Returns the map consisting of the resultPos subset.
Definition: AffineMap.cpp:530
This class represents an argument of a Block.
Definition: Value.h:296
Block * getOwner() const
Returns the block that owns this argument.
Definition: Value.h:305
Operation * getParentOp()
Returns the closest surrounding operation that contains this block.
Definition: Block.cpp:30
IntegerAttr getIndexAttr(int64_t value)
Definition: Builders.cpp:109
This class provides support for representing a failure result, or a valid value of type T.
Definition: LogicalResult.h:78
IRValueT get() const
Return the current value being used by this operand.
Definition: UseDefLists.h:137
void set(IRValueT newValue)
Set the current value being used by this operand.
Definition: UseDefLists.h:140
This class coordinates rewriting a piece of IR outside of a pattern rewrite, providing a way to keep ...
Definition: PatternMatch.h:594
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:64
RAII guard to reset the insertion point of the builder when destroyed.
Definition: Builders.h:300
This class helps build Operations.
Definition: Builders.h:198
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
Definition: Builders.cpp:422
void setInsertionPointAfter(Operation *op)
Sets the insertion point to the node after the specified operation, which will cause subsequent inser...
Definition: Builders.h:364
This class represents a single result from folding an operation.
Definition: OpDefinition.h:233
This class represents an operand of an operation.
Definition: Value.h:247
unsigned getOperandNumber()
Return which operand this is in the OpOperand list of the Operation.
Definition: Value.cpp:212
This is a value defined by a result of an operation.
Definition: Value.h:442
Operation * getOwner() const
Returns the operation that owns this result.
Definition: Value.h:451
unsigned getResultNumber() const
Returns the number of this result.
Definition: Value.h:454
Operation is a basic unit of execution within MLIR.
Definition: Operation.h:31
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Definition: Operation.h:324
This class provides an abstraction over the various different ranges of value types.
Definition: TypeRange.h:36
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
This class provides an abstraction over the different types of ranges over Values.
Definition: ValueRange.h:349
type_range getTypes() const
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition: Value.h:85
Type getType() const
Return the type of this value.
Definition: Value.h:114
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
Definition: Value.h:193
void replaceAllUsesExcept(Value newValue, const SmallPtrSetImpl< Operation * > &exceptions) const
Replace all uses of 'this' value with 'newValue', updating anything in the IR that uses 'this' to use...
Definition: Value.cpp:61
U dyn_cast() const
Definition: Value.h:95
user_range getUsers() const
Definition: Value.h:209
bool hasOneUse() const
Returns true if this value has exactly one use.
Definition: Value.h:196
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Definition: Value.cpp:20
Operation * getOwner() const
Return the owner of this operand.
Definition: UseDefLists.h:40
LogicalResult tileRootOp(OpBuilder &b, ArrayRef< int64_t > tileSizes, ArrayRef< int64_t > tileInterchange, Optional< LinalgLoopDistributionOptions > tileDistribution)
Tile the root operation using the given tileSizes and tileInterchange, and tileDistribution.
ValueRange getRootOpReplacementResults()
Returns the replacement results for the original untiled root operation.
SmallVector< LinalgOp > getAllTiledAndFusedOps()
Returns the tiled root operation and the fused producers.
FailureOr< LinalgOp > fuseProducer(OpBuilder &b, OpOperand *consumerOpOperand)
Fuse the producer of consumerOpOperand into the tile loop nest.
bool isEmpty()
Returns true if the tile loop nest has no tile loops.
constexpr void enumerate(std::tuple< Tys... > &tuple, CallbackT &&callback)
Definition: Matchers.h:230
SmallVector< Value > makeTiledShapes(OpBuilder &builder, Location loc, LinalgOp linalgOp, ValueRange valuesToTile, ArrayRef< OpFoldResult > ivs, ArrayRef< OpFoldResult > tileSizes, ArrayRef< OpFoldResult > sizeBounds, bool omitPartialTileCheck)
Creates extract_slice/subview ops for all valuesToTile of the given linalgOp with builder,...
Definition: Utils.cpp:984
void offsetIndices(OpBuilder &b, LinalgOp linalgOp, ArrayRef< OpFoldResult > offests)
Add the specified offsets to any linalg.index ops contained in the given linalgOp.
Definition: Utils.cpp:1005
FailureOr< TiledLinalgOp > tileLinalgOp(RewriterBase &b, LinalgOp op, const LinalgTilingOptions &options)
Definition: Tiling.cpp:747
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
Definition: LogicalResult.h:62
void getBackwardSlice(Operation *op, SetVector< Operation * > *backwardSlice, TransitiveFilter filter=nullptr)
Fills backwardSlice with the computed backward slice (i.e.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
Definition: LogicalResult.h:56
Operation * clone(OpBuilder &b, Operation *op, TypeRange newResultTypes, ValueRange newOperands)
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
Definition: LogicalResult.h:72
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26
Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...
LinalgTilingOptions & setLoopType(LinalgTilingLoopType lt)
Definition: Transforms.h:651
LinalgTilingOptions & setInterchange(ArrayRef< unsigned > interchange)
Definition: Transforms.h:643
LinalgTilingOptions & setTileSizes(const SmallVector< Value, 4 > &ts)
Set the tileSizeComputationFunction to return the values ts.
Definition: Transforms.h:627
LinalgTilingOptions & setDistributionOptions(LinalgLoopDistributionOptions distributionOptions)
Definition: Transforms.h:661