MLIR
18.0.0git
|
#include "mlir/Dialect/SCF/Transforms/TileUsingInterface.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SCF/Utils/Utils.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
#include "mlir/Interfaces/TilingInterface.h"
#include "llvm/Support/Debug.h"
#include <optional>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "tile-using-interface" |
Functions | |
static SmallVector< int64_t > | fillInterchangeVector (ArrayRef< int64_t > interchangeVector, size_t iterationDomainSize) |
Helper method to adjust the interchange vector to match the iteration domain. More... | |
template<typename SrcOpTy > | |
static SmallVector< Operation * > | getAsOperations (ArrayRef< SrcOpTy > ops) |
Convert a list of ops of type SrcOpTy to list of Operation * . More... | |
template<typename SrcOpTy > | |
static SmallVector< Operation * > | getAsOperations (const SmallVector< SrcOpTy > &ops) |
template<typename DstOpTy > | |
static SmallVector< DstOpTy > | castToTypedOperations (ArrayRef< Operation * > ops) |
Convert a list of Operation * to a list of `DstOpTy. More... | |
template<typename DstOpTy > | |
static SmallVector< DstOpTy > | castToTypedOperations (const SmallVector< Operation * > &ops) |
static bool | tileDividesIterationDomain (Range loopRange) |
static OpFoldResult | getBoundedTileSize (OpBuilder &b, Location loc, Range loopRange, Value iv, OpFoldResult tileSize) |
Returns the bounded tile size given the current iv , loopRange and tileSize , i.e., min(tileSize, range.end() - iv) . More... | |
static Operation * | cloneOpAndUpdateDestinationArgs (RewriterBase &rewriter, Operation *op, ValueRange newDestArgs) |
Clones the operation and updates the destination if the operation implements the DestinationStyleOpInterface . More... | |
static SmallVector< scf::ForOp > | generateTileLoopNest (OpBuilder &builder, Location loc, ArrayRef< Range > loopRanges, ArrayRef< OpFoldResult > tileSizes, SmallVector< OpFoldResult > &offsets, SmallVector< OpFoldResult > &sizes, ValueRange destinationTensors={}) |
Generate an empty loop nest that represents the tiled loop nest shell. More... | |
static void | addInitOperandsToLoopNest (RewriterBase &rewriter, MutableArrayRef< scf::ForOp > loops, ValueRange newInitValues, llvm::function_ref< SmallVector< Value >(RewriterBase &rewriter, Value iv, ValueRange newRegionIterArgs)> getNewYieldValsFn) |
Method to add new init values to a loop nest. More... | |
static std::tuple< OpResult, std::optional< OpOperand * > > | getUntiledProducerFromSliceSource (OpOperand *source, ArrayRef< scf::ForOp > loops) |
Return the untiled producer whose slice is used in a tiled consumer. More... | |
#define DEBUG_TYPE "tile-using-interface" |
Definition at line 29 of file TileUsingInterface.cpp.
|
static |
Method to add new init values to a loop nest.
Updates loops
in-place with new loops that use the newInitValues
. The outer-loops are updated to yield the new result values of the inner loop. For the innermost loop, the call back getNewYields
is invoked to get the additional values to yield form the innermost loop.
Definition at line 205 of file TileUsingInterface.cpp.
References mlir::OpBuilder::create(), mlir::RewriterBase::mergeBlocks(), mlir::RewriterBase::replaceOp(), mlir::RewriterBase::replaceOpWithNewOp(), and mlir::OpBuilder::setInsertionPoint().
Referenced by mlir::scf::yieldReplacementForFusedProducer().
|
static |
Convert a list of Operation *
to a list of `DstOpTy.
Definition at line 72 of file TileUsingInterface.cpp.
|
static |
Definition at line 78 of file TileUsingInterface.cpp.
|
static |
Clones the operation and updates the destination if the operation implements the DestinationStyleOpInterface
.
Definition at line 127 of file TileUsingInterface.cpp.
Referenced by mlir::scf::tileAndFuseProducerOfSlice().
|
static |
Helper method to adjust the interchange vector to match the iteration domain.
Definition at line 46 of file TileUsingInterface.cpp.
|
static |
Generate an empty loop nest that represents the tiled loop nest shell.
loopRanges
specifies the lb, ub and step of the untiled iteration space.tileSizes
is the tile sizes to use. Zero represent untiled loops.offsets
and sizes
return the multi-dimensional offset and size of the tile processed within the inner most loop. Note that this methods adds scf.yield
operation for all but the innermost loop. These yield the value returned by the immediately inner loop. The caller is expected to add the scf.yield operation for the innermost loop. Definition at line 146 of file TileUsingInterface.cpp.
|
static |
Convert a list of ops of type SrcOpTy
to list of Operation *
.
Definition at line 60 of file TileUsingInterface.cpp.
Referenced by getAsOperations(), and mlir::scf::tileConsumerAndFuseProducerGreedilyUsingSCFForOp().
|
static |
Definition at line 66 of file TileUsingInterface.cpp.
References getAsOperations().
|
static |
Returns the bounded tile size given the current iv
, loopRange
and tileSize
, i.e., min(tileSize, range.end() - iv)
.
Definition at line 102 of file TileUsingInterface.cpp.
References mlir::bindDims(), mlir::bindSymbols(), mlir::AffineMap::get(), mlir::getConstantIntValue(), mlir::Builder::getContext(), mlir::getValueOrCreateConstantIndexOp(), mlir::affine::makeComposedFoldedAffineMin(), mlir::Range::offset, mlir::Range::size, and tileDividesIterationDomain().
|
static |
Return the untiled producer whose slice is used in a tiled consumer.
The method traverses the tile loop nest (loops
) if needed, and returns the iter_args
of the outer most that is encountered. Traversing the iter_args indicates that this is a destination operand of the consumer. If there was no loop traversal needed, the second value of the returned tuple is empty.
Definition at line 530 of file TileUsingInterface.cpp.
References mlir::IROperand< DerivedT, IRValueT >::get().
Referenced by mlir::scf::tileAndFuseProducerOfSlice().
|
static |
Definition at line 87 of file TileUsingInterface.cpp.
References mlir::getConstantIntValue(), mlir::Range::offset, mlir::Range::size, and mlir::Range::stride.
Referenced by getBoundedTileSize().