MLIR  19.0.0git
Macros | Functions
Padding.cpp File Reference
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "linalg-padding"
 
#define DBGS()   (llvm::dbgs() << "[" DEBUG_TYPE << "]: ")
 
#define DBGSNL()   (llvm::dbgs() << "\n")
 

Functions

static LogicalResult computePaddedShape (linalg::LinalgOp opToPad, OpOperand *opOperand, const LinalgPaddingOptions &options, SmallVector< int64_t > &paddedShape, bool &alreadyHasRequestedShape)
 Compute the padded shape of the given operand. More...
 
static FailureOr< ValuepadOperandToSmallestStaticBoundingBox (RewriterBase &rewriter, linalg::LinalgOp opToPad, OpOperand *opOperand, const LinalgPaddingOptions &options)
 Pad the opOperand in the "paddingDimensions" using the padding value and the nofold flag found in "paddingValues" and "packPaddings", respectively. More...
 

Macro Definition Documentation

◆ DBGS

#define DBGS ( )    (llvm::dbgs() << "[" DEBUG_TYPE << "]: ")

Definition at line 22 of file Padding.cpp.

◆ DBGSNL

#define DBGSNL ( )    (llvm::dbgs() << "\n")

Definition at line 23 of file Padding.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-padding"

Definition at line 17 of file Padding.cpp.

Function Documentation

◆ computePaddedShape()

static LogicalResult computePaddedShape ( linalg::LinalgOp  opToPad,
OpOperand opOperand,
const LinalgPaddingOptions options,
SmallVector< int64_t > &  paddedShape,
bool &  alreadyHasRequestedShape 
)
static

Compute the padded shape of the given operand.

The operand is padded to a static bounding box according to the specified padding options.

Definition at line 27 of file Padding.cpp.

References mlir::presburger::ceil(), mlir::ValueBoundsConstraintSet::computeConstantBound(), DBGS, mlir::detail::enumerate(), mlir::failed(), mlir::failure(), mlir::IROperand< DerivedT, IRValueT >::get(), mlir::AffineMap::getResults(), options, mlir::success(), and mlir::presburger::UB.

Referenced by padOperandToSmallestStaticBoundingBox().

◆ padOperandToSmallestStaticBoundingBox()

static FailureOr<Value> padOperandToSmallestStaticBoundingBox ( RewriterBase rewriter,
linalg::LinalgOp  opToPad,
OpOperand opOperand,
const LinalgPaddingOptions options 
)
static

Pad the opOperand in the "paddingDimensions" using the padding value and the nofold flag found in "paddingValues" and "packPaddings", respectively.

Exit early and return the opOperand value if it already has the requested shape. i.e.:

  • static shape
  • nofold is not set
  • dim sizes are multiples of "padToMultipleOf"

Otherwise, try to pad the shape dimensions that match the iterator dimensions "paddingDimensions" and return the tensor::PadOp result if padding succeeds or failure otherwise.

Definition at line 102 of file Padding.cpp.

References computePaddedShape(), mlir::OpBuilder::create(), DBGS, mlir::failed(), mlir::IROperand< DerivedT, IRValueT >::get(), mlir::get(), mlir::getElementTypeOrSelf(), mlir::OpOperand::getOperandNumber(), mlir::Value::getType(), mlir::linalg::makeComposedPadHighOp(), mlir::RewriterBase::notifyMatchFailure(), and options.

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