MLIR  20.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, ConversionPatternRewriter &rewriter)
 
static Value expandRank (PatternRewriter &rewriter, Location loc, Value tensor, int64_t rank)
 
static SmallVector< ValueexpandInputRanks (PatternRewriter &rewriter, Location loc, ValueRange operands, int64_t rank)
 
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 (ConversionPatternRewriter &rewriter, Location loc, Operation *operation, ValueRange operands, ArrayRef< OpFoldResult > targetShape, const TypeConverter &converter)
 
static LogicalResult elementwiseMatchAndRewriteHelper (Operation *operation, ValueRange operands, ConversionPatternRewriter &rewriter, const TypeConverter &converter)
 
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 641 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 845 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 732 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

◆ 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

◆ createLinalgBodyCalculationForElementwiseOp()

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

◆ createLinalgBodyCalculationForReduceOp()

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

◆ elementwiseMatchAndRewriteHelper()

static LogicalResult elementwiseMatchAndRewriteHelper ( Operation operation,
ValueRange  operands,
ConversionPatternRewriter rewriter,
const TypeConverter converter 
)
static

◆ emitElementwiseComputation()

static LogicalResult emitElementwiseComputation ( ConversionPatternRewriter rewriter,
Location  loc,
Operation operation,
ValueRange  operands,
ArrayRef< OpFoldResult targetShape,
const TypeConverter converter 
)
static

◆ expandInputRanks()

static SmallVector<Value> expandInputRanks ( PatternRewriter rewriter,
Location  loc,
ValueRange  operands,
int64_t  rank 
)
static

Definition at line 633 of file TosaToLinalg.cpp.

References expandRank().

Referenced by elementwiseMatchAndRewriteHelper().

◆ expandRank()

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

Definition at line 600 of file TosaToLinalg.cpp.

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

Referenced by expandInputRanks().

◆ 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