MLIR
17.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"
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... | |
static bool | tileDividesIterationDomain (Range loopRange) |
static OpFoldResult | getBoundedTileSize (OpBuilder &b, Location loc, Range loopRange, Value iv, Value tileSize) |
Returns the bounded tile size given the current iv , loopRange and tileSize , i.e., min(tileSize, range.end() - iv) . More... | |
static SmallVector< scf::ForOp > | generateTileLoopNest (OpBuilder &builder, Location loc, ArrayRef< Range > loopRanges, ArrayRef< Value > tileSizeVals, SmallVector< OpFoldResult > &offsets, SmallVector< OpFoldResult > &sizes) |
Generate an empty loop nest that represents the tiled loop nest shell. More... | |
static SmallVector< Value > | yieldTiledValues (RewriterBase &rewriter, ValueRange initValues, ValueRange yieldedValues, ArrayRef< SmallVector< OpFoldResult >> tileOffsetsList, ArrayRef< SmallVector< OpFoldResult >> tileSizesList, MutableArrayRef< scf::ForOp > loops) |
For a value to be yielded (yieldedValue ) from within a loop nest loops , construct the destructive update pattern that inserts the yielded value into a destination tensor provided by initValue at offset tileOffsets and size tileSizes . More... | |
static void | updateDestinationOperandsForTiledOp (OpBuilder &builder, ValueRange tiledOpDestinationValues, ValueRange bbArgsList) |
If the tiled operation is destination passing style, update the slice of the destination used (which refers to the untiled destination) to use the corresponding region argument of the innermost loop. More... | |
static SmallVector< Value > | yieldTiledValues (RewriterBase &rewriter, ArrayRef< Value > initValues, Operation *tiledOp, ArrayRef< SmallVector< OpFoldResult >> tileOffsetsList, ArrayRef< SmallVector< OpFoldResult >> tileSizesList, MutableArrayRef< scf::ForOp > loops) |
Helper method to yield the values of the tiled op, as well as update the destination operands of the tiled op, if it is a destination passing style op. 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 28 of file TileUsingInterface.cpp.
|
static |
Helper method to adjust the interchange vector to match the iteration domain.
Definition at line 51 of file TileUsingInterface.cpp.
Referenced by mlir::scf::tileUsingSCFForOp().
|
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.tileSizeVals
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. Definition at line 113 of file TileUsingInterface.cpp.
References mlir::OpBuilder::create(), mlir::detail::enumerate(), getBoundedTileSize(), mlir::getValueOrCreateConstantIndexOp(), mlir::m_Zero(), mlir::matchPattern(), and mlir::OpBuilder::setInsertionPoint().
Referenced by mlir::scf::tileReductionUsingScf(), and mlir::scf::tileUsingSCFForOp().
|
static |
Returns the bounded tile size given the current iv
, loopRange
and tileSize
, i.e., min(tileSize, range.end() - iv)
.
Definition at line 83 of file TileUsingInterface.cpp.
References mlir::bindDims(), mlir::bindSymbols(), mlir::AffineMap::get(), mlir::getAsOpFoldResult(), mlir::getConstantIntValue(), mlir::Builder::getContext(), mlir::getValueOrCreateConstantIndexOp(), mlir::makeComposedFoldedAffineMin(), mlir::Range::offset, mlir::Range::size, and tileDividesIterationDomain().
Referenced by generateTileLoopNest().
|
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 492 of file TileUsingInterface.cpp.
References mlir::Value::dyn_cast(), and mlir::IROperand< DerivedT, IRValueT >::get().
Referenced by mlir::scf::tileAndFuseProducerOfSlice().
|
static |
Definition at line 68 of file TileUsingInterface.cpp.
References mlir::getConstantIntValue(), mlir::Range::offset, mlir::Range::size, and mlir::Range::stride.
Referenced by getBoundedTileSize().
|
static |
If the tiled operation is destination passing style, update the slice of the destination used (which refers to the untiled destination) to use the corresponding region argument of the innermost loop.
is transformed to
Definition at line 237 of file TileUsingInterface.cpp.
References mlir::detail::enumerate().
Referenced by mlir::scf::tileAndFuseProducerOfSlice(), mlir::scf::tileReductionUsingScf(), mlir::scf::yieldReplacementForFusedProducer(), and yieldTiledValues().
|
static |
Helper method to yield the values of the tiled op, as well as update the destination operands of the tiled op, if it is a destination passing style op.
Definition at line 252 of file TileUsingInterface.cpp.
References mlir::Operation::getResults(), updateDestinationOperandsForTiledOp(), and yieldTiledValues().
|
static |
For a value to be yielded (yieldedValue
) from within a loop nest loops
, construct the destructive update pattern that inserts the yielded value into a destination tensor provided by initValue
at offset tileOffsets
and size tileSizes
.
For example,
is transformed to
TODO: This API can be cleaned up by using SubsetExtractOpInterface
.
Definition at line 177 of file TileUsingInterface.cpp.
References mlir::OpBuilder::create(), mlir::detail::enumerate(), mlir::RewriterBase::eraseOp(), mlir::Builder::getIndexAttr(), and mlir::replaceLoopNestWithNewYields().
Referenced by mlir::scf::tileReductionUsingScf(), mlir::scf::tileUsingSCFForOp(), mlir::scf::yieldReplacementForFusedProducer(), and yieldTiledValues().