MLIR  16.0.0git
Namespaces | Macros | Functions
Utils.cpp File Reference
#include "mlir/Dialect/Linalg/Utils/Utils.h"
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Dialect/Affine/LoopUtils.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Arithmetic/Utils/Utils.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
+ Include dependency graph for Utils.cpp:

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::linalg
 

Macros

#define DEBUG_TYPE   "linalg-utils"
 

Functions

static bool isZero (OpFoldResult v)
 
static bool isTiled (AffineExpr expr, ArrayRef< OpFoldResult > tileSizes)
 
static bool isTiled (AffineMap map, ArrayRef< OpFoldResult > tileSizes)
 
static void unpackRanges (OpBuilder &builder, Location loc, ArrayRef< Range > ranges, SmallVectorImpl< Value > &lbs, SmallVectorImpl< Value > &ubs, SmallVectorImpl< Value > &steps)
 Given a list of subview ranges, extract individual values for lower, upper bounds and steps and put them into the corresponding vectors. More...
 
bool mlir::linalg::allIndexingsAreProjectedPermutation (LinalgOp op)
 Check if all indexing maps are projected permutations. More...
 
bool mlir::linalg::hasOnlyScalarElementwiseOp (Region &r)
 Detect whether r has only ConstantOp, ElementwiseMappable and YieldOp. More...
 
bool mlir::linalg::isElementwise (LinalgOp op)
 Check if a LinalgOp is an element-wise operation. More...
 
bool mlir::linalg::isPermutation (ArrayRef< int64_t > permutation)
 Check if permutation is a permutation of the range [0, permutation.size()). More...
 
Value mlir::linalg::createOrFoldDimOp (OpBuilder &b, Location loc, Value source, int64_t dim)
 Helper function that creates a memref::DimOp or tensor::DimOp depending on the type of source. More...
 
OpFoldResult mlir::linalg::createFoldedDimOp (OpBuilder &b, Location loc, Value source, int64_t dim)
 
SmallVector< Value, 4 > mlir::linalg::getDynOperands (Location loc, Value val, OpBuilder &b)
 Given an operation, retrieves the value of each dynamic dimension through constructing the necessary DimOp operators. More...
 
void mlir::linalg::getUpperBoundForIndex (Value value, AffineMap &boundMap, SmallVectorImpl< Value > &boundOperands, bool constantRequired=false)
 Computes an upper bound for the result value of an index computation. More...
 
FailureOr< int64_t > mlir::linalg::getConstantUpperBoundForIndex (Value value)
 Returns a constant upper bound for the result value of an index computation. More...
 
tensor::ExtractSliceOp mlir::linalg::makeComposedExtractSliceOp (OpBuilder &b, Location loc, Value source, ArrayRef< OpFoldResult > offsets, ArrayRef< OpFoldResult > sizes, ArrayRef< OpFoldResult > strides)
 Create an ExtractSliceOp and, if source is defined by an ExtractSliceOp, fold it by adding the offsets. More...
 
Value mlir::linalg::makeComposedPadHighOp (OpBuilder &b, Location loc, RankedTensorType type, Value source, Value pad, bool nofold)
 Create a tensor::PadOp that pads source to the size of the statically sized type whose static sizes are assumed to be greater than the dynamic source size. More...
 
GenericOp mlir::linalg::makeTransposeOp (OpBuilder &b, Location loc, Value inputTensor, Value outputTensor, ArrayRef< int64_t > transposeVector)
 Returns a GenericOp that tansposes inputTensor into outputTensor using transposeVector to permute the inputTensor dimensions. More...
 
GenericOp mlir::linalg::makeMemRefCopyOp (OpBuilder &b, Location loc, Value from, Value to)
 Returns GenericOp that copies an n-D memref. More...
 
void mlir::linalg::updateBoundsForCyclicDistribution (OpBuilder &builder, Location loc, Value procId, Value nprocs, Value &lb, Value &ub, Value &step)
 Update the lb, ub and step to get per processor lb, ub and step. More...
 
static void mlir::linalg::generateParallelLoopNest (OpBuilder &b, Location loc, ValueRange lbs, ValueRange ubs, ValueRange steps, ArrayRef< Attribute > iteratorTypes, ArrayRef< linalg::ProcInfo > procInfo, function_ref< void(OpBuilder &, Location, ValueRange)> bodyBuilderFn, SmallVectorImpl< Value > &ivStorage)
 Generates a loop nest consisting of scf.parallel and scf.for, depending on the `iteratorTypes. More...
 
static Value mlir::linalg::materializeTiledShape (OpBuilder &builder, Location loc, Value valueToTile, const SliceParameters &sliceParams)
 
Value mlir::linalg::makeTiledShape (OpBuilder &builder, Location loc, Value valueToTile, ArrayRef< OpFoldResult > tileSizes, AffineMap map, ArrayRef< OpFoldResult > lbs, ArrayRef< OpFoldResult > ubs, ArrayRef< OpFoldResult > subShapeSizes, bool omitPartialTileCheck)
 Creates an extract_slice/subview op for a single valueToTile with builder. More...
 
SliceParameters mlir::linalg::computeSliceParameters (OpBuilder &builder, Location loc, Value valueToTile, ArrayRef< OpFoldResult > tileSizes, AffineMap map, ArrayRef< OpFoldResult > lbs, ArrayRef< OpFoldResult > ubs, ArrayRef< OpFoldResult > subShapeSizes, bool omitPartialTileCheck)
 Computes SliceParameters for a single valueToTile assuming that its user is being tiled with the given loop bounds lbs and ubs and the tile sizes tileSizes. More...
 
SmallVector< OpFoldResultmlir::linalg::computeTileOffsets (OpBuilder &b, Location loc, ArrayRef< OpFoldResult > ivs, ArrayRef< OpFoldResult > tileSizes)
 Computes tile offsets, given a list of loop ivs and tileSizes. More...
 
SmallVector< OpFoldResultmlir::linalg::computeTileSizes (OpBuilder &b, Location loc, ArrayRef< OpFoldResult > tileSizes, ArrayRef< OpFoldResult > sizeBounds)
 Computes tile sizes, given a list of tileSizes and dimension sizes (sizeBounds). More...
 
SmallVector< Typemlir::linalg::getTensorOutputTypes (LinalgOp op, ValueRange operands)
 Returns the list of tensor output types produced when the given structured operation op is applied to the given operands. More...
 
SmallVector< Valuemlir::linalg::insertSlicesBack (OpBuilder &builder, Location loc, LinalgOp op, ValueRange operands, ValueRange results)
 Creates insert_slice ops that insert results back into larger tensors they were originally extracted from with extract_slice before being passed as operands to the given structured operation op or its clone. More...
 
Value mlir::linalg::materializeOpFoldResult (ImplicitLocOpBuilder &builder, OpFoldResult opFoldResult)
 Turns an OpFoldResult into a value, creating an index-typed constant if necessary. More...
 
Value mlir::linalg::materializeOpFoldResult (OpBuilder &b, Location loc, OpFoldResult opFoldResult)
 
SmallVector< Optional< SliceParameters > > mlir::linalg::computeAllSliceParameters (OpBuilder &builder, Location loc, LinalgOp linalgOp, ValueRange valuesToTile, ArrayRef< OpFoldResult > ivs, ArrayRef< OpFoldResult > tileSizes, ArrayRef< OpFoldResult > sizeBounds, bool omitPartialTileCheck)
 Computes SliceParamaters for all valuesToTile of the given linalgOp, assuming linalgOp is being fused into a loop nest. More...
 
SmallVector< Valuemlir::linalg::makeTiledShapes (OpBuilder &builder, Location loc, LinalgOp linalgOp, ValueRange valuesToTile, ArrayRef< OpFoldResult > ivs, ArrayRef< OpFoldResult > tileSizes, ArrayRef< OpFoldResult > sizeBounds, bool omitPartialTileCheck)
 Creates extract_slice/subview ops for all valuesToTile of the given linalgOp with builder, assuming linalgOp is being fused into a loop nest for tiling with the given induction variables ivs and tile sizes tileSizes. More...
 
void mlir::linalg::offsetIndices (OpBuilder &b, LinalgOp linalgOp, ArrayRef< OpFoldResult > offests)
 Add the specified offsets to any linalg.index ops contained in the given linalgOp. More...
 
void mlir::linalg::offsetIndices (RewriterBase &b, LinalgOp linalgOp, ArrayRef< OpFoldResult > offests)
 
Optional< SmallVector< ReassociationIndices > > mlir::linalg::getReassociationMapForFoldingUnitDims (ArrayRef< OpFoldResult > mixedSizes)
 Get the reassociation maps to fold the result of a extract_slice (or source of a insert_slice) operation with given offsets, and sizes to its rank-reduced version. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-utils"

Definition at line 38 of file Utils.cpp.

Function Documentation

◆ isTiled() [1/2]

static bool isTiled ( AffineExpr  expr,
ArrayRef< OpFoldResult tileSizes 
)
static

◆ isTiled() [2/2]

static bool isTiled ( AffineMap  map,
ArrayRef< OpFoldResult tileSizes 
)
static

◆ isZero()

static bool isZero ( OpFoldResult  v)
static

◆ unpackRanges()

static void unpackRanges ( OpBuilder builder,
Location  loc,
ArrayRef< Range ranges,
SmallVectorImpl< Value > &  lbs,
SmallVectorImpl< Value > &  ubs,
SmallVectorImpl< Value > &  steps 
)
static

Given a list of subview ranges, extract individual values for lower, upper bounds and steps and put them into the corresponding vectors.

Definition at line 138 of file Utils.cpp.

References mlir::linalg::materializeOpFoldResult().

Referenced by mlir::linalg::GenerateLoopNest< LoopTy >::doit().