MLIR: include/mlir/Dialect/Tosa/IR/TosaProfileCompliance.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9 #ifndef MLIR_DIALECT_TOSA_TRANSFORMS_TOSAPROFILECOMPILANCE_H
10 #define MLIR_DIALECT_TOSA_TRANSFORMS_TOSAPROFILECOMPILANCE_H
11
12 #include <unordered_map>
13
16
18
19 using namespace mlir;
21
22
23
24
25
26 typedef struct {
30
33
35
38
39 template
41
42
46 };
47
49 std::unordered_map<std::string, SmallVector<OpComplianceInfo>>;
51 std::unordered_map<std::string, SmallVector<OpComplianceInfo>>;
52
53
54
55
56
58 public:
60 if (failed(populatationDispatch(op)))
61 op->emitOpError() << "fail to populate the profile info\n";
62 }
63
64 void addType(Type t) { tyInfo.push_back(convertTypeToInfo(t)); }
65 void addValue(Value v) { tyInfo.push_back(convertValueToInfo(v)); }
67
68 private:
71 }
72
75 }
76
77 LogicalResult populatationDispatch(Operation *op);
78
79 LogicalResult populateProfileInfo(ValueRange operands, Value output);
80
81
82 template
83 LogicalResult populateProfileInfo(T op) {
84 return op->emitOpError()
85 << "profile requirement for this op has not been defined";
86 }
87
88 template
89 LogicalResult populateProfileInfoConv(T op);
90
91
92 template
93 LogicalResult populateProfileInfoDataLayout(T op);
94
95 private:
97 };
98
99
100
101
102
104 public:
106
107
108 template
109 std::unordered_map<std::string, SmallVector<OpComplianceInfo>>
111
112 return {};
113 }
114
115
116
119 LogicalResult checkInvalid(Operation *op);
120
121 template
122 LogicalResult checkProfileOrExtension(
125
128 }
129
130
131
132 template
136
138 switch (ext) {
139 case Extension::int16:
140 case Extension::int4:
141 case Extension::doubleround:
142 case Extension::inexactround:
143 return {Profile::pro_int};
144 case Extension::bf16:
145 case Extension::fp8e4m3:
146 case Extension::fp8e5m2:
147 case Extension::fft:
148 return {Profile::pro_fp};
149 case Extension::variable:
150 case Extension::controlflow:
151 case Extension::dynamic:
152 return {Profile::pro_fp, Profile::pro_int};
153 case Extension::none:
154 return {};
155 };
156 llvm_unreachable("bad Extension type");
157 }
158
159
160 template
162
163 template
166
168
169 private:
170 template
171 FailureOr<SmallVector> getOperatorDefinition(Operation *op,
173
176 };
177
178 #endif
std::unordered_map< std::string, SmallVector< OpComplianceInfo< Profile > >> OperationProfileComplianceMap
std::unordered_map< std::string, SmallVector< OpComplianceInfo< Extension > >> OperationExtensionComplianceMap
ProfileInfoDepot(Operation *op)
SmallVector< TypeInfo > getInfo()
SmallVector< Profile > getCooperativeProfiles(Extension ext)
bool isSameTypeInfo(TypeInfo a, TypeInfo b)
std::unordered_map< std::string, SmallVector< OpComplianceInfo< T > > > getProfileComplianceMap()
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.
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
This class provides an abstraction over the different types of ranges over Values.
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,...
Include the generated interface declarations.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
SmallVector< SmallVector< TypeInfo > > operandTypeInfoSet