18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/SmallVector.h"
31 static TilingInterface
40 sizesCopy[dimension] = size;
41 offsetsCopy[dimension] = offset;
45 op.getTiledImplementation(b, offsetsCopy, sizesCopy);
48 for (
auto [index, result] :
llvm::enumerate(tilingResult->tiledValues)) {
50 if (
failed(op.getResultTilePosition(b, index, offsetsCopy, sizesCopy,
51 resultOffsets, resultSizes)))
56 loc, result, resultOperands[index], resultOffsets, resultSizes,
58 results.push_back(inserted);
61 assert(tilingResult->tiledOps.size() == 1 &&
62 "expected split part to return a single tiled operation");
63 return cast<TilingInterface>(tilingResult->tiledOps[0]);
66 std::pair<TilingInterface, TilingInterface>
73 if (dimension >= iterationSpace.size())
74 return std::make_pair(op, TilingInterface());
77 iterationSpace, [](
const Range &range) {
return range.
offset; }));
79 iterationSpace, [](
const Range &range) {
return range.
size; }));
87 {splitPoint, offsets[dimension], sizes[dimension]});
92 rewriter, op.
getLoc(), d0 + d1 - d2,
93 {iterationSpace[dimension].offset, iterationSpace[dimension].size,
95 if (
auto attr = llvm::dyn_cast_if_present<Attribute>(remainingSize)) {
96 if (cast<IntegerAttr>(attr).getValue().isZero())
97 return {op, TilingInterface()};
103 rewriter, op.
getLoc(), op, destinationTensors);
105 assert(
succeeded(destStatus) &&
"failed to get destination tensors");
110 rewriter, op.
getLoc(), op, offsets, sizes, destinationTensors, dimension,
111 minSplitPoint, iterationSpace[dimension].offset, firstResults);
118 unsigned numOutputOperands = firstResults.size();
119 op->
setOperands(numTotalOperands - numOutputOperands, numOutputOperands,
125 rewriter, op.
getLoc(), d0 + d1, {offsets[dimension], minSplitPoint});
127 TilingInterface secondPart =
129 dimension, remainingSize, totalOffset, secondResults);
132 if (!firstPart || !secondPart)
133 return {TilingInterface(), TilingInterface()};
137 return {firstPart, secondPart};
static TilingInterface createSplitPart(RewriterBase &b, Location loc, TilingInterface op, ArrayRef< OpFoldResult > offsets, ArrayRef< OpFoldResult > sizes, ValueRange resultOperands, unsigned dimension, OpFoldResult size, OpFoldResult offset, SmallVectorImpl< Value > &results)
Creates a part of the given op split along the iteration space dimension with the given size and an o...
Base type for affine expression.
static SmallVector< AffineMap, 4 > inferFromExprList(ArrayRef< ArrayRef< AffineExpr >> exprsList)
Returns a vector of AffineMaps; each with as many results as exprs.size(), as many dims as the larges...
IntegerAttr getIndexAttr(int64_t value)
MLIRContext * getContext() const
This class provides support for representing a failure result, or a valid value of type T.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
This class represents a single result from folding an operation.
Location getLoc()
The source location the operation was defined or derived from.
unsigned getNumOperands()
void setOperands(ValueRange operands)
Replace the current operands of this operation with the ones provided in 'operands'.
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
virtual void replaceOp(Operation *op, ValueRange newValues)
This method replaces the results of the operation with the specified list of values.
void updateRootInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around a root update of an operation.
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...
OpFoldResult makeComposedFoldedAffineMin(OpBuilder &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > operands)
Constructs an AffineMinOp that computes a minimum across the results of applying map to operands,...
OpFoldResult makeComposedFoldedAffineApply(OpBuilder &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > operands)
Constructs an AffineApplyOp that applies map to operands after composing the map with the maps of any...
constexpr void enumerate(std::tuple< Tys... > &tuple, CallbackT &&callback)
std::pair< TilingInterface, TilingInterface > splitOp(RewriterBase &rewriter, TilingInterface op, unsigned dimension, OpFoldResult splitPoint)
Split the given op into two parts along the given iteration space dimension at the specified splitPoi...
LogicalResult getOrCreateDestinations(OpBuilder &b, Location loc, Operation *op, SmallVector< Value > &result)
This is a helper function for DestinationStyleOpInterface.
Include the generated interface declarations.
void bindDims(MLIRContext *ctx, AffineExprTy &...exprs)
Bind a list of AffineExpr references to DimExpr at positions: [0 .
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...