MLIR 24.0.0git
TosaOps.cpp File Reference
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/Dialect/Quant/IR/Quant.h"
#include "mlir/Dialect/Shard/Interfaces/ShardingInterface.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tosa/Utils/QuantUtils.h"
#include "mlir/Dialect/Tosa/Utils/ShapeUtils.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Utils/VerificationUtils.h"
#include "mlir/IR/BuiltinTypeInterfaces.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallVectorExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include <numeric>
#include <type_traits>
#include "mlir/Dialect/Tosa/IR/TosaOpsDialect.cpp.inc"
#include "mlir/Dialect/Tosa/Utils/ConversionUtils.h"
#include "mlir/Dialect/Tosa/IR/TosaEnums.cpp.inc"
#include "mlir/Dialect/Tosa/IR/TosaInterfaces.cpp.inc"
#include "mlir/Dialect/Tosa/IR/TosaDialectBytecode.cpp.inc"
#include "mlir/Dialect/Tosa/IR/TosaOpsTypesBase.cpp.inc"
#include "mlir/Dialect/Tosa/IR/TosaOps.cpp.inc"
#include "mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"

Go to the source code of this file.

Classes

class  ConvInferShapeAdaptorBase
class  ConvInferShapeAdaptor< Conv2DOp::Adaptor >
class  ConvInferShapeAdaptor< Conv2DBlockScaledOp::Adaptor >
class  ConvInferShapeAdaptor< Conv3DOp::Adaptor >

Macros

#define GET_TYPEDEF_LIST
#define GET_OP_LIST
#define GET_ATTRDEF_LIST
#define ZERO_POINT_HELPER(OP, OPERAND_NAME, SIGN_EXTEND)
#define COMPATIBLE_RETURN_TYPES(OP)
#define REDUCE_SHAPE_INFER(OP)
#define NARY_SHAPE_INFER(OP)
#define GET_ATTRDEF_CLASSES
#define GET_TYPEDEF_CLASSES
#define GET_OP_CLASSES

Functions

static SmallVector< int64_t > convertToMlirShape (ArrayRef< int64_t > shape)
static std::optional< int64_t > idivCheck (const int64_t lhs, const int64_t rhs)
static LogicalResult verifyRescaleValueAndZpTypes (Operation *op, Value val, Value valZp, StringRef name)
LogicalResult tryUpdateDimOrFailure (Operation *op, int64_t &currDim, const int64_t newDim, const StringRef operandName, const StringRef dimName)
static void printShapeToDiagnostic (InFlightDiagnostic &diag, ArrayRef< int64_t > shape)
static LogicalResult verifyOutputShapeCompatibleWithExpected (Operation *op, ShapedType outputType, ArrayRef< int64_t > expectedShape, StringRef outputName="output")
LogicalResult verifyConvOutputSize (Operation *op, const int64_t inputSize, const int64_t kernelSize, const int64_t outputSize, const int64_t padBefore, const int64_t padAfter, const int64_t stride, const int64_t dilation, const llvm::StringRef dimName, const llvm::StringRef dimAxis, const llvm::StringRef padBeforeName, const llvm::StringRef padAfterName)
static ParseResult parseScaleValues (AsmParser &parser, SmallVector< Attribute > &scaleValues, Type scaleType)
static void printScaleValues (AsmPrinter &printer, ArrayRef< Attribute > scaleValues, Type)
template<typename A, std::enable_if_t< std::is_same_v< A, ArgMaxOp::Adaptor >||std::is_same_v< A, ArgMinOp::Adaptor >, int > = 0>
LogicalResult inferArgMaxMinReturnTypeComponents (MLIRContext *context, ::std::optional< Location > location, A adaptor, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
template<typename T>
LogicalResult argMaxMinVerify (T op)
template<typename T>
static LogicalResult verifyConvOp (T op)
template<typename T>
static LogicalResult verifyConvOpModes (T op)
template<typename T>
static LogicalResult verifyConvOpErrorIf (T op)
static LogicalResult errorIfTypeOrShapeMismatch (Operation *op, Type type1, StringRef name1, Type type2, StringRef name2)
static LogicalResult errorIfTypeOrShapeMismatch (Operation *op, ValueRange list1, StringRef name1, ValueRange list2, StringRef name2)
static LogicalResult errorIfShapeNotSizeOne (Operation *op, Type type)
template<typename T>
static LogicalResult verifyVariableOpErrorIf (T op, Type type, StringRef name)
static LogicalResult verifySameElementTypes (Operation *op, Type aType, Type bType, StringRef aName="input", StringRef bName="output")
static LogicalResult verifyPoolingOpImpl (Operation *op, ArrayRef< int64_t > kernel, ArrayRef< int64_t > strides, ArrayRef< int64_t > padding, Value input, Value output)
template<typename T>
static LogicalResult verifyPoolingOp (T op)
template<typename T>
static LogicalResult verifyAvgPoolCommonTypeAndZpChecks (T op)
template<typename T, typename std::enable_if< IsSupportedAdaptivePoolConstShapeVerifyOp< T >, int >::type = 0>
static void extractAdaptivePoolingConstShapeOperands (T op, AdaptivePoolingConstShapeValues &values)
static void buildConvOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value input, Value weight, Value bias, DenseI64ArrayAttr pad, DenseI64ArrayAttr stride, DenseI64ArrayAttr dilation, TypeAttr accType)
 This builder is called on all convolution operators except TransposeConv, which has specialized output shape semantics.
static void buildTransConvOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value input, Value weight, Value bias, DenseI64ArrayAttr outpad, DenseI64ArrayAttr stride, TypeAttr accType)
 Handles tosa.transpose_conv2d which has outpad and output shape attributes.
static void buildMatMulLikeOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value a, Value b)
static void buildMatMulOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value a, Value b)
static void buildMatMulTOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value a, Value b)
static void buildAvgPool2dOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value input, DenseArrayAttr kernel, DenseArrayAttr stride, DenseArrayAttr pad, TypeAttr accType)
 Both the tosa.avg_pool2d and unary ops use the same UnaryOpQuantizationAttr but avg_pool operator has its own builder as it has additional parameters not part of the unary ops.
static void buildAvgPool2dAdaptiveOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value input, DenseI64ArrayAttr kernel, DenseI64ArrayAttr stride, DenseI64ArrayAttr pad, TypeAttr accType)
 This builder mirrors avg_pool2d quant-info handling and materializes kernel/stride/pad as const_shape operands for avg_pool2d_adaptive.
static void buildNegateOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value input)
 This builder is called on single-parameter negate operator to construct input and output zero points based on their types.
static void buildPadOpWithQuantInfo (OpBuilder &builder, OperationState &result, Type outputType, Value input, Value paddings)
 This builder is called on TOSA pad operator that needs to create its own OptionalAttr quantization_attr parameter to scale the padding values correctly.
static void buildVariableOp (OpBuilder &builder, OperationState &result, StringRef name, Type variableType, Attribute initialValue)
static FailureOr< int64_t > resolveBroadcastDim (const int64_t dim1, const int64_t dim2)
static LogicalResult resolveBroadcastShape (const ValueShapeRange &operands, SmallVector< int64_t > &outShape)
static LogicalResult verifyDimIsPowerOfTwo (Operation *op, const int64_t dimSize, const llvm::StringRef dimName)
static int64_t getMatMulBatchDim (const ShapeAdaptor &shape, int64_t outputRank, int64_t axis)
static FailureOr< SmallVector< int64_t > > resolveMatMulOutputShape (const ShapeAdaptor &aShape, const ShapeAdaptor &bShape, int64_t outputRank, bool transposeB)
static LogicalResult inferMatMulReturnTypeComponents (const ShapeAdaptor &aShape, const ShapeAdaptor &bShape, bool transposeB, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
template<typename T>
static LogicalResult verifyMatMulQuantizedOperandsType (T op, Type aElementType, Type bElementType)
template<typename T>
static LogicalResult verifyMatMulZeroPointType (T op, Value input, Value zp, StringRef inputName, StringRef zpName)
static SmallVector< int64_t > getMatMulBatchShape (const ShapeAdaptor &shape)
template<typename T>
static LogicalResult verifyMatMulShapes (T op, bool transposeB)
static FailureOr< int64_t > getZeroPoint (Value val, bool signExtend)
template<typename T>
static LogicalResult verifyZeroPoint (T op, Value val, const int64_t &zp, const std::string &operand)
static LogicalResult verifyZeroPoint (tosa::RescaleOp op, Value zpVal, const int64_t &zp, const std::string &operand)
static LogicalResult ReduceInferReturnTypes (ShapeAdaptor operandShape, Type inputType, IntegerAttr axis, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
template<typename T>
static LogicalResult verifyReduceOp (T op)
static LogicalResult NAryInferReturnTypes (const ValueShapeRange &operands, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
static LogicalResult poolingInferReturnTypes (ShapeAdaptor inputShape, ArrayRef< int64_t > kernel, ArrayRef< int64_t > stride, ArrayRef< int64_t > pad, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
template<typename AdaptorT>
LogicalResult inferConvReturnTypeComponents (AdaptorT adaptor, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
static void printInitializationList (OpAsmPrinter &parser, Block::BlockArgListType blocksArgs, ValueRange initializers, StringRef prefix="")
static ParseResult parseOptionalBoolClause (OpAsmParser &parser, StringRef keyword, BoolAttr &result)
static void printOptionalBoolClause (OpAsmPrinter &printer, StringRef keyword, BoolAttr attr)
static ParseResult parseLocalBound (OpAsmParser &parser, BoolAttr &result)
static void printLocalBound (OpAsmPrinter &printer, Operation *, BoolAttr attr)
static ParseResult parseInputUnsigned (OpAsmParser &parser, BoolAttr &result)
static void printInputUnsigned (OpAsmPrinter &printer, Operation *, BoolAttr attr)

Variables

template<typename T>
static constexpr bool IsSupportedAdaptivePoolConstShapeVerifyOp

Macro Definition Documentation

◆ COMPATIBLE_RETURN_TYPES

#define COMPATIBLE_RETURN_TYPES ( OP)
Value:
bool OP::isCompatibleReturnTypes(TypeRange l, TypeRange r) { \
if (l.size() != r.size() || l.size() != 1) \
return false; \
return false; \
return succeeded(verifyCompatibleShape(l[0], r[0])); \
}
This class provides an abstraction over the various different ranges of value types.
Definition TypeRange.h:40
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
LogicalResult verifyCompatibleShape(ArrayRef< int64_t > shape1, ArrayRef< int64_t > shape2)
Returns success if the given two shapes are compatible.

Definition at line 4021 of file TosaOps.cpp.

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 5945 of file TosaOps.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 5995 of file TosaOps.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

◆ GET_TYPEDEF_CLASSES

#define GET_TYPEDEF_CLASSES

Definition at line 5951 of file TosaOps.cpp.

◆ GET_TYPEDEF_LIST

#define GET_TYPEDEF_LIST

◆ NARY_SHAPE_INFER

#define NARY_SHAPE_INFER ( OP)
Value:
LogicalResult OP::inferReturnTypeComponents( \
MLIRContext *context, ::std::optional<Location> location, \
ValueShapeRange operands, DictionaryAttr attributes, \
PropertyRef properties, RegionRange regions, \
SmallVectorImpl<ShapedTypeComponents> &inferredReturnShapes) { \
return NAryInferReturnTypes(operands, inferredReturnShapes); \
}
static LogicalResult NAryInferReturnTypes(const ValueShapeRange &operands, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
Definition TosaOps.cpp:4111
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
Type-safe wrapper around a void* for passing properties, including the properties structs of operatio...
This class provides an abstraction over the different types of ranges over Regions.
Definition Region.h:363
Range of values and shapes (corresponding effectively to Shapes dialect's ValueShape type concept).

Definition at line 4123 of file TosaOps.cpp.

◆ REDUCE_SHAPE_INFER

#define REDUCE_SHAPE_INFER ( OP)
Value:
LogicalResult OP::inferReturnTypeComponents( \
MLIRContext *context, ::std::optional<Location> location, \
OP::Adaptor adaptor, \
SmallVectorImpl<ShapedTypeComponents> &inferredReturnShapes) { \
Type inputType = \
llvm::cast<TensorType>(adaptor.getInput().getType()).getElementType(); \
ShapeAdaptor inputShape(adaptor.getInput().getType()); \
const Properties &prop = adaptor.getProperties(); \
return ReduceInferReturnTypes(inputShape, inputType, prop.axis, \
inferredReturnShapes); \
} \
COMPATIBLE_RETURN_TYPES(OP)
static LogicalResult ReduceInferReturnTypes(ShapeAdaptor operandShape, Type inputType, IntegerAttr axis, SmallVectorImpl< ShapedTypeComponents > &inferredReturnShapes)
Definition TosaOps.cpp:4005
Adaptor class to abstract the differences between whether value is from a ShapedType or ShapedTypeCom...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74

Definition at line 4030 of file TosaOps.cpp.

◆ ZERO_POINT_HELPER

#define ZERO_POINT_HELPER ( OP,
OPERAND_NAME,
SIGN_EXTEND )
Value:
FailureOr<int64_t> tosa::OP::get##OPERAND_NAME##ZeroPoint() { \
return getZeroPoint(get##OPERAND_NAME##Zp(), SIGN_EXTEND); \
} \
LogicalResult tosa::OP::verify##OPERAND_NAME##ZeroPoint(int64_t zp) { \
return verifyZeroPoint(*this, get##OPERAND_NAME##Zp(), zp, #OPERAND_NAME); \
}
static FailureOr< int64_t > getZeroPoint(Value val, bool signExtend)
Definition TosaOps.cpp:3160
static LogicalResult verifyZeroPoint(T op, Value val, const int64_t &zp, const std::string &operand)
Definition TosaOps.cpp:3187
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...

Definition at line 3229 of file TosaOps.cpp.

Function Documentation

◆ argMaxMinVerify()

template<typename T>
LogicalResult argMaxMinVerify ( T op)

Definition at line 625 of file TosaOps.cpp.

References success(), and mlir::verifyCompatibleShape().

◆ buildAvgPool2dAdaptiveOpWithQuantInfo()

void buildAvgPool2dAdaptiveOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value input,
DenseI64ArrayAttr kernel,
DenseI64ArrayAttr stride,
DenseI64ArrayAttr pad,
TypeAttr accType )
static

This builder mirrors avg_pool2d quant-info handling and materializes kernel/stride/pad as const_shape operands for avg_pool2d_adaptive.

Definition at line 1435 of file TosaOps.cpp.

References mlir::detail::DenseArrayAttrImpl< T >::asArrayRef(), b, mlir::tosa::buildUnaryOpQuantizationAttr(), mlir::tosa::createZeroPointTensor(), mlir::emitError(), mlir::tosa::getTosaConstShape(), mlir::Value::getType(), and result.

◆ buildAvgPool2dOpWithQuantInfo()

void buildAvgPool2dOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value input,
DenseArrayAttr kernel,
DenseArrayAttr stride,
DenseArrayAttr pad,
TypeAttr accType )
static

Both the tosa.avg_pool2d and unary ops use the same UnaryOpQuantizationAttr but avg_pool operator has its own builder as it has additional parameters not part of the unary ops.

Definition at line 1391 of file TosaOps.cpp.

References mlir::tosa::buildUnaryOpQuantizationAttr(), mlir::tosa::createZeroPointTensor(), mlir::emitError(), mlir::Value::getType(), and result.

◆ buildConvOpWithQuantInfo()

void buildConvOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value input,
Value weight,
Value bias,
DenseI64ArrayAttr pad,
DenseI64ArrayAttr stride,
DenseI64ArrayAttr dilation,
TypeAttr accType )
static

This builder is called on all convolution operators except TransposeConv, which has specialized output shape semantics.

The builder also defines the bitwidth of the output given the bit width of the input & weight content.

Definition at line 1308 of file TosaOps.cpp.

References mlir::tosa::buildConvOpQuantizationAttr(), mlir::tosa::buildConvOpResultTypeInfo(), mlir::tosa::createZPsAsConst(), and result.

◆ buildMatMulLikeOpWithQuantInfo()

◆ buildMatMulOpWithQuantInfo()

void buildMatMulOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value a,
Value b )
static

Definition at line 1375 of file TosaOps.cpp.

References b, buildMatMulLikeOpWithQuantInfo(), and result.

◆ buildMatMulTOpWithQuantInfo()

void buildMatMulTOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value a,
Value b )
static

Definition at line 1381 of file TosaOps.cpp.

References b, buildMatMulLikeOpWithQuantInfo(), and result.

◆ buildNegateOpWithQuantInfo()

void buildNegateOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value input )
static

This builder is called on single-parameter negate operator to construct input and output zero points based on their types.

Definition at line 1482 of file TosaOps.cpp.

References mlir::tosa::buildUnaryOpQuantizationAttr(), mlir::tosa::createZeroPointTensor(), mlir::emitError(), mlir::Value::getType(), and result.

◆ buildPadOpWithQuantInfo()

void buildPadOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value input,
Value paddings )
static

This builder is called on TOSA pad operator that needs to create its own OptionalAttr quantization_attr parameter to scale the padding values correctly.

No pad_const is interpreted as zero-padding.

Definition at line 1522 of file TosaOps.cpp.

References mlir::tosa::buildPadOpQuantizationAttr(), mlir::tosa::createPadConstTensor(), and result.

◆ buildTransConvOpWithQuantInfo()

void buildTransConvOpWithQuantInfo ( OpBuilder & builder,
OperationState & result,
Type outputType,
Value input,
Value weight,
Value bias,
DenseI64ArrayAttr outpad,
DenseI64ArrayAttr stride,
TypeAttr accType )
static

Handles tosa.transpose_conv2d which has outpad and output shape attributes.

Definition at line 1332 of file TosaOps.cpp.

References mlir::tosa::buildConvOpQuantizationAttr(), mlir::tosa::buildConvOpResultTypeInfo(), mlir::tosa::createZPsAsConst(), and result.

◆ buildVariableOp()

void buildVariableOp ( OpBuilder & builder,
OperationState & result,
StringRef name,
Type variableType,
Attribute initialValue )
static

◆ convertToMlirShape()

SmallVector< int64_t > convertToMlirShape ( ArrayRef< int64_t > shape)
static

Definition at line 138 of file TosaOps.cpp.

Referenced by mlir::tosa::printVariableOpTypeOrInitialValue().

◆ errorIfShapeNotSizeOne()

LogicalResult errorIfShapeNotSizeOne ( Operation * op,
Type type )
inlinestatic

◆ errorIfTypeOrShapeMismatch() [1/2]

LogicalResult errorIfTypeOrShapeMismatch ( Operation * op,
Type type1,
StringRef name1,
Type type2,
StringRef name2 )
static

◆ errorIfTypeOrShapeMismatch() [2/2]

LogicalResult errorIfTypeOrShapeMismatch ( Operation * op,
ValueRange list1,
StringRef name1,
ValueRange list2,
StringRef name2 )
static

◆ extractAdaptivePoolingConstShapeOperands()

template<typename T, typename std::enable_if< IsSupportedAdaptivePoolConstShapeVerifyOp< T >, int >::type = 0>
void extractAdaptivePoolingConstShapeOperands ( T op,
AdaptivePoolingConstShapeValues & values )
static

Definition at line 1201 of file TosaOps.cpp.

References mlir::tosa::getConstShapeValues().

◆ getMatMulBatchDim()

int64_t getMatMulBatchDim ( const ShapeAdaptor & shape,
int64_t outputRank,
int64_t axis )
static

Definition at line 1931 of file TosaOps.cpp.

Referenced by resolveMatMulOutputShape().

◆ getMatMulBatchShape()

SmallVector< int64_t > getMatMulBatchShape ( const ShapeAdaptor & shape)
static

Definition at line 2061 of file TosaOps.cpp.

Referenced by verifyMatMulShapes().

◆ getZeroPoint()

FailureOr< int64_t > getZeroPoint ( Value val,
bool signExtend )
static

◆ idivCheck()

std::optional< int64_t > idivCheck ( const int64_t lhs,
const int64_t rhs )
static

Definition at line 279 of file TosaOps.cpp.

Referenced by verifyConvOutputSize(), and verifyPoolingOpImpl().

◆ inferArgMaxMinReturnTypeComponents()

template<typename A, std::enable_if_t< std::is_same_v< A, ArgMaxOp::Adaptor >||std::is_same_v< A, ArgMinOp::Adaptor >, int > = 0>
LogicalResult inferArgMaxMinReturnTypeComponents ( MLIRContext * context,
::std::optional< Location > location,
A adaptor,
SmallVectorImpl< ShapedTypeComponents > & inferredReturnShapes )

◆ inferConvReturnTypeComponents()

template<typename AdaptorT>
LogicalResult inferConvReturnTypeComponents ( AdaptorT adaptor,
SmallVectorImpl< ShapedTypeComponents > & inferredReturnShapes )

◆ inferMatMulReturnTypeComponents()

LogicalResult inferMatMulReturnTypeComponents ( const ShapeAdaptor & aShape,
const ShapeAdaptor & bShape,
bool transposeB,
SmallVectorImpl< ShapedTypeComponents > & inferredReturnShapes )
static

◆ NAryInferReturnTypes()

LogicalResult NAryInferReturnTypes ( const ValueShapeRange & operands,
SmallVectorImpl< ShapedTypeComponents > & inferredReturnShapes )
static

Definition at line 4111 of file TosaOps.cpp.

References resolveBroadcastShape(), and success().

◆ parseInputUnsigned()

ParseResult parseInputUnsigned ( OpAsmParser & parser,
BoolAttr & result )
static

Definition at line 5986 of file TosaOps.cpp.

References parseOptionalBoolClause(), and result.

◆ parseLocalBound()

ParseResult parseLocalBound ( OpAsmParser & parser,
BoolAttr & result )
static

Definition at line 5978 of file TosaOps.cpp.

References parseOptionalBoolClause(), and result.

◆ parseOptionalBoolClause()

ParseResult parseOptionalBoolClause ( OpAsmParser & parser,
StringRef keyword,
BoolAttr & result )
static

◆ parseScaleValues()

◆ poolingInferReturnTypes()

LogicalResult poolingInferReturnTypes ( ShapeAdaptor inputShape,
ArrayRef< int64_t > kernel,
ArrayRef< int64_t > stride,
ArrayRef< int64_t > pad,
SmallVectorImpl< ShapedTypeComponents > & inferredReturnShapes )
static

◆ printInitializationList()

void printInitializationList ( OpAsmPrinter & parser,
Block::BlockArgListType blocksArgs,
ValueRange initializers,
StringRef prefix = "" )
static

Definition at line 5423 of file TosaOps.cpp.

◆ printInputUnsigned()

void printInputUnsigned ( OpAsmPrinter & printer,
Operation * ,
BoolAttr attr )
static

Definition at line 5990 of file TosaOps.cpp.

References printOptionalBoolClause().

◆ printLocalBound()

void printLocalBound ( OpAsmPrinter & printer,
Operation * ,
BoolAttr attr )
static

Definition at line 5982 of file TosaOps.cpp.

References printOptionalBoolClause().

◆ printOptionalBoolClause()

void printOptionalBoolClause ( OpAsmPrinter & printer,
StringRef keyword,
BoolAttr attr )
static

Definition at line 5969 of file TosaOps.cpp.

References mlir::AsmPrinter::printAttribute().

Referenced by printInputUnsigned(), and printLocalBound().

◆ printScaleValues()

void printScaleValues ( AsmPrinter & printer,
ArrayRef< Attribute > scaleValues,
Type  )
static

Definition at line 547 of file TosaOps.cpp.

References mlir::AsmPrinter::printAttributeWithoutType().

◆ printShapeToDiagnostic()

void printShapeToDiagnostic ( InFlightDiagnostic & diag,
ArrayRef< int64_t > shape )
static

Definition at line 356 of file TosaOps.cpp.

Referenced by verifyMatMulShapes(), and verifyOutputShapeCompatibleWithExpected().

◆ ReduceInferReturnTypes()

LogicalResult ReduceInferReturnTypes ( ShapeAdaptor operandShape,
Type inputType,
IntegerAttr axis,
SmallVectorImpl< ShapedTypeComponents > & inferredReturnShapes )
static

◆ resolveBroadcastDim()

FailureOr< int64_t > resolveBroadcastDim ( const int64_t dim1,
const int64_t dim2 )
static

Definition at line 1566 of file TosaOps.cpp.

Referenced by resolveBroadcastShape(), and resolveMatMulOutputShape().

◆ resolveBroadcastShape()

LogicalResult resolveBroadcastShape ( const ValueShapeRange & operands,
SmallVector< int64_t > & outShape )
static

Definition at line 1580 of file TosaOps.cpp.

References mlir::ValueShapeRange::getShape(), resolveBroadcastDim(), and success().

Referenced by NAryInferReturnTypes().

◆ resolveMatMulOutputShape()

FailureOr< SmallVector< int64_t > > resolveMatMulOutputShape ( const ShapeAdaptor & aShape,
const ShapeAdaptor & bShape,
int64_t outputRank,
bool transposeB )
static

◆ tryUpdateDimOrFailure()

LogicalResult tryUpdateDimOrFailure ( Operation * op,
int64_t & currDim,
const int64_t newDim,
const StringRef operandName,
const StringRef dimName )

Definition at line 341 of file TosaOps.cpp.

References mlir::Operation::emitOpError(), and success().

Referenced by verifyMatMulShapes().

◆ verifyAvgPoolCommonTypeAndZpChecks()

template<typename T>
LogicalResult verifyAvgPoolCommonTypeAndZpChecks ( T op)
static

◆ verifyConvOp()

template<typename T>
LogicalResult verifyConvOp ( T op)
static

◆ verifyConvOpErrorIf()

template<typename T>
LogicalResult verifyConvOpErrorIf ( T op)
static

Definition at line 823 of file TosaOps.cpp.

References success(), and verifyConvOutputSize().

◆ verifyConvOpModes()

template<typename T>
LogicalResult verifyConvOpModes ( T op)
static

Definition at line 801 of file TosaOps.cpp.

References mlir::tosa::getStorageElementTypeFromQuantized(), and success().

◆ verifyConvOutputSize()

LogicalResult verifyConvOutputSize ( Operation * op,
const int64_t inputSize,
const int64_t kernelSize,
const int64_t outputSize,
const int64_t padBefore,
const int64_t padAfter,
const int64_t stride,
const int64_t dilation,
const llvm::StringRef dimName,
const llvm::StringRef dimAxis,
const llvm::StringRef padBeforeName,
const llvm::StringRef padAfterName )

Definition at line 385 of file TosaOps.cpp.

References mlir::Operation::emitOpError(), idivCheck(), and success().

Referenced by verifyConvOpErrorIf().

◆ verifyDimIsPowerOfTwo()

LogicalResult verifyDimIsPowerOfTwo ( Operation * op,
const int64_t dimSize,
const llvm::StringRef dimName )
static

Definition at line 1657 of file TosaOps.cpp.

References mlir::Operation::emitOpError(), and success().

◆ verifyMatMulQuantizedOperandsType()

template<typename T>
LogicalResult verifyMatMulQuantizedOperandsType ( T op,
Type aElementType,
Type bElementType )
static

Definition at line 2009 of file TosaOps.cpp.

References success().

◆ verifyMatMulShapes()

◆ verifyMatMulZeroPointType()

template<typename T>
LogicalResult verifyMatMulZeroPointType ( T op,
Value input,
Value zp,
StringRef inputName,
StringRef zpName )
static

◆ verifyOutputShapeCompatibleWithExpected()

LogicalResult verifyOutputShapeCompatibleWithExpected ( Operation * op,
ShapedType outputType,
ArrayRef< int64_t > expectedShape,
StringRef outputName = "output" )
static

◆ verifyPoolingOp()

template<typename T>
LogicalResult verifyPoolingOp ( T op)
static

Definition at line 1137 of file TosaOps.cpp.

References verifyPoolingOpImpl().

◆ verifyPoolingOpImpl()

LogicalResult verifyPoolingOpImpl ( Operation * op,
ArrayRef< int64_t > kernel,
ArrayRef< int64_t > strides,
ArrayRef< int64_t > padding,
Value input,
Value output )
static

◆ verifyReduceOp()

template<typename T>
LogicalResult verifyReduceOp ( T op)
static

◆ verifyRescaleValueAndZpTypes()

LogicalResult verifyRescaleValueAndZpTypes ( Operation * op,
Value val,
Value valZp,
StringRef name )
static

◆ verifySameElementTypes()

LogicalResult verifySameElementTypes ( Operation * op,
Type aType,
Type bType,
StringRef aName = "input",
StringRef bName = "output" )
static

Definition at line 1003 of file TosaOps.cpp.

References mlir::Operation::emitOpError(), and success().

Referenced by verifyPoolingOpImpl().

◆ verifyVariableOpErrorIf()

template<typename T>
LogicalResult verifyVariableOpErrorIf ( T op,
Type type,
StringRef name )
static

◆ verifyZeroPoint() [1/2]

template<typename T>
LogicalResult verifyZeroPoint ( T op,
Value val,
const int64_t & zp,
const std::string & operand )
static

Definition at line 3187 of file TosaOps.cpp.

References mlir::getElementTypeOrSelf(), mlir::Type::isInteger(), and success().

◆ verifyZeroPoint() [2/2]

LogicalResult verifyZeroPoint ( tosa::RescaleOp op,
Value zpVal,
const int64_t & zp,
const std::string & operand )
static

Definition at line 3202 of file TosaOps.cpp.

References mlir::getElementTypeOrSelf(), mlir::Type::isInteger(), and success().

Variable Documentation

◆ IsSupportedAdaptivePoolConstShapeVerifyOp

template<typename T>
bool IsSupportedAdaptivePoolConstShapeVerifyOp
staticconstexpr
Initial value:
=
std::is_same_v<T, tosa::AvgPool2dAdaptiveOp> ||
std::is_same_v<T, tosa::MaxPool2dAdaptiveOp>

Definition at line 1194 of file TosaOps.cpp.