9#ifndef MLIR_DIALECT_TOSA_TRANSFORMS_TOSAPROFILECOMPILANCE_H
10#define MLIR_DIALECT_TOSA_TRANSFORMS_TOSAPROFILECOMPILANCE_H
12#include <unordered_map>
52 std::pair<SmallVector<TypeInfo>, SpecificationVersion>;
64 std::unordered_map<std::string, SmallVector<OpComplianceInfo<Profile>>>;
66 std::unordered_map<std::string, SmallVector<OpComplianceInfo<Extension>>>;
75 if (failed(populatationDispatch(op)))
76 op->
emitOpError() <<
"fail to populate the profile info\n";
79 void addType(
Type t) { tyInfo.push_back(convertTypeToInfo(t)); }
85 if (
auto blockScaledTy = dyn_cast<tosa::BlockScaledType>(type)) {
86 Type valueTy = blockScaledTy.getValueType();
87 Type scaleTy = blockScaledTy.getScaleType();
89 scaleTy.
getTypeID(), blockScaledTy.getBlockShape()};
94 TypeInfo convertValueToInfo(Value value) {
98 LogicalResult populatationDispatch(Operation *op);
104 template <
typename T>
105 LogicalResult populateProfileInfo(T op) {
106 return op->emitOpError()
107 <<
"profile requirement for this op has not been defined";
110 template <
typename T>
111 LogicalResult populateProfileInfoConv(T op);
114 template <
typename T>
115 LogicalResult populateProfileInfoDataLayout(T op);
118 SmallVector<TypeInfo> tyInfo;
130 template <
typename T>
131 std::unordered_map<std::string, SmallVector<OpComplianceInfo<T>>>
143 template <
typename T>
156 template <
typename T>
161 template <
typename T>
164 template <
typename T>
171 template <
typename T>
172 FailureOr<SmallVector<OpComplianceInfo<T>>>
173 getOperatorMatchedEntries(
Operation *op);
std::unordered_map< std::string, SmallVector< OpComplianceInfo< Profile > > > OperationProfileComplianceMap
std::pair< SmallVector< TypeInfo >, SpecificationVersion > VersionedTypeInfo
std::unordered_map< std::string, SmallVector< OpComplianceInfo< Extension > > > OperationExtensionComplianceMap
ProfileInfoDepot(Operation *op)
SmallVector< TypeInfo > getInfo()
bool isSameTypeInfo(TypeInfo a, TypeInfo b)
LogicalResult checkProfile(Operation *op, const tosa::TargetEnv &targetEnv)
static llvm::SmallString< 32 > stringifyTypeInfo(const TypeInfo &typeInfo)
LogicalResult checkExtension(Operation *op, const tosa::TargetEnv &targetEnv)
LogicalResult checkInvalid(Operation *op)
SmallVector< StringRef > stringifyProfile(ArrayRef< T > profiles)
LogicalResult checkProfileOrExtension(Operation *op, const tosa::TargetEnv &targetEnv, const SmallVector< ArrayRef< T > > &specDefinedProfileSet)
std::unordered_map< std::string, SmallVector< OpComplianceInfo< T > > > getProfileComplianceMap()
SmallVector< OpComplianceInfo< T > > findMatchedEntries(Operation *op, SmallVector< OpComplianceInfo< T > > compInfo)
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class provides an efficient unique identifier for a specific C++ type.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
TypeID getTypeID()
Return a unique identifier for the concrete type.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
This class represents the capability enabled in the target implementation such as profile,...
unsigned getBitWidth(Type type)
Include the generated interface declarations.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
SmallVector< VersionedTypeInfo > operandTypeInfoSet
TypeInfo(mlir::TypeID typeID, uint32_t bitWidth)
TypeInfo(mlir::TypeID typeID, uint32_t bitWidth, mlir::TypeID valueTypeID, mlir::TypeID scaleTypeID, tosa::BlockShape blockShape)
std::optional< tosa::BlockShape > blockShape