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"
56#include "mlir/Dialect/Tosa/IR/TosaInterfaces.h.inc"
65template <
typename ConcreteType>
67 :
public TraitBase<ConcreteType, MulOperandsAndResultElementType> {
88 if (lhsElemType != rhsElemType)
89 return op->
emitOpError(
"requires the same element type for all operands");
94 if (
auto resIntType = dyn_cast<IntegerType>(resElemType)) {
95 auto lhsIntType = cast<IntegerType>(lhsElemType);
96 if (lhsIntType.getWidth() > resIntType.getWidth())
97 return op->
emitOpError(
"invalid data type size for operands or result");
101 if (resElemType != lhsElemType)
103 "requires the same element type for all operands and results");
106 return llvm::success();
112template <
typename ConcreteType>
114 :
public TraitBase<ConcreteType, TosaElementwiseOperator> {};
118template <
typename ConcreteType>
120 :
public TraitBase<ConcreteType, TosaResolvableShapeOperands> {
129template <
typename ConcreteType>
139template <
typename ConcreteType>
141 :
public TraitBase<ConcreteType, TosaShapeOperatorWithSameRanks> {
159#define GET_ATTRDEF_CLASSES
160#include "mlir/Dialect/Tosa/IR/TosaAttributes.h.inc"
162#define GET_TYPEDEF_CLASSES
163#include "mlir/Dialect/Tosa/IR/TosaOpsTypesBase.h.inc"
165#define GET_OP_CLASSES
166#include "mlir/Dialect/Tosa/IR/TosaOps.h.inc"
173 Type srcElemType,
int64_t zp = 0);
Attributes are known-constant values of operations.
An attribute that represents a reference to a dense vector or tensor object.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
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.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
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)
RankedTensorType getVariableType(VariableOp variableOp)
ParseResult parseVariableOpTypeOrInitialValue(OpAsmParser &parser, DenseElementsAttr &varShapeAttr, TypeAttr &typeAttr, Attribute &initialValueAttr)
void printVariableOpTypeOrInitialValue(OpAsmPrinter &p, Operation *op, DenseElementsAttr varShapeAttr, TypeAttr typeAttr, Attribute initialValueAttr)
unsigned getBitWidth(Type type)
std::optional< Value > createZeroPointTensor(OpBuilder &builder, Location loc, Type srcElemType, int64_t zp=0)
bool isa_tosa_shape_type(mlir::Type t)
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.