blob: f1d1680863b7b3d98e7caf5107fd5b22d2be85fb [file] [log] [blame]
Eric Kunzee5e26762020-10-13 16:11:07 -07001
Tai Lya4d748b2023-03-28 22:06:56 +00002// Copyright (c) 2020-2023, ARM Limited.
Eric Kunzee5e26762020-10-13 16:11:07 -07003//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef OPS_OP_FACTORY_H
17#define OPS_OP_FACTORY_H
18
19#include "attribute.h"
20#include "graph_node.h"
Eric Kunzee5e26762020-10-13 16:11:07 -070021#include "template_types.h"
22#include "tosa_serialization_handler.h"
23
24#define DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, RANK, DTYPE) \
25 case RANK: \
Tai Lya4d748b2023-03-28 22:06:56 +000026 return new OP<RANK, TOSA_REF_TYPE_##DTYPE>(sgt, attribute, id);
Eric Kunzee5e26762020-10-13 16:11:07 -070027
28#define DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, RANK, DTYPE1, DTYPE2) \
29 case RANK: \
Tai Lya4d748b2023-03-28 22:06:56 +000030 return new OP<RANK, TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2>(sgt, attribute, id);
Eric Kunzee5e26762020-10-13 16:11:07 -070031
32#define DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, RANK1, RANK2, DTYPE) \
33 case RANK2: \
Tai Lya4d748b2023-03-28 22:06:56 +000034 return new OP<RANK1, RANK2, TOSA_REF_TYPE_##DTYPE>(sgt, attribute, id);
Eric Kunzee5e26762020-10-13 16:11:07 -070035
36#define DEF_FACTORY_TWO_RANK_TWO_TYPE(OP, RANK1, RANK2, DTYPE1, DTYPE2) \
37 case RANK2: \
Tai Lya4d748b2023-03-28 22:06:56 +000038 return new OP<RANK1, RANK2, TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2>(sgt, attribute, id);
Eric Kunzee5e26762020-10-13 16:11:07 -070039
40#define DEF_FACTORY_ONE_RANK_0_6(OP) \
41 switch (inputRank) \
42 { \
43 case 0: \
TatWai Chongf7326092022-06-08 12:17:14 -070044 return new OP<0>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070045 case 1: \
TatWai Chongf7326092022-06-08 12:17:14 -070046 return new OP<1>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070047 case 2: \
TatWai Chongf7326092022-06-08 12:17:14 -070048 return new OP<2>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070049 case 3: \
TatWai Chongf7326092022-06-08 12:17:14 -070050 return new OP<3>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070051 case 4: \
TatWai Chongf7326092022-06-08 12:17:14 -070052 return new OP<4>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070053 case 5: \
TatWai Chongf7326092022-06-08 12:17:14 -070054 return new OP<5>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070055 case 6: \
TatWai Chongf7326092022-06-08 12:17:14 -070056 return new OP<6>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070057 }
58
59#define DEF_FACTORY_ONE_TYPE(OP, DTYPE) \
Tai Lya4d748b2023-03-28 22:06:56 +000060 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE) \
Eric Kunzee5e26762020-10-13 16:11:07 -070061 { \
Tai Lya4d748b2023-03-28 22:06:56 +000062 return new OP<TOSA_REF_TYPE_##DTYPE>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070063 }
64
Tai Ly8ead6c42024-02-14 22:35:44 +000065#define DEF_FACTORY_ONE_TYPE_ONE_ACCUM(OP, ATTR_NAME, DTYPE, ACC_TYPE) \
66 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE && ACCUM_FROM_ATTRIBUTE(ATTR_NAME) == TOSA_REF_TYPE_##ACC_TYPE) \
James Ward8b390432022-08-12 20:48:56 +010067 { \
Tai Ly8ead6c42024-02-14 22:35:44 +000068 return new OP<TOSA_REF_TYPE_##DTYPE, TOSA_REF_TYPE_##ACC_TYPE>(sgt, attribute, id); \
James Ward8b390432022-08-12 20:48:56 +010069 }
70
Eric Kunzee5e26762020-10-13 16:11:07 -070071#define DEF_FACTORY_TWO_TYPE(OP, DTYPE1, DTYPE2) \
Tai Lya4d748b2023-03-28 22:06:56 +000072 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && weightDTYPE == TOSA_REF_TYPE_##DTYPE2) \
Eric Kunzee5e26762020-10-13 16:11:07 -070073 { \
Tai Lya4d748b2023-03-28 22:06:56 +000074 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -070075 }
76
James Wardd34b3fc2023-01-18 14:51:25 +000077#define DEF_FACTORY_TWO_TYPE_IN_OUT(OP, DTYPE1, DTYPE2) \
Tai Lya4d748b2023-03-28 22:06:56 +000078 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
James Wardd34b3fc2023-01-18 14:51:25 +000079 { \
Tai Lya4d748b2023-03-28 22:06:56 +000080 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2>(sgt, attribute, id); \
James Wardd34b3fc2023-01-18 14:51:25 +000081 }
82
Tai Ly8ead6c42024-02-14 22:35:44 +000083#define DEF_FACTORY_TWO_TYPE_ONE_ACCUM(OP, ATTR_NAME, DTYPE1, DTYPE2, ACC_TYPE) \
Tai Lya4d748b2023-03-28 22:06:56 +000084 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && weightDTYPE == TOSA_REF_TYPE_##DTYPE2 && \
Tai Ly8ead6c42024-02-14 22:35:44 +000085 ACCUM_FROM_ATTRIBUTE(ATTR_NAME) == TOSA_REF_TYPE_##ACC_TYPE) \
James Ward8b390432022-08-12 20:48:56 +010086 { \
Tai Ly8ead6c42024-02-14 22:35:44 +000087 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, TOSA_REF_TYPE_##ACC_TYPE>(sgt, attribute, id); \
Tai Lya4d748b2023-03-28 22:06:56 +000088 }
James Ward8b390432022-08-12 20:48:56 +010089
James Wardd34b3fc2023-01-18 14:51:25 +000090#define DEF_FACTORY_THREE_TYPE(OP, DTYPE1, DTYPE2, DTYPE3) \
Tai Lya4d748b2023-03-28 22:06:56 +000091 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && weightDTYPE == TOSA_REF_TYPE_##DTYPE2 && \
92 outputDTYPE == TOSA_REF_TYPE_##DTYPE3) \
James Wardd34b3fc2023-01-18 14:51:25 +000093 { \
Tai Lya4d748b2023-03-28 22:06:56 +000094 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, TOSA_REF_TYPE_##DTYPE3>(sgt, attribute, id); \
James Wardd34b3fc2023-01-18 14:51:25 +000095 }
96
Tai Lyf36f2562024-03-14 16:21:29 +000097#define DEF_FACTORY_THREE_TYPE_ONE_ACCUM(OP, ATTR_NAME, IN_DTYPE, W_DTYPE, ACC_DTYPE, OUT_DTYPE) \
98 if (inputDTYPE == TOSA_REF_TYPE_##IN_DTYPE && weightDTYPE == TOSA_REF_TYPE_##W_DTYPE && \
99 outputDTYPE == TOSA_REF_TYPE_##OUT_DTYPE && ACCUM_FROM_ATTRIBUTE(ATTR_NAME) == TOSA_REF_TYPE_##ACC_DTYPE) \
100 { \
101 return new OP<TOSA_REF_TYPE_##IN_DTYPE, TOSA_REF_TYPE_##W_DTYPE, TOSA_REF_TYPE_##ACC_DTYPE, \
102 TOSA_REF_TYPE_##OUT_DTYPE>(sgt, attribute, id); \
103 }
104
James Ward8b390432022-08-12 20:48:56 +0100105// Statement-expression to evaluate accumulate attribute in-place
106#define ACCUM_FROM_ATTRIBUTE(ATTRIBUTE_NAME) \
107 ({ \
108 tosa::DType accumDType = tosa::DType_UNKNOWN; \
109 if (auto p = dynamic_cast<tosa::Tosa##ATTRIBUTE_NAME##Attribute*>(attribute)) \
110 { \
111 auto attr = new tosa::Tosa##ATTRIBUTE_NAME##Attribute(p); \
112 ASSERT_MEM(attr); \
Tai Ly8ead6c42024-02-14 22:35:44 +0000113 accumDType = tosa::EnumValuesDType()[attr->acc_type()]; \
James Ward8b390432022-08-12 20:48:56 +0100114 } \
115 else \
116 { \
117 FATAL_ERROR("Can't initialize Tosa" #ATTRIBUTE_NAME "Attribute.\nPre-initialization " \
118 "of this attribute is required in order to determine the accumulate type."); \
119 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000120 ConvertDType(accumDType); \
Tai Lya4d748b2023-03-28 22:06:56 +0000121 })
James Ward8b390432022-08-12 20:48:56 +0100122
TatWai Chongf7326092022-06-08 12:17:14 -0700123#define DEF_FACTORY_TWO_TYPE_RESIZE_INT16(OP, DTYPE1, DTYPE2) \
Tai Lya4d748b2023-03-28 22:06:56 +0000124 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
Eric Kunzee5e26762020-10-13 16:11:07 -0700125 { \
Tai Lya4d748b2023-03-28 22:06:56 +0000126 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, int16_t>(sgt, attribute, id); \
TatWai Chongf7326092022-06-08 12:17:14 -0700127 }
128
James Ward8b390432022-08-12 20:48:56 +0100129#define DEF_FACTORY_TWO_TYPE_RESIZE_FP16(OP, DTYPE1, DTYPE2) \
Tai Lya4d748b2023-03-28 22:06:56 +0000130 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
James Ward8b390432022-08-12 20:48:56 +0100131 { \
Tai Lya4d748b2023-03-28 22:06:56 +0000132 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, half_float::half>(sgt, attribute, id); \
James Ward8b390432022-08-12 20:48:56 +0100133 }
134
James Ward24dbc422022-10-19 12:20:31 +0100135#define DEF_FACTORY_TWO_TYPE_RESIZE_BF16(OP, DTYPE1, DTYPE2) \
Tai Lya4d748b2023-03-28 22:06:56 +0000136 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
James Ward24dbc422022-10-19 12:20:31 +0100137 { \
Tai Lya4d748b2023-03-28 22:06:56 +0000138 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, Eigen::bfloat16>(sgt, attribute, id); \
James Ward24dbc422022-10-19 12:20:31 +0100139 }
140
Tai Lya4d748b2023-03-28 22:06:56 +0000141#define DEF_FACTORY_TWO_TYPE_RESIZE_FP32(OP, DTYPE1, DTYPE2) \
142 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
TatWai Chongf7326092022-06-08 12:17:14 -0700143 { \
Tai Lya4d748b2023-03-28 22:06:56 +0000144 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, float>(sgt, attribute, id); \
145 }
146
147#define DEF_FACTORY_TWO_TYPE_RESIZE_FP64(OP, DTYPE1, DTYPE2) \
148 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
149 { \
150 return new OP<TOSA_REF_TYPE_##DTYPE1, TOSA_REF_TYPE_##DTYPE2, double>(sgt, attribute, id); \
Eric Kunzee5e26762020-10-13 16:11:07 -0700151 }
152
153#define DEF_FACTORY_RANK0_6_ONE_RANK_ONE_TYPE(OP, DTYPE) \
Tai Lya4d748b2023-03-28 22:06:56 +0000154 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE) \
Eric Kunzee5e26762020-10-13 16:11:07 -0700155 { \
156 switch (inputRank) \
157 { \
158 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 0, DTYPE) \
159 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 1, DTYPE) \
160 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 2, DTYPE) \
161 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 3, DTYPE) \
162 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 4, DTYPE) \
163 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 5, DTYPE) \
164 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 6, DTYPE) \
165 } \
166 }
167
168#define DEF_FACTORY_RANK1_6_ONE_RANK_ONE_TYPE(OP, DTYPE) \
Tai Lya4d748b2023-03-28 22:06:56 +0000169 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE) \
Eric Kunzee5e26762020-10-13 16:11:07 -0700170 { \
171 switch (inputRank) \
172 { \
173 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 1, DTYPE) \
174 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 2, DTYPE) \
175 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 3, DTYPE) \
176 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 4, DTYPE) \
177 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 5, DTYPE) \
178 DEF_FACTORY_ONE_RANK_ONE_TYPE(OP, 6, DTYPE) \
179 } \
180 }
181
182#define DEF_FACTORY_RANK0_6_ONE_RANK_TWO_TYPE(OP, DTYPE1, DTYPE2) \
Tai Lya4d748b2023-03-28 22:06:56 +0000183 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE1 && outputDTYPE == TOSA_REF_TYPE_##DTYPE2) \
Eric Kunzee5e26762020-10-13 16:11:07 -0700184 { \
185 switch (inputRank) \
186 { \
187 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 0, DTYPE1, DTYPE2) \
188 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 1, DTYPE1, DTYPE2) \
189 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 2, DTYPE1, DTYPE2) \
190 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 3, DTYPE1, DTYPE2) \
191 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 4, DTYPE1, DTYPE2) \
192 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 5, DTYPE1, DTYPE2) \
193 DEF_FACTORY_ONE_RANK_TWO_TYPE(OP, 6, DTYPE1, DTYPE2) \
194 } \
195 }
196
197#define DEF_FACTORY_RESHAPE(OP, DTYPE) \
Tai Lya4d748b2023-03-28 22:06:56 +0000198 if (inputDTYPE == TOSA_REF_TYPE_##DTYPE && outputDTYPE == TOSA_REF_TYPE_##DTYPE) \
Eric Kunzee5e26762020-10-13 16:11:07 -0700199 { \
200 switch (inputRank) \
201 { \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000202 case 0: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700203 switch (outputRank) \
204 { \
205 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 0, DTYPE) \
206 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 1, DTYPE) \
207 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 2, DTYPE) \
208 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 3, DTYPE) \
209 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 4, DTYPE) \
210 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 5, DTYPE) \
211 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 0, 6, DTYPE) \
212 } \
213 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000214 case 1: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700215 switch (outputRank) \
216 { \
217 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 0, DTYPE) \
218 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 1, DTYPE) \
219 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 2, DTYPE) \
220 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 3, DTYPE) \
221 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 4, DTYPE) \
222 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 5, DTYPE) \
223 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 1, 6, DTYPE) \
224 } \
225 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000226 case 2: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700227 switch (outputRank) \
228 { \
229 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 0, DTYPE) \
230 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 1, DTYPE) \
231 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 2, DTYPE) \
232 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 3, DTYPE) \
233 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 4, DTYPE) \
234 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 5, DTYPE) \
235 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 2, 6, DTYPE) \
236 } \
237 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000238 case 3: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700239 switch (outputRank) \
240 { \
241 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 0, DTYPE) \
242 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 1, DTYPE) \
243 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 2, DTYPE) \
244 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 3, DTYPE) \
245 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 4, DTYPE) \
246 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 5, DTYPE) \
247 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 3, 6, DTYPE) \
248 } \
249 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000250 case 4: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700251 switch (outputRank) \
252 { \
253 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 0, DTYPE) \
254 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 1, DTYPE) \
255 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 2, DTYPE) \
256 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 3, DTYPE) \
257 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 4, DTYPE) \
258 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 5, DTYPE) \
259 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 4, 6, DTYPE) \
260 } \
261 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000262 case 5: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700263 switch (outputRank) \
264 { \
265 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 0, DTYPE) \
266 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 1, DTYPE) \
267 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 2, DTYPE) \
268 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 3, DTYPE) \
269 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 4, DTYPE) \
270 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 5, DTYPE) \
271 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 5, 6, DTYPE) \
272 } \
273 } \
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000274 case 6: { \
Eric Kunzee5e26762020-10-13 16:11:07 -0700275 switch (outputRank) \
276 { \
277 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 0, DTYPE) \
278 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 1, DTYPE) \
279 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 2, DTYPE) \
280 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 3, DTYPE) \
281 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 4, DTYPE) \
282 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 5, DTYPE) \
283 DEF_FACTORY_TWO_RANK_ONE_TYPE(OP, 6, 6, DTYPE) \
284 } \
285 } \
286 } \
287 }
288
Eric Kunzee5e26762020-10-13 16:11:07 -0700289namespace TosaReference
290{
291
Kevin Chengacb550f2021-06-29 15:32:19 -0700292class SubgraphTraverser;
293class GraphNode;
294
Eric Kunzee5e26762020-10-13 16:11:07 -0700295class OpFactory
296{
297public:
Kevin Chengacb550f2021-06-29 15:32:19 -0700298 static GraphNode* newOp(SubgraphTraverser* sgt,
299 tosa::TosaSerializationHandler* tsh,
Eric Kunzee5e26762020-10-13 16:11:07 -0700300 tosa::Op opType,
301 tosa::TosaAttributeBase* attribute,
Eric Kunzee5e26762020-10-13 16:11:07 -0700302 uint64_t id,
Tai Lya4d748b2023-03-28 22:06:56 +0000303 TOSA_REF_TYPE inputDTYPE,
Eric Kunzee5e26762020-10-13 16:11:07 -0700304 int inputRank,
Tai Lya4d748b2023-03-28 22:06:56 +0000305 TOSA_REF_TYPE outputDTYPE,
Eric Kunzee5e26762020-10-13 16:11:07 -0700306 int outputRank,
Tai Lya4d748b2023-03-28 22:06:56 +0000307 TOSA_REF_TYPE weightDTYPE,
Eric Kunzee5e26762020-10-13 16:11:07 -0700308 int weightRank);
309};
310}; // namespace TosaReference
311
312#endif