MLIR
21.0.0git
|
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/Linalg/Utils/Utils.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include <optional>
#include <set>
Go to the source code of this file.
Classes | |
struct | ShapeDimension |
Implements a simple high-level fusion pass on linalg structured operations. More... | |
Macros | |
#define | DEBUG_TYPE "linalg-fusion" |
Functions | |
static ShapeDimension | getShapeDefiningLoopRange (LinalgOp op, unsigned loopDepth, bool fromSubViewOpOnly=false) |
static SmallVector< Value > | getTiledOperands (LinalgOp producer) |
static LinalgOp | fuse (OpBuilder &b, LinalgOp producer, const DenseMap< unsigned, Range > &fusedLoopsAndRanges) |
Fuses the producer by cloning the producer . More... | |
static Range | getRangeFromOperandShape (OpBuilder &b, Location loc, Value shapedOperand, unsigned dim) |
Get the loop range for a dimension dim based on the shapedOperand . More... | |
static LinalgOp | fuse (OpBuilder &b, LinalgOp producerOp, AffineMap producerMap, OpOperand &consumerOpOperand) |
Fuses the producer into the loop immediately enclosing the consumer. More... | |
static void | getProducerOfTensor (Value tensor, OpResult &opResult) |
Walk back use-def chain through scf::For yields. More... | |
#define DEBUG_TYPE "linalg-fusion" |
Definition at line 37 of file Fusion.cpp.
|
static |
Fuses the producer by cloning the producer
.
The fusedLoopsAndRanges
provides the loop range information for the fused loops. The rest are obtained from the producer itself, since they are not tiled + fused.
omitPartialTileCheck=
Definition at line 114 of file Fusion.cpp.
References mlir::clone(), mlir::linalg::createFoldedDimOp(), mlir::MutableOperandRange::getAsOperandRange(), mlir::OperandRange::getBeginOperandIndex(), mlir::Builder::getIndexAttr(), getShapeDefiningLoopRange(), getTiledOperands(), mlir::getType(), mlir::linalg::makeTiledShapes(), mlir::Range::offset, and mlir::linalg::offsetIndices().
Referenced by fuse(), and mlir::linalg::fuseProducerOfTensor().
|
static |
Fuses the producer into the loop immediately enclosing the consumer.
This is achieved by "recomputing" the producer at the time it is needed just before the consumer.
Definition at line 184 of file Fusion.cpp.
References mlir::detail::enumerate(), fuse(), mlir::IROperand< DerivedT, IRValueT >::get(), mlir::Operation::getLoc(), mlir::detail::IROperandBase::getOwner(), getRangeFromOperandShape(), and mlir::AffineMap::getResults().
Walk back use-def chain through scf::For yields.
Sets producer
and outputIndex
if it finds a producer LinalgOp
Definition at line 203 of file Fusion.cpp.
References mlir::Value::getDefiningOp(), and mlir::Value::getType().
Referenced by mlir::linalg::fuseProducerOfTensor().
|
static |
Get the loop range for a dimension dim
based on the shapedOperand
.
It is expected to be defined by a subview op or an extract_slice op.
Definition at line 171 of file Fusion.cpp.
References mlir::Value::getDefiningOp().
Referenced by fuse().
|
static |
Definition at line 69 of file Fusion.cpp.
References mlir::detail::enumerate(), and mlir::AffineMap::getResults().
Referenced by fuse().
|
static |
Definition at line 107 of file Fusion.cpp.
Referenced by fuse().