MLIR  19.0.0git
Typedefs | Functions
TosaToLinalg.cpp File Reference
#include "mlir/Conversion/TosaToLinalg/TosaToLinalg.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Index/IR/IndexOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/Dialect/Tosa/Utils/ConversionUtils.h"
#include "mlir/Dialect/Utils/ReshapeOpsUtils.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include <numeric>

Go to the source code of this file.

Typedefs

using IndexPool = DenseMap< int64_t, Value >
 

Functions

template<typename T >
static arith::ConstantOp createConstFromIntAttribute (Operation *op, const std::string &attrName, Type requiredAttrType, OpBuilder &rewriter)
 
static Value createLinalgBodyCalculationForElementwiseOp (Operation *op, ValueRange args, ArrayRef< Type > resultTypes, PatternRewriter &rewriter)
 
static Value expandRank (PatternRewriter &rewriter, Location loc, Value tensor, int64_t rank)
 
static SmallVector< ValueexpandInputRanks (PatternRewriter &rewriter, Location loc, Operation *operation)
 
static Value createIndex (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, int64_t index)
 
static Value getTensorDim (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, Value tensor, int64_t index)
 
static OpFoldResult getOrFoldTensorDim (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, Value tensor, int64_t index)
 
static bool operandsAndResultsRanked (Operation *operation)
 
static std::pair< OpFoldResult, ValuecomputeTargetSize (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, ValueRange operands, int64_t dim)
 
static std::pair< SmallVector< OpFoldResult >, SmallVector< Value > > computeTargetShape (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, ValueRange operands)
 
static Value broadcastDynamicDimension (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, Value operand, int64_t dim, OpFoldResult targetSize, Value masterOperand)
 
static Value broadcastDynamicDimensions (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, Value operand, ArrayRef< OpFoldResult > targetShape, ArrayRef< Value > masterOperands)
 
static SmallVector< ValuebroadcastDynamicDimensions (PatternRewriter &rewriter, Location loc, IndexPool &indexPool, ValueRange operands, ArrayRef< OpFoldResult > targetShape, ArrayRef< Value > masterOperands)
 
static LogicalResult emitElementwiseComputation (PatternRewriter &rewriter, Location loc, Operation *operation, ValueRange operands, ArrayRef< OpFoldResult > targetShape)
 
static LogicalResult elementwiseMatchAndRewriteHelper (Operation *operation, PatternRewriter &rewriter)
 
static TypedAttr createInitialValueForReduceOp (Operation *op, Type elementTy, PatternRewriter &rewriter)
 
static Value createLinalgBodyCalculationForReduceOp (Operation *op, ValueRange args, Type elementTy, PatternRewriter &rewriter)
 
static LogicalResult reduceMatchAndRewriteHelper (Operation *op, uint64_t axis, PatternRewriter &rewriter)
 

Typedef Documentation

◆ IndexPool

using IndexPool = DenseMap<int64_t, Value>

Definition at line 626 of file TosaToLinalg.cpp.

Function Documentation

◆ broadcastDynamicDimension()

static Value broadcastDynamicDimension ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
Value  operand,
int64_t  dim,
OpFoldResult  targetSize,
Value  masterOperand 
)
static

◆ broadcastDynamicDimensions() [1/2]

static Value broadcastDynamicDimensions ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
Value  operand,
ArrayRef< OpFoldResult targetShape,
ArrayRef< Value masterOperands 
)
static

◆ broadcastDynamicDimensions() [2/2]

static SmallVector<Value> broadcastDynamicDimensions ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
ValueRange  operands,
ArrayRef< OpFoldResult targetShape,
ArrayRef< Value masterOperands 
)
static

Definition at line 830 of file TosaToLinalg.cpp.

References broadcastDynamicDimensions().

◆ computeTargetShape()

static std::pair<SmallVector<OpFoldResult>, SmallVector<Value> > computeTargetShape ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
ValueRange  operands 
)
static

Definition at line 717 of file TosaToLinalg.cpp.

References computeTargetSize(), and mlir::ValueRange::getType().

Referenced by elementwiseMatchAndRewriteHelper().

◆ computeTargetSize()

static std::pair<OpFoldResult, Value> computeTargetSize ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
ValueRange  operands,
int64_t  dim 
)
static

◆ createConstFromIntAttribute()

template<typename T >
static arith::ConstantOp createConstFromIntAttribute ( Operation op,
const std::string &  attrName,
Type  requiredAttrType,
OpBuilder rewriter 
)
static

Definition at line 41 of file TosaToLinalg.cpp.

◆ createIndex()

static Value createIndex ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
int64_t  index 
)
static

◆ createInitialValueForReduceOp()

static TypedAttr createInitialValueForReduceOp ( Operation op,
Type  elementTy,
PatternRewriter rewriter 
)
static

Definition at line 922 of file TosaToLinalg.cpp.

◆ createLinalgBodyCalculationForElementwiseOp()

static Value createLinalgBodyCalculationForElementwiseOp ( Operation op,
ValueRange  args,
ArrayRef< Type resultTypes,
PatternRewriter rewriter 
)
static

Definition at line 50 of file TosaToLinalg.cpp.

Referenced by emitElementwiseComputation().

◆ createLinalgBodyCalculationForReduceOp()

static Value createLinalgBodyCalculationForReduceOp ( Operation op,
ValueRange  args,
Type  elementTy,
PatternRewriter rewriter 
)
static

Definition at line 974 of file TosaToLinalg.cpp.

◆ elementwiseMatchAndRewriteHelper()

static LogicalResult elementwiseMatchAndRewriteHelper ( Operation operation,
PatternRewriter rewriter 
)
static

◆ emitElementwiseComputation()

static LogicalResult emitElementwiseComputation ( PatternRewriter rewriter,
Location  loc,
Operation operation,
ValueRange  operands,
ArrayRef< OpFoldResult targetShape 
)
static

◆ expandInputRanks()

static SmallVector<Value> expandInputRanks ( PatternRewriter rewriter,
Location  loc,
Operation operation 
)
static

◆ expandRank()

static Value expandRank ( PatternRewriter rewriter,
Location  loc,
Value  tensor,
int64_t  rank 
)
static

Definition at line 584 of file TosaToLinalg.cpp.

References mlir::OpBuilder::create(), mlir::get(), and mlir::Value::getType().

◆ getOrFoldTensorDim()

static OpFoldResult getOrFoldTensorDim ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
Value  tensor,
int64_t  index 
)
static

◆ getTensorDim()

static Value getTensorDim ( PatternRewriter rewriter,
Location  loc,
IndexPool indexPool,
Value  tensor,
int64_t  index 
)
static

◆ operandsAndResultsRanked()

static bool operandsAndResultsRanked ( Operation operation)
static

◆ reduceMatchAndRewriteHelper()

static LogicalResult reduceMatchAndRewriteHelper ( Operation op,
uint64_t  axis,
PatternRewriter rewriter 
)
static

Definition at line 1023 of file TosaToLinalg.cpp.