MLIR 22.0.0git
Tiling.cpp File Reference
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/LoopUtils.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/ValueRange.h"
#include "mlir/Transforms/FoldUtils.h"
#include "llvm/ADT/STLExtras.h"
#include <utility>
#include "mlir/Dialect/Linalg/Passes.h.inc"
#include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc"

Go to the source code of this file.

Namespaces

namespace  mlir
 Include the generated interface declarations.

Macros

#define GEN_PASS_DEF_LINALGTILINGPASS
#define DEBUG_TYPE   "linalg-tiling"
#define GET_OP_LIST

Functions

static void emitIsPositiveIndexAssertion (ImplicitLocOpBuilder &b, OpFoldResult value)
 Asserts that the given index-typed value is strictly positive.
static bool canOmitTileOffsetInBoundsCheck (OpFoldResult tileSize, OpFoldResult numThreads, OpFoldResult iterationSize)
 Returns true if the maximum tile offset tileSize * numThreads-1 is less than iterationSize.
static OpFoldResult buildMax (OpBuilder &b, Location loc, ArrayRef< OpFoldResult > vals)
 Build an affine_max of all the vals.
static OpFoldResult buildMin (OpBuilder &b, Location loc, ArrayRef< OpFoldResult > vals)
 Build an affine_min of all the vals.
static void calculateTileOffsetsAndSizes (RewriterBase &b, Location loc, scf::ForallOp forallOp, ArrayRef< OpFoldResult > numThreads, SmallVector< Range > loopRanges, bool omitTileOffsetBoundsCheck, std::optional< ArrayRef< OpFoldResult > > nominalTileSizes, SmallVector< OpFoldResult > &tiledOffsets, SmallVector< OpFoldResult > &tiledSizes)
 Fill out the tiledOffsets and tiledSizes to be used to tile to a given number of threads.
template<typename LoopTy>
static FailureOr< TiledLinalgOptileLinalgOpImpl (RewriterBase &b, LinalgOp op, ArrayRef< OpFoldResult > tileSizes, const LinalgTilingOptions &options)
template<typename LoopTy>
static FailureOr< TiledLinalgOptileLinalgOpImpl (RewriterBase &b, LinalgOp op, const LinalgTilingOptions &options)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-tiling"

Definition at line 41 of file Tiling.cpp.

◆ GEN_PASS_DEF_LINALGTILINGPASS

#define GEN_PASS_DEF_LINALGTILINGPASS

Definition at line 32 of file Tiling.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ buildMax()

OpFoldResult buildMax ( OpBuilder & b,
Location loc,
ArrayRef< OpFoldResult > vals )
static

Build an affine_max of all the vals.

Definition at line 345 of file Tiling.cpp.

References b, mlir::Location::getContext(), mlir::AffineMap::getMultiDimIdentityMap(), and mlir::affine::makeComposedFoldedAffineMax().

Referenced by calculateTileOffsetsAndSizes().

◆ buildMin()

OpFoldResult buildMin ( OpBuilder & b,
Location loc,
ArrayRef< OpFoldResult > vals )
static

Build an affine_min of all the vals.

Definition at line 353 of file Tiling.cpp.

References b, mlir::Location::getContext(), mlir::AffineMap::getMultiDimIdentityMap(), and mlir::affine::makeComposedFoldedAffineMin().

Referenced by calculateTileOffsetsAndSizes().

◆ calculateTileOffsetsAndSizes()

void calculateTileOffsetsAndSizes ( RewriterBase & b,
Location loc,
scf::ForallOp forallOp,
ArrayRef< OpFoldResult > numThreads,
SmallVector< Range > loopRanges,
bool omitTileOffsetBoundsCheck,
std::optional< ArrayRef< OpFoldResult > > nominalTileSizes,
SmallVector< OpFoldResult > & tiledOffsets,
SmallVector< OpFoldResult > & tiledSizes )
static

Fill out the tiledOffsets and tiledSizes to be used to tile to a given number of threads.

Definition at line 362 of file Tiling.cpp.

References b, mlir::bindDims(), mlir::bindSymbols(), buildMax(), buildMin(), canOmitTileOffsetInBoundsCheck(), mlir::AffineExpr::ceilDiv(), mlir::isZeroInteger(), and mlir::affine::makeComposedFoldedAffineApply().

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

◆ canOmitTileOffsetInBoundsCheck()

bool canOmitTileOffsetInBoundsCheck ( OpFoldResult tileSize,
OpFoldResult numThreads,
OpFoldResult iterationSize )
static

Returns true if the maximum tile offset tileSize * numThreads-1 is less than iterationSize.

Definition at line 333 of file Tiling.cpp.

References mlir::getConstantIntValue().

Referenced by calculateTileOffsetsAndSizes().

◆ emitIsPositiveIndexAssertion()

void emitIsPositiveIndexAssertion ( ImplicitLocOpBuilder & b,
OpFoldResult value )
static

Asserts that the given index-typed value is strictly positive.

If the value is an attribute, asserts at compile time, otherwise emits an assertion checked at runtime.

Definition at line 89 of file Tiling.cpp.

References b, and mlir::arith::ConstantIndexOp::create().

Referenced by mlir::linalg::computeContinuousTileSizes(), and mlir::linalg::computeMultiTileSizes().

◆ tileLinalgOpImpl() [1/2]

◆ tileLinalgOpImpl() [2/2]

template<typename LoopTy>
FailureOr< TiledLinalgOp > tileLinalgOpImpl ( RewriterBase & b,
LinalgOp op,
const LinalgTilingOptions & options )
static

Definition at line 795 of file Tiling.cpp.

References b, mlir::getAsOpFoldResult(), options, and tileLinalgOpImpl().