13 #ifndef MLIR_DIALECT_TOSA_IR_TOSAOPS_H
14 #define MLIR_DIALECT_TOSA_IR_TOSAOPS_H
30 #include "mlir/Dialect/Tosa/IR/TosaOpsDialect.h.inc"
33 class PatternRewriter;
42 #include "mlir/Dialect/Tosa/IR/TosaInterfaces.h.inc"
51 template <
typename ConcreteType>
53 :
public TraitBase<ConcreteType, MulOperandsAndResultElementType> {
60 if (llvm::isa<FloatType>(resElemType))
63 if (
auto resIntType = dyn_cast<IntegerType>(resElemType)) {
64 IntegerType lhsIntType =
66 IntegerType rhsIntType =
68 if (lhsIntType != rhsIntType)
70 "requires the same element type for all operands");
75 if (lhsIntType.getWidth() > resIntType.getWidth())
76 return op->
emitOpError(
"invalid data type size for operands or result");
89 template <
typename ConcreteType>
91 :
public TraitBase<ConcreteType, TosaElementwiseOperator> {};
95 template <
typename ConcreteType>
97 :
public TraitBase<ConcreteType, TosaResolvableShapeOperands> {
106 template <
typename ConcreteType>
116 template <
typename ConcreteType>
118 :
public TraitBase<ConcreteType, TosaShapeOperatorWithSameRanks> {
136 #define GET_ATTRDEF_CLASSES
137 #include "mlir/Dialect/Tosa/IR/TosaAttributes.h.inc"
139 #define GET_TYPEDEF_CLASSES
140 #include "mlir/Dialect/Tosa/IR/TosaOpsTypesBase.h.inc"
142 #define GET_OP_CLASSES
143 #include "mlir/Dialect/Tosa/IR/TosaOps.h.inc"
Helper class for implementing traits.
static LogicalResult verifyTrait(Operation *op)
This class indicates that an op is tosa-elementwise (permits broadcasting, unlike Elementwise trait).
This class verifies that tosa shape operands are compile time resolvable.
static LogicalResult verifyTrait(Operation *op)
This class indicates that op operates on tosa shape types.
static LogicalResult verifyTrait(Operation *op)
This class indicates that op operates on tosa shape types.
static LogicalResult verifyTrait(Operation *op)
Operation is the basic unit of execution within MLIR.
Value getOperand(unsigned idx)
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
LogicalResult verifySameOperandsAndResultElementType(Operation *op)
LogicalResult verifyTosaShapeOperator(Operation *op)
LogicalResult verifyTosaShapeOperatorWithSameRanks(Operation *op)
LogicalResult verifyTosaResolvableShapeOperands(Operation *op)
ParseResult parseTypeOrAttr(OpAsmParser &parser, TypeAttr &typeAttr, Attribute &attr)
bool isa_tosa_shape_type(mlir::Type t)
void printTypeOrAttr(OpAsmPrinter &p, Operation *op, TypeAttr type, Attribute attr)
Include the generated interface declarations.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.