MLIR  16.0.0git
Macros | Functions
LinalgTransformOps.cpp File Reference
#include "mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.h"
#include "mlir/AsmParser/AsmParser.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/PDL/IR/PDL.h"
#include "mlir/Dialect/PDL/IR/PDLTypes.h"
#include "mlir/Dialect/SCF/Transforms/TileUsingInterface.h"
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/IR/TransformInterfaces.h"
#include "mlir/Dialect/Transform/IR/TransformUtils.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Interfaces/TilingInterface.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Debug.h"
#include "mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp.inc"
#include "mlir/Dialect/Linalg/TransformOps/LinalgTransformOpsEnums.cpp.inc"
+ Include dependency graph for LinalgTransformOps.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "linalg-transforms"
 
#define GET_OP_LIST
 
#define GET_OP_CLASSES
 

Functions

static SmallVector< unsigned > extractUIntArray (ArrayAttr attr)
 Extracts a vector of unsigned from an array attribute. More...
 
template<typename PatternTy , typename... Args>
static FailureOr< LinalgOp > tryApply (Operation *operation, Args &&...args)
 Attempts to apply the pattern specified as template argument to the given operation. More...
 
static LogicalResult applyTilingToAll (Operation *transformOp, ArrayRef< Operation * > payloadOps, unsigned numLoops, transform::TransformResults &transformResults, function_ref< FailureOr< scf::SCFTileAndFuseResult >(TilingInterface)> applyFn)
 Apply a tiling transformation to all payload ops and store both the tiled operation as well as the created tile loops. More...
 
static ParseResult parseTileLikeOp (OpAsmParser &parser, OperationState &result, StringRef sizesAttrName)
 Parse a tiling-like operation that returns the tiled op as well as the created tile loops. More...
 
static OperationtileAndFuseFirstExtractUse (RewriterBase &rewriter, Diagnostic &diag, Operation *producerOp, Operation *containingOp)
 Find the first "extract" user of producerOp and tile it right before its use. More...
 
static OperationtileAndFuseFirstExtractUseThroughContainingOpBlockArgument (RewriterBase &rewriter, Diagnostic &diag, Operation *producerOp, Operation *containingOp)
 First, find the first "scf::ForeachThreadOp" user of producerOp and ensure it is exactly the containingOp, otherwise bail. More...
 
static OperationcloneAndFuseFirstUse (RewriterBase &rewriter, Diagnostic &diag, Operation *producerOp, Operation *containingOp)
 
ParseResult parseOptionalInterchange (OpAsmParser &parser, OperationState &result)
 
void printOptionalInterchange (OpAsmPrinter &p, ArrayRef< int64_t > interchangeVals)
 
static DiagnosedSilenceableFailure unpackPDLOperations (transform::TransformState &state, TransformOpInterface transformOp, SmallVector< OpFoldResult > &result, ArrayRef< OpFoldResult > ofrs)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-transforms"

Definition at line 33 of file LinalgTransformOps.cpp.

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 1883 of file LinalgTransformOps.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ applyTilingToAll()

static LogicalResult applyTilingToAll ( Operation transformOp,
ArrayRef< Operation * >  payloadOps,
unsigned  numLoops,
transform::TransformResults transformResults,
function_ref< FailureOr< scf::SCFTileAndFuseResult >(TilingInterface)>  applyFn 
)
static

Apply a tiling transformation to all payload ops and store both the tiled operation as well as the created tile loops.

Definition at line 106 of file LinalgTransformOps.cpp.

References mlir::Operation::emitError(), mlir::failed(), mlir::failure(), and mlir::OpBuilder::setInsertionPoint().

◆ cloneAndFuseFirstUse()

static Operation* cloneAndFuseFirstUse ( RewriterBase rewriter,
Diagnostic diag,
Operation producerOp,
Operation containingOp 
)
static

◆ extractUIntArray()

static SmallVector<unsigned> extractUIntArray ( ArrayAttr  attr)
static

Extracts a vector of unsigned from an array attribute.

Asserts if the attribute contains values other than intergers. May truncate.

Definition at line 37 of file LinalgTransformOps.cpp.

References value.

◆ parseOptionalInterchange()

ParseResult parseOptionalInterchange ( OpAsmParser parser,
OperationState result 
)

◆ parseTileLikeOp()

static ParseResult parseTileLikeOp ( OpAsmParser parser,
OperationState result,
StringRef  sizesAttrName 
)
static

◆ printOptionalInterchange()

void printOptionalInterchange ( OpAsmPrinter p,
ArrayRef< int64_t >  interchangeVals 
)

Definition at line 1375 of file LinalgTransformOps.cpp.

◆ tileAndFuseFirstExtractUse()

static Operation* tileAndFuseFirstExtractUse ( RewriterBase rewriter,
Diagnostic diag,
Operation producerOp,
Operation containingOp 
)
static

Find the first "extract" user of producerOp and tile it right before its use.

The tiled op is fused under the containingOp. Return this fused op on success or nullptr if anything fails.

Definition at line 252 of file LinalgTransformOps.cpp.

References diag(), mlir::failed(), mlir::Operation::getLoc(), mlir::Operation::getResult(), mlir::RewriterBase::replaceOp(), and mlir::OpBuilder::setInsertionPoint().

◆ tileAndFuseFirstExtractUseThroughContainingOpBlockArgument()

static Operation* tileAndFuseFirstExtractUseThroughContainingOpBlockArgument ( RewriterBase rewriter,
Diagnostic diag,
Operation producerOp,
Operation containingOp 
)
static

First, find the first "scf::ForeachThreadOp" user of producerOp and ensure it is exactly the containingOp, otherwise bail.

Then, find the first "extract" user of the tied block argument and tile it right before its "extract" use. The tiled op is fused under the containingOp. Return this fused op on success or nullptr if anything fails.

Definition at line 311 of file LinalgTransformOps.cpp.

References mlir::Value::cast(), mlir::OpBuilder::clone(), diag(), mlir::RewriterBase::eraseOp(), mlir::failed(), mlir::IROperand< DerivedT, IRValueT >::get(), mlir::Operation::getLoc(), mlir::OpOperand::getOperandNumber(), mlir::tensor::getOrCreateDestinations(), mlir::Operation::getResult(), mlir::Value::getUsers(), mlir::BlockAndValueMapping::map(), mlir::RewriterBase::replaceOp(), mlir::OpBuilder::setInsertionPoint(), mlir::Operation::setOperand(), and mlir::RewriterBase::updateRootInPlace().

◆ tryApply()

template<typename PatternTy , typename... Args>
static FailureOr<LinalgOp> tryApply ( Operation operation,
Args &&...  args 
)
static

Attempts to apply the pattern specified as template argument to the given operation.

The pattern is expected to have a returningMatchAndRewrite function that returns the "main" result or failure. Returns failure if the pattern failed to apply. Extra arguments are forwarded to the pattern constructor.

Definition at line 51 of file LinalgTransformOps.cpp.

References mlir::failed(), mlir::failure(), mlir::Operation::getContext(), and mlir::OpBuilder::setInsertionPoint().

◆ unpackPDLOperations()

static DiagnosedSilenceableFailure unpackPDLOperations ( transform::TransformState state,
TransformOpInterface  transformOp,
SmallVector< OpFoldResult > &  result,
ArrayRef< OpFoldResult ofrs 
)
static