MLIR  16.0.0git
Classes | Macros | Functions
HoistPadding.cpp File Reference
#include "mlir/Dialect/Linalg/Transforms/HoistPadding.h"
#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/Transforms.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Utils/Utils.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/IR/AsmState.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/Matchers.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
+ Include dependency graph for HoistPadding.cpp:

Go to the source code of this file.

Classes

struct  HoistingAnalysis
 Analysis class to support tensor::PadOp hoisting across multiple enclosing loops. More...
 

Macros

#define DEBUG_TYPE   "hoist-padding"
 
#define DBGS()   (dbgs() << '[' << DEBUG_TYPE << "] ")
 

Functions

static bool isOnlyUsedAsInputOfLinalgOp (tensor::PadOp padOp)
 Return true if all uses of padOp are an input tensor of some LinalgOp. More...
 
static void getAtMostNEnclosingLoops (tensor::PadOp padOp, int nLevels, SmallVector< scf::ForOp > &reverseEnclosingLoops)
 Return at most nLevels of immediately enclosing scf::ForOp loops. More...
 
static FailureOr< RankedTensorType > computeTransposedType (RankedTensorType rankedTensorType, ArrayRef< int64_t > transposeVector)
 Returns the transposed rankedTensorType if transposeVector is non-empty. More...
 
static bool isDefinedOutsideOrConstant (scf::ForOp outer, Value v)
 
static Value buildLoopIterationCount (OpBuilder &b, scf::ForOp outer, scf::ForOp forOp)
 Return the current iteration number in the loop (iv - lb).ceilDiv(step). More...
 

Macro Definition Documentation

◆ DBGS

#define DBGS ( )    (dbgs() << '[' << DEBUG_TYPE << "] ")

◆ DEBUG_TYPE

#define DEBUG_TYPE   "hoist-padding"

Definition at line 34 of file HoistPadding.cpp.

Function Documentation

◆ buildLoopIterationCount()

static Value buildLoopIterationCount ( OpBuilder b,
scf::ForOp  outer,
scf::ForOp  forOp 
)
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 381 of file HoistPadding.cpp.

References mlir::bindDims(), mlir::bindSymbols(), mlir::ceilDiv(), mlir::OpBuilder::createOrFold(), mlir::Value::getLoc(), and isDefinedOutsideOrConstant().

Referenced by mlir::linalg::hoistPaddingOnTensors().

◆ computeTransposedType()

static FailureOr<RankedTensorType> computeTransposedType ( RankedTensorType  rankedTensorType,
ArrayRef< int64_t >  transposeVector 
)
static

Returns the transposed rankedTensorType if transposeVector is non-empty.

Fail if transposeVector is no permutation matching the tensor rank.

Definition at line 150 of file HoistPadding.cpp.

References mlir::applyPermutationToVector(), mlir::failure(), mlir::linalg::isPermutation(), and mlir::RankedTensorType::Builder::setShape().

Referenced by mlir::linalg::hoistPaddingOnTensors().

◆ getAtMostNEnclosingLoops()

static void getAtMostNEnclosingLoops ( tensor::PadOp  padOp,
int  nLevels,
SmallVector< scf::ForOp > &  reverseEnclosingLoops 
)
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 130 of file HoistPadding.cpp.

References DBGS, and mlir::Operation::getParentOp().

Referenced by HoistingAnalysis::HoistingAnalysis().

◆ isDefinedOutsideOrConstant()

static bool isDefinedOutsideOrConstant ( scf::ForOp  outer,
Value  v 
)
static

Definition at line 373 of file HoistPadding.cpp.

References mlir::m_Constant(), and mlir::matchPattern().

Referenced by buildLoopIterationCount().

◆ isOnlyUsedAsInputOfLinalgOp()

static bool isOnlyUsedAsInputOfLinalgOp ( tensor::PadOp  padOp)
static

Return true if all uses of padOp are an input tensor of some LinalgOp.

Definition at line 111 of file HoistPadding.cpp.

References DBGS.

Referenced by HoistingAnalysis::HoistingAnalysis().