MLIR
17.0.0git
|
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Transforms/Hoisting.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/IR/AsmState.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/Support/Debug.h"
Go to the source code of this file.
Classes | |
struct | HoistingAnalysis |
Analysis class to support tensor::PadOp hoisting across multiple enclosing loops. More... | |
struct | PackingLoopNestResult |
Macros | |
#define | DEBUG_TYPE "hoist-padding" |
#define | DBGS() (dbgs() << '[' << DEBUG_TYPE << "] ") |
Functions | |
static bool | debugPrintLoopInShortForm (Operation *op) |
static void | debugPrintBackwardSlice (SetVector< Operation * > &backwardSlice) |
static void | getAtMostNEnclosingLoops (tensor::PadOp padOp, int nLevels, SmallVector< scf::ForOp > &reverseEnclosingLoops) |
Return at most nLevels of immediately enclosing scf::ForOp loops. More... | |
static void | computeBackwardSlice (tensor::PadOp padOp, scf::ForOp outermostEnclosingForOp, SetVector< Operation * > &backwardSlice) |
static bool | isDefinedOutsideOrConstant (scf::ForOp outer, Value v) |
static Value | buildLoopIterationCount (RewriterBase &rewriter, scf::ForOp outer, scf::ForOp forOp) |
Return the current iteration number in the loop (iv - lb).ceilDiv(step). More... | |
static PackingLoopNestResult | buildPackingLoopNest (RewriterBase &rewriter, IRMapping &bvm, tensor::PadOp opToHoist, ArrayRef< int64_t > transposeVector, RankedTensorType transposedTensorType, tensor::EmptyOp emptyOp, const HoistingAnalysis &analysis) |
static Value | padThroughLoopIterArg (RewriterBase &rewriter, Value packedTensor, tensor::ExtractSliceOp sliceOp, scf::ForOp forOp) |
static Value | replaceByPackingLoopNestResult (RewriterBase &rewriter, const IRMapping &bvm, tensor::PadOp opToHoist, RankedTensorType transposedTensorType, const HoistingAnalysis &analysis, const PackingLoopNestResult &packingResult) |
Produce a tensor extracted from the packingResult. More... | |
#define DBGS | ( | ) | (dbgs() << '[' << DEBUG_TYPE << "] ") |
Definition at line 32 of file HoistPadding.cpp.
#define DEBUG_TYPE "hoist-padding" |
Definition at line 30 of file HoistPadding.cpp.
|
static |
Return the current iteration number in the loop (iv - lb).ceilDiv(step).
The returned Value is guaranteed not to depend on any loop comprised in [outer
, forOp
]. Return null if such a loop-independent quantity cannot be computed.
Definition at line 410 of file HoistPadding.cpp.
References mlir::bindDims(), mlir::bindSymbols(), mlir::ceilDiv(), mlir::OpBuilder::createOrFold(), mlir::Value::getLoc(), and isDefinedOutsideOrConstant().
Referenced by buildPackingLoopNest(), and replaceByPackingLoopNestResult().
|
static |
Definition at line 442 of file HoistPadding.cpp.
References HoistingAnalysis::backwardSlice, buildLoopIterationCount(), mlir::OpBuilder::clone(), mlir::OpBuilder::create(), DBGS, mlir::scf::getForInductionVarOwner(), mlir::Builder::getIndexAttr(), mlir::Operation::getResult(), mlir::IRMapping::lookup(), mlir::IRMapping::lookupOrDefault(), mlir::linalg::makeTransposeOp(), mlir::IRMapping::map(), HoistingAnalysis::outermostEnclosingForOp, mlir::OpBuilder::setInsertionPointToEnd(), and mlir::OpBuilder::setInsertionPointToStart().
Referenced by mlir::linalg::hoistPaddingOnTensors().
|
static |
Definition at line 162 of file HoistPadding.cpp.
References mlir::DominanceInfo::dominates(), mlir::getBackwardSlice(), and mlir::getUsedValuesDefinedAbove().
Referenced by HoistingAnalysis::HoistingAnalysis().
Definition at line 50 of file HoistPadding.cpp.
References DBGS, and debugPrintLoopInShortForm().
Referenced by HoistingAnalysis::HoistingAnalysis().
|
static |
Definition at line 38 of file HoistPadding.cpp.
References mlir::Operation::getParentOfType().
Referenced by debugPrintBackwardSlice(), and getAtMostNEnclosingLoops().
|
static |
Return at most nLevels of immediately enclosing scf::ForOp loops.
Stops at the first parent that is not an scf::ForOp. Multi-loops such as scf.parallel or linalg.tiled_loop are not modeled atm. Control-flow and other containing ops with regions are not modeled atm.
Definition at line 144 of file HoistPadding.cpp.
References DBGS, debugPrintLoopInShortForm(), and mlir::Operation::getParentOp().
Referenced by HoistingAnalysis::HoistingAnalysis().
|
static |
Definition at line 402 of file HoistPadding.cpp.
References mlir::m_Constant(), and mlir::matchPattern().
Referenced by buildLoopIterationCount().
|
static |
Definition at line 558 of file HoistPadding.cpp.
References mlir::OpBuilder::create(), mlir::RewriterBase::finalizeRootUpdate(), mlir::IROperand< DerivedT, IRValueT >::get(), mlir::Value::getDefiningOp(), mlir::Value::getLoc(), mlir::Value::getType(), mlir::OpBuilder::setInsertionPointAfter(), and mlir::RewriterBase::startRootUpdate().
Referenced by replaceByPackingLoopNestResult().
|
static |
Produce a tensor extracted from the packingResult.
This can be used as a replacement for opToHoist
in callers.
Definition at line 587 of file HoistPadding.cpp.
References buildLoopIterationCount(), PackingLoopNestResult::clonedLoopIvs, copy(), mlir::OpBuilder::create(), DBGS, mlir::RewriterBase::finalizeRootUpdate(), mlir::scf::getForInductionVarOwner(), mlir::Builder::getIndexAttr(), mlir::IRMapping::lookup(), HoistingAnalysis::outermostEnclosingForOp, HoistingAnalysis::packingLoops, HoistingAnalysis::padConsumingForOp, padThroughLoopIterArg(), mlir::OpBuilder::setInsertionPoint(), PackingLoopNestResult::sizes, HoistingAnalysis::sliceOp, mlir::RewriterBase::startRootUpdate(), and PackingLoopNestResult::strides.
Referenced by mlir::linalg::hoistPaddingOnTensors().