MLIR 22.0.0git
TosaToLinalg.cpp File Reference

Go to the source code of this file.

Typedefs

using IndexPool = DenseMap<int64_t, Value>

Functions

template<typename OpTy>
static Value materializeBinaryNanCheckIfRequired (OpTy op, PatternRewriter &rewriter, Value lhs, Value rhs, Value result)
static Value createLinalgBodyCalculationForElementwiseOp (Operation *op, ValueRange args, ArrayRef< Type > resultTypes, ConversionPatternRewriter &rewriter)
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 ValueRange getBroadcastableOperands (Operation *operation, ValueRange operands)
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)
template<typename OpTy>
static LogicalResult reduceMatchAndRewriteHelper (OpTy op, uint64_t axis, PatternRewriter &rewriter)

Typedef Documentation

◆ IndexPool

Definition at line 722 of file TosaToLinalg.cpp.

Function Documentation

◆ broadcastDynamicDimension()

◆ broadcastDynamicDimensions() [1/2]

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

◆ broadcastDynamicDimensions() [2/2]

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

Definition at line 925 of file TosaToLinalg.cpp.

References broadcastDynamicDimensions().

◆ computeTargetShape()

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

Definition at line 813 of file TosaToLinalg.cpp.

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

Referenced by elementwiseMatchAndRewriteHelper().

◆ computeTargetSize()

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

◆ createIndex()

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

Definition at line 727 of file TosaToLinalg.cpp.

References mlir::Builder::getIndexAttr(), and inserted().

Referenced by broadcastDynamicDimension(), and getTensorDim().

◆ createInitialValueForReduceOp()

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

◆ createLinalgBodyCalculationForElementwiseOp()

◆ createLinalgBodyCalculationForReduceOp()

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

Definition at line 1116 of file TosaToLinalg.cpp.

References mlir::Operation::getLoc(), and mlir::Type::isInteger().

Referenced by reduceMatchAndRewriteHelper().

◆ elementwiseMatchAndRewriteHelper()

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

◆ emitElementwiseComputation()

◆ getBroadcastableOperands()

ValueRange getBroadcastableOperands ( Operation * operation,
ValueRange operands )
static

◆ getOrFoldTensorDim()

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

Definition at line 742 of file TosaToLinalg.cpp.

References mlir::Builder::getIndexAttr(), and getTensorDim().

Referenced by broadcastDynamicDimension().

◆ getTensorDim()

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

Definition at line 736 of file TosaToLinalg.cpp.

References createIndex().

Referenced by broadcastDynamicDimension(), computeTargetSize(), and getOrFoldTensorDim().

◆ materializeBinaryNanCheckIfRequired()

template<typename OpTy>
Value materializeBinaryNanCheckIfRequired ( OpTy op,
PatternRewriter & rewriter,
Value lhs,
Value rhs,
Value result )
static

Definition at line 61 of file TosaToLinalg.cpp.

References mlir::getElementTypeOrSelf(), lhs, result, and rhs.

Referenced by createLinalgBodyCalculationForElementwiseOp().

◆ operandsAndResultsRanked()

bool operandsAndResultsRanked ( Operation * operation)
static

◆ reduceMatchAndRewriteHelper()