13 #ifndef MLIR_DIALECT_TOSA_IR_TOSAOPS_H
14 #define MLIR_DIALECT_TOSA_IR_TOSAOPS_H
32 #include "mlir/Dialect/Tosa/IR/TosaEnums.h.inc"
33 #include "mlir/Dialect/Tosa/IR/TosaOpsDialect.h.inc"
40 #include "mlir/Dialect/Tosa/IR/TosaAvailability.h.inc"
43 class PatternRewriter;
52 #include "mlir/Dialect/Tosa/IR/TosaInterfaces.h.inc"
61 template <
typename ConcreteType>
63 :
public TraitBase<ConcreteType, MulOperandsAndResultElementType> {
84 if (lhsElemType != rhsElemType)
85 return op->
emitOpError(
"requires the same element type for all operands");
90 if (
auto resIntType = dyn_cast<IntegerType>(resElemType)) {
91 auto lhsIntType = cast<IntegerType>(lhsElemType);
92 if (lhsIntType.getWidth() > resIntType.getWidth())
93 return op->
emitOpError(
"invalid data type size for operands or result");
97 if (resElemType != lhsElemType)
99 "requires the same element type for all operands and results");
102 return llvm::success();
108 template <
typename ConcreteType>
110 :
public TraitBase<ConcreteType, TosaElementwiseOperator> {};
114 template <
typename ConcreteType>
116 :
public TraitBase<ConcreteType, TosaResolvableShapeOperands> {
125 template <
typename ConcreteType>
135 template <
typename ConcreteType>
137 :
public TraitBase<ConcreteType, TosaShapeOperatorWithSameRanks> {
155 #define GET_ATTRDEF_CLASSES
156 #include "mlir/Dialect/Tosa/IR/TosaAttributes.h.inc"
158 #define GET_TYPEDEF_CLASSES
159 #include "mlir/Dialect/Tosa/IR/TosaOpsTypesBase.h.inc"
161 #define GET_OP_CLASSES
162 #include "mlir/Dialect/Tosa/IR/TosaOps.h.inc"
169 Type srcElemType, int64_t zp = 0);
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...
bool isInteger() const
Return true if this is an integer type (with the specified width).
LogicalResult verifyNOperands(Operation *op, unsigned numOperands)
LogicalResult verifyAtLeastNOperands(Operation *op, unsigned numOperands)
LogicalResult verifyOneResult(Operation *op)
LogicalResult verifyTosaShapeOperator(Operation *op)
LogicalResult verifyTosaShapeOperatorWithSameRanks(Operation *op)
LogicalResult verifyTosaResolvableShapeOperands(Operation *op)
ParseResult parseTypeOrAttr(OpAsmParser &parser, TypeAttr &typeAttr, Attribute &attr)
std::optional< Value > createZeroPointTensor(OpBuilder &builder, Location loc, Type srcElemType, int64_t zp=0)
bool isa_tosa_shape_type(mlir::Type t)
void printTypeOrAttr(OpAsmPrinter &p, Operation *op, TypeAttr type, Attribute attr)
Value createPadConstTensor(OpBuilder &builder, Location loc, Value src, int32_t val=0)
Include the generated interface declarations.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.