1 // clang-format off
2 // Generated file (from: div_v1_2.mod.py). Do not edit
CreateModel(Model * model)3 void CreateModel(Model *model) {
4 OperandType type0(Type::TENSOR_FLOAT16, {3});
5 OperandType type1(Type::INT32, {});
6 // Phase 1, operands
7 auto op1 = model->addOperand(&type0);
8 auto op2 = model->addOperand(&type0);
9 auto act = model->addOperand(&type1);
10 auto op3 = model->addOperand(&type0);
11 // Phase 2, operations
12 static int32_t act_init[] = {0};
13 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
14 model->addOperation(ANEURALNETWORKS_DIV, {op1, op2, act}, {op3});
15 // Phase 3, inputs and outputs
16 model->identifyInputsAndOutputs(
17 {op1, op2},
18 {op3});
19 assert(model->isValid());
20 }
21
is_ignored(int i)22 inline bool is_ignored(int i) {
23 static std::set<int> ignore = {};
24 return ignore.find(i) != ignore.end();
25 }
26
CreateModel_dynamic_output_shape(Model * model)27 void CreateModel_dynamic_output_shape(Model *model) {
28 OperandType type0(Type::TENSOR_FLOAT16, {3});
29 OperandType type1(Type::INT32, {});
30 OperandType type15(Type::TENSOR_FLOAT16, {0});
31 // Phase 1, operands
32 auto op1 = model->addOperand(&type0);
33 auto op2 = model->addOperand(&type0);
34 auto act = model->addOperand(&type1);
35 auto op3 = model->addOperand(&type15);
36 // Phase 2, operations
37 static int32_t act_init[] = {0};
38 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
39 model->addOperation(ANEURALNETWORKS_DIV, {op1, op2, act}, {op3});
40 // Phase 3, inputs and outputs
41 model->identifyInputsAndOutputs(
42 {op1, op2},
43 {op3});
44 assert(model->isValid());
45 }
46
is_ignored_dynamic_output_shape(int i)47 inline bool is_ignored_dynamic_output_shape(int i) {
48 static std::set<int> ignore = {};
49 return ignore.find(i) != ignore.end();
50 }
51
CreateModel_2(Model * model)52 void CreateModel_2(Model *model) {
53 OperandType type1(Type::INT32, {});
54 OperandType type2(Type::TENSOR_FLOAT16, {2, 2});
55 OperandType type3(Type::TENSOR_FLOAT16, {1, 2});
56 // Phase 1, operands
57 auto op11 = model->addOperand(&type2);
58 auto op21 = model->addOperand(&type3);
59 auto act1 = model->addOperand(&type1);
60 auto op31 = model->addOperand(&type2);
61 // Phase 2, operations
62 static int32_t act1_init[] = {0};
63 model->setOperandValue(act1, act1_init, sizeof(int32_t) * 1);
64 model->addOperation(ANEURALNETWORKS_DIV, {op11, op21, act1}, {op31});
65 // Phase 3, inputs and outputs
66 model->identifyInputsAndOutputs(
67 {op11, op21},
68 {op31});
69 assert(model->isValid());
70 }
71
is_ignored_2(int i)72 inline bool is_ignored_2(int i) {
73 static std::set<int> ignore = {};
74 return ignore.find(i) != ignore.end();
75 }
76
CreateModel_dynamic_output_shape_2(Model * model)77 void CreateModel_dynamic_output_shape_2(Model *model) {
78 OperandType type1(Type::INT32, {});
79 OperandType type16(Type::TENSOR_FLOAT16, {0, 0});
80 OperandType type2(Type::TENSOR_FLOAT16, {2, 2});
81 OperandType type3(Type::TENSOR_FLOAT16, {1, 2});
82 // Phase 1, operands
83 auto op11 = model->addOperand(&type2);
84 auto op21 = model->addOperand(&type3);
85 auto act1 = model->addOperand(&type1);
86 auto op31 = model->addOperand(&type16);
87 // Phase 2, operations
88 static int32_t act1_init[] = {0};
89 model->setOperandValue(act1, act1_init, sizeof(int32_t) * 1);
90 model->addOperation(ANEURALNETWORKS_DIV, {op11, op21, act1}, {op31});
91 // Phase 3, inputs and outputs
92 model->identifyInputsAndOutputs(
93 {op11, op21},
94 {op31});
95 assert(model->isValid());
96 }
97
is_ignored_dynamic_output_shape_2(int i)98 inline bool is_ignored_dynamic_output_shape_2(int i) {
99 static std::set<int> ignore = {};
100 return ignore.find(i) != ignore.end();
101 }
102
CreateModel_zero_sized(Model * model)103 void CreateModel_zero_sized(Model *model) {
104 OperandType type1(Type::INT32, {});
105 OperandType type10(Type::FLOAT32, {});
106 OperandType type11(Type::BOOL, {});
107 OperandType type12(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
108 OperandType type13(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
109 OperandType type14(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
110 OperandType type4(Type::TENSOR_FLOAT32, {1, 2});
111 OperandType type5(Type::TENSOR_FLOAT32, {1, 8});
112 OperandType type6(Type::TENSOR_FLOAT32, {0});
113 OperandType type7(Type::TENSOR_INT32, {0});
114 OperandType type8(Type::TENSOR_FLOAT32, {0, 4});
115 OperandType type9(Type::TENSOR_INT32, {1});
116 // Phase 1, operands
117 auto scores = model->addOperand(&type4);
118 auto roi = model->addOperand(&type5);
119 auto param = model->addOperand(&type9);
120 auto param1 = model->addOperand(&type10);
121 auto param2 = model->addOperand(&type1);
122 auto param3 = model->addOperand(&type1);
123 auto param4 = model->addOperand(&type10);
124 auto param5 = model->addOperand(&type10);
125 auto param6 = model->addOperand(&type10);
126 auto scoresOut = model->addOperand(&type6);
127 auto roiOut = model->addOperand(&type8);
128 auto classesOut = model->addOperand(&type7);
129 auto batchSplitOut = model->addOperand(&type7);
130 auto in = model->addOperand(&type12);
131 auto param7 = model->addOperand(&type1);
132 auto param8 = model->addOperand(&type1);
133 auto param9 = model->addOperand(&type10);
134 auto param10 = model->addOperand(&type10);
135 auto param11 = model->addOperand(&type1);
136 auto param12 = model->addOperand(&type1);
137 auto layout = model->addOperand(&type11);
138 auto featureMap = model->addOperand(&type13);
139 auto op = model->addOperand(&type14);
140 auto param13 = model->addOperand(&type1);
141 auto out = model->addOperand(&type13);
142 // Phase 2, operations
143 static float scores_init[] = {0.9f, 0.1f};
144 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
145 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
146 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
147 static int32_t param_init[] = {0};
148 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
149 static float param1_init[] = {0.3f};
150 model->setOperandValue(param1, param1_init, sizeof(float) * 1);
151 static int32_t param2_init[] = {-1};
152 model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
153 static int32_t param3_init[] = {0};
154 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
155 static float param4_init[] = {0.4f};
156 model->setOperandValue(param4, param4_init, sizeof(float) * 1);
157 static float param5_init[] = {1.0f};
158 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
159 static float param6_init[] = {0.3f};
160 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
161 static int32_t param7_init[] = {2};
162 model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
163 static int32_t param8_init[] = {2};
164 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
165 static float param9_init[] = {2.0f};
166 model->setOperandValue(param9, param9_init, sizeof(float) * 1);
167 static float param10_init[] = {2.0f};
168 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
169 static int32_t param11_init[] = {4};
170 model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
171 static int32_t param12_init[] = {4};
172 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
173 static bool8 layout_init[] = {false};
174 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
175 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
176 model->setOperandValue(op, op_init, sizeof(float) * 4);
177 static int32_t param13_init[] = {0};
178 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
179 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
180 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
181 model->addOperation(ANEURALNETWORKS_DIV, {featureMap, op, param13}, {out});
182 // Phase 3, inputs and outputs
183 model->identifyInputsAndOutputs(
184 {in},
185 {scoresOut, classesOut, out});
186 assert(model->isValid());
187 }
188
is_ignored_zero_sized(int i)189 inline bool is_ignored_zero_sized(int i) {
190 static std::set<int> ignore = {};
191 return ignore.find(i) != ignore.end();
192 }
193
CreateModel_zero_sized_relaxed(Model * model)194 void CreateModel_zero_sized_relaxed(Model *model) {
195 OperandType type1(Type::INT32, {});
196 OperandType type10(Type::FLOAT32, {});
197 OperandType type11(Type::BOOL, {});
198 OperandType type12(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
199 OperandType type13(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
200 OperandType type14(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
201 OperandType type4(Type::TENSOR_FLOAT32, {1, 2});
202 OperandType type5(Type::TENSOR_FLOAT32, {1, 8});
203 OperandType type6(Type::TENSOR_FLOAT32, {0});
204 OperandType type7(Type::TENSOR_INT32, {0});
205 OperandType type8(Type::TENSOR_FLOAT32, {0, 4});
206 OperandType type9(Type::TENSOR_INT32, {1});
207 // Phase 1, operands
208 auto scores = model->addOperand(&type4);
209 auto roi = model->addOperand(&type5);
210 auto param = model->addOperand(&type9);
211 auto param1 = model->addOperand(&type10);
212 auto param2 = model->addOperand(&type1);
213 auto param3 = model->addOperand(&type1);
214 auto param4 = model->addOperand(&type10);
215 auto param5 = model->addOperand(&type10);
216 auto param6 = model->addOperand(&type10);
217 auto scoresOut = model->addOperand(&type6);
218 auto roiOut = model->addOperand(&type8);
219 auto classesOut = model->addOperand(&type7);
220 auto batchSplitOut = model->addOperand(&type7);
221 auto in = model->addOperand(&type12);
222 auto param7 = model->addOperand(&type1);
223 auto param8 = model->addOperand(&type1);
224 auto param9 = model->addOperand(&type10);
225 auto param10 = model->addOperand(&type10);
226 auto param11 = model->addOperand(&type1);
227 auto param12 = model->addOperand(&type1);
228 auto layout = model->addOperand(&type11);
229 auto featureMap = model->addOperand(&type13);
230 auto op = model->addOperand(&type14);
231 auto param13 = model->addOperand(&type1);
232 auto out = model->addOperand(&type13);
233 // Phase 2, operations
234 static float scores_init[] = {0.9f, 0.1f};
235 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
236 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
237 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
238 static int32_t param_init[] = {0};
239 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
240 static float param1_init[] = {0.3f};
241 model->setOperandValue(param1, param1_init, sizeof(float) * 1);
242 static int32_t param2_init[] = {-1};
243 model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
244 static int32_t param3_init[] = {0};
245 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
246 static float param4_init[] = {0.4f};
247 model->setOperandValue(param4, param4_init, sizeof(float) * 1);
248 static float param5_init[] = {1.0f};
249 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
250 static float param6_init[] = {0.3f};
251 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
252 static int32_t param7_init[] = {2};
253 model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
254 static int32_t param8_init[] = {2};
255 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
256 static float param9_init[] = {2.0f};
257 model->setOperandValue(param9, param9_init, sizeof(float) * 1);
258 static float param10_init[] = {2.0f};
259 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
260 static int32_t param11_init[] = {4};
261 model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
262 static int32_t param12_init[] = {4};
263 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
264 static bool8 layout_init[] = {false};
265 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
266 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
267 model->setOperandValue(op, op_init, sizeof(float) * 4);
268 static int32_t param13_init[] = {0};
269 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
270 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
271 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
272 model->addOperation(ANEURALNETWORKS_DIV, {featureMap, op, param13}, {out});
273 // Phase 3, inputs and outputs
274 model->identifyInputsAndOutputs(
275 {in},
276 {scoresOut, classesOut, out});
277 // Phase 4: set relaxed execution
278 model->relaxComputationFloat32toFloat16(true);
279 assert(model->isValid());
280 }
281
is_ignored_zero_sized_relaxed(int i)282 inline bool is_ignored_zero_sized_relaxed(int i) {
283 static std::set<int> ignore = {};
284 return ignore.find(i) != ignore.end();
285 }
286
CreateModel_zero_sized_float16(Model * model)287 void CreateModel_zero_sized_float16(Model *model) {
288 OperandType type1(Type::INT32, {});
289 OperandType type11(Type::BOOL, {});
290 OperandType type17(Type::TENSOR_FLOAT16, {0, 2, 2, 2});
291 OperandType type18(Type::TENSOR_FLOAT16, {1, 1, 1, 2});
292 OperandType type19(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
293 OperandType type20(Type::FLOAT16, {});
294 OperandType type21(Type::TENSOR_FLOAT16, {1, 8});
295 OperandType type22(Type::TENSOR_FLOAT16, {0, 4});
296 OperandType type23(Type::TENSOR_FLOAT16, {1, 2});
297 OperandType type24(Type::TENSOR_FLOAT16, {0});
298 OperandType type7(Type::TENSOR_INT32, {0});
299 OperandType type9(Type::TENSOR_INT32, {1});
300 // Phase 1, operands
301 auto scores = model->addOperand(&type23);
302 auto roi = model->addOperand(&type21);
303 auto param = model->addOperand(&type9);
304 auto param1 = model->addOperand(&type20);
305 auto param2 = model->addOperand(&type1);
306 auto param3 = model->addOperand(&type1);
307 auto param4 = model->addOperand(&type20);
308 auto param5 = model->addOperand(&type20);
309 auto param6 = model->addOperand(&type20);
310 auto scoresOut = model->addOperand(&type24);
311 auto roiOut = model->addOperand(&type22);
312 auto classesOut = model->addOperand(&type7);
313 auto batchSplitOut = model->addOperand(&type7);
314 auto in = model->addOperand(&type18);
315 auto param7 = model->addOperand(&type1);
316 auto param8 = model->addOperand(&type1);
317 auto param9 = model->addOperand(&type20);
318 auto param10 = model->addOperand(&type20);
319 auto param11 = model->addOperand(&type1);
320 auto param12 = model->addOperand(&type1);
321 auto layout = model->addOperand(&type11);
322 auto featureMap = model->addOperand(&type17);
323 auto op = model->addOperand(&type19);
324 auto param13 = model->addOperand(&type1);
325 auto out = model->addOperand(&type17);
326 // Phase 2, operations
327 static _Float16 scores_init[] = {0.8999999761581421f, 0.10000000149011612f};
328 model->setOperandValue(scores, scores_init, sizeof(_Float16) * 2);
329 static _Float16 roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
330 model->setOperandValue(roi, roi_init, sizeof(_Float16) * 8);
331 static int32_t param_init[] = {0};
332 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
333 static _Float16 param1_init[] = {0.30000001192092896f};
334 model->setOperandValue(param1, param1_init, sizeof(_Float16) * 1);
335 static int32_t param2_init[] = {-1};
336 model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
337 static int32_t param3_init[] = {0};
338 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
339 static _Float16 param4_init[] = {0.4000000059604645f};
340 model->setOperandValue(param4, param4_init, sizeof(_Float16) * 1);
341 static _Float16 param5_init[] = {1.0f};
342 model->setOperandValue(param5, param5_init, sizeof(_Float16) * 1);
343 static _Float16 param6_init[] = {0.30000001192092896f};
344 model->setOperandValue(param6, param6_init, sizeof(_Float16) * 1);
345 static int32_t param7_init[] = {2};
346 model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
347 static int32_t param8_init[] = {2};
348 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
349 static _Float16 param9_init[] = {2.0f};
350 model->setOperandValue(param9, param9_init, sizeof(_Float16) * 1);
351 static _Float16 param10_init[] = {2.0f};
352 model->setOperandValue(param10, param10_init, sizeof(_Float16) * 1);
353 static int32_t param11_init[] = {4};
354 model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
355 static int32_t param12_init[] = {4};
356 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
357 static bool8 layout_init[] = {false};
358 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
359 static _Float16 op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
360 model->setOperandValue(op, op_init, sizeof(_Float16) * 4);
361 static int32_t param13_init[] = {0};
362 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
363 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
364 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
365 model->addOperation(ANEURALNETWORKS_DIV, {featureMap, op, param13}, {out});
366 // Phase 3, inputs and outputs
367 model->identifyInputsAndOutputs(
368 {in},
369 {scoresOut, classesOut, out});
370 assert(model->isValid());
371 }
372
is_ignored_zero_sized_float16(int i)373 inline bool is_ignored_zero_sized_float16(int i) {
374 static std::set<int> ignore = {};
375 return ignore.find(i) != ignore.end();
376 }
377
CreateModel_zero_sized_dynamic_output_shape(Model * model)378 void CreateModel_zero_sized_dynamic_output_shape(Model *model) {
379 OperandType type1(Type::INT32, {});
380 OperandType type10(Type::FLOAT32, {});
381 OperandType type11(Type::BOOL, {});
382 OperandType type12(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
383 OperandType type13(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
384 OperandType type14(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
385 OperandType type25(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
386 OperandType type4(Type::TENSOR_FLOAT32, {1, 2});
387 OperandType type5(Type::TENSOR_FLOAT32, {1, 8});
388 OperandType type6(Type::TENSOR_FLOAT32, {0});
389 OperandType type7(Type::TENSOR_INT32, {0});
390 OperandType type8(Type::TENSOR_FLOAT32, {0, 4});
391 OperandType type9(Type::TENSOR_INT32, {1});
392 // Phase 1, operands
393 auto scores = model->addOperand(&type4);
394 auto roi = model->addOperand(&type5);
395 auto param = model->addOperand(&type9);
396 auto param1 = model->addOperand(&type10);
397 auto param2 = model->addOperand(&type1);
398 auto param3 = model->addOperand(&type1);
399 auto param4 = model->addOperand(&type10);
400 auto param5 = model->addOperand(&type10);
401 auto param6 = model->addOperand(&type10);
402 auto scoresOut = model->addOperand(&type6);
403 auto roiOut = model->addOperand(&type8);
404 auto classesOut = model->addOperand(&type7);
405 auto batchSplitOut = model->addOperand(&type7);
406 auto in = model->addOperand(&type12);
407 auto param7 = model->addOperand(&type1);
408 auto param8 = model->addOperand(&type1);
409 auto param9 = model->addOperand(&type10);
410 auto param10 = model->addOperand(&type10);
411 auto param11 = model->addOperand(&type1);
412 auto param12 = model->addOperand(&type1);
413 auto layout = model->addOperand(&type11);
414 auto featureMap = model->addOperand(&type13);
415 auto op = model->addOperand(&type14);
416 auto param13 = model->addOperand(&type1);
417 auto out = model->addOperand(&type25);
418 // Phase 2, operations
419 static float scores_init[] = {0.9f, 0.1f};
420 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
421 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
422 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
423 static int32_t param_init[] = {0};
424 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
425 static float param1_init[] = {0.3f};
426 model->setOperandValue(param1, param1_init, sizeof(float) * 1);
427 static int32_t param2_init[] = {-1};
428 model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
429 static int32_t param3_init[] = {0};
430 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
431 static float param4_init[] = {0.4f};
432 model->setOperandValue(param4, param4_init, sizeof(float) * 1);
433 static float param5_init[] = {1.0f};
434 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
435 static float param6_init[] = {0.3f};
436 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
437 static int32_t param7_init[] = {2};
438 model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
439 static int32_t param8_init[] = {2};
440 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
441 static float param9_init[] = {2.0f};
442 model->setOperandValue(param9, param9_init, sizeof(float) * 1);
443 static float param10_init[] = {2.0f};
444 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
445 static int32_t param11_init[] = {4};
446 model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
447 static int32_t param12_init[] = {4};
448 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
449 static bool8 layout_init[] = {false};
450 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
451 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
452 model->setOperandValue(op, op_init, sizeof(float) * 4);
453 static int32_t param13_init[] = {0};
454 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
455 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
456 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
457 model->addOperation(ANEURALNETWORKS_DIV, {featureMap, op, param13}, {out});
458 // Phase 3, inputs and outputs
459 model->identifyInputsAndOutputs(
460 {in},
461 {scoresOut, classesOut, out});
462 assert(model->isValid());
463 }
464
is_ignored_zero_sized_dynamic_output_shape(int i)465 inline bool is_ignored_zero_sized_dynamic_output_shape(int i) {
466 static std::set<int> ignore = {};
467 return ignore.find(i) != ignore.end();
468 }
469
CreateModel_zero_sized_dynamic_output_shape_relaxed(Model * model)470 void CreateModel_zero_sized_dynamic_output_shape_relaxed(Model *model) {
471 OperandType type1(Type::INT32, {});
472 OperandType type10(Type::FLOAT32, {});
473 OperandType type11(Type::BOOL, {});
474 OperandType type12(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
475 OperandType type13(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
476 OperandType type14(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
477 OperandType type25(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
478 OperandType type4(Type::TENSOR_FLOAT32, {1, 2});
479 OperandType type5(Type::TENSOR_FLOAT32, {1, 8});
480 OperandType type6(Type::TENSOR_FLOAT32, {0});
481 OperandType type7(Type::TENSOR_INT32, {0});
482 OperandType type8(Type::TENSOR_FLOAT32, {0, 4});
483 OperandType type9(Type::TENSOR_INT32, {1});
484 // Phase 1, operands
485 auto scores = model->addOperand(&type4);
486 auto roi = model->addOperand(&type5);
487 auto param = model->addOperand(&type9);
488 auto param1 = model->addOperand(&type10);
489 auto param2 = model->addOperand(&type1);
490 auto param3 = model->addOperand(&type1);
491 auto param4 = model->addOperand(&type10);
492 auto param5 = model->addOperand(&type10);
493 auto param6 = model->addOperand(&type10);
494 auto scoresOut = model->addOperand(&type6);
495 auto roiOut = model->addOperand(&type8);
496 auto classesOut = model->addOperand(&type7);
497 auto batchSplitOut = model->addOperand(&type7);
498 auto in = model->addOperand(&type12);
499 auto param7 = model->addOperand(&type1);
500 auto param8 = model->addOperand(&type1);
501 auto param9 = model->addOperand(&type10);
502 auto param10 = model->addOperand(&type10);
503 auto param11 = model->addOperand(&type1);
504 auto param12 = model->addOperand(&type1);
505 auto layout = model->addOperand(&type11);
506 auto featureMap = model->addOperand(&type13);
507 auto op = model->addOperand(&type14);
508 auto param13 = model->addOperand(&type1);
509 auto out = model->addOperand(&type25);
510 // Phase 2, operations
511 static float scores_init[] = {0.9f, 0.1f};
512 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
513 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
514 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
515 static int32_t param_init[] = {0};
516 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
517 static float param1_init[] = {0.3f};
518 model->setOperandValue(param1, param1_init, sizeof(float) * 1);
519 static int32_t param2_init[] = {-1};
520 model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
521 static int32_t param3_init[] = {0};
522 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
523 static float param4_init[] = {0.4f};
524 model->setOperandValue(param4, param4_init, sizeof(float) * 1);
525 static float param5_init[] = {1.0f};
526 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
527 static float param6_init[] = {0.3f};
528 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
529 static int32_t param7_init[] = {2};
530 model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
531 static int32_t param8_init[] = {2};
532 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
533 static float param9_init[] = {2.0f};
534 model->setOperandValue(param9, param9_init, sizeof(float) * 1);
535 static float param10_init[] = {2.0f};
536 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
537 static int32_t param11_init[] = {4};
538 model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
539 static int32_t param12_init[] = {4};
540 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
541 static bool8 layout_init[] = {false};
542 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
543 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
544 model->setOperandValue(op, op_init, sizeof(float) * 4);
545 static int32_t param13_init[] = {0};
546 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
547 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
548 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
549 model->addOperation(ANEURALNETWORKS_DIV, {featureMap, op, param13}, {out});
550 // Phase 3, inputs and outputs
551 model->identifyInputsAndOutputs(
552 {in},
553 {scoresOut, classesOut, out});
554 // Phase 4: set relaxed execution
555 model->relaxComputationFloat32toFloat16(true);
556 assert(model->isValid());
557 }
558
is_ignored_zero_sized_dynamic_output_shape_relaxed(int i)559 inline bool is_ignored_zero_sized_dynamic_output_shape_relaxed(int i) {
560 static std::set<int> ignore = {};
561 return ignore.find(i) != ignore.end();
562 }
563
CreateModel_zero_sized_dynamic_output_shape_float16(Model * model)564 void CreateModel_zero_sized_dynamic_output_shape_float16(Model *model) {
565 OperandType type1(Type::INT32, {});
566 OperandType type11(Type::BOOL, {});
567 OperandType type15(Type::TENSOR_FLOAT16, {0});
568 OperandType type17(Type::TENSOR_FLOAT16, {0, 2, 2, 2});
569 OperandType type18(Type::TENSOR_FLOAT16, {1, 1, 1, 2});
570 OperandType type19(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
571 OperandType type20(Type::FLOAT16, {});
572 OperandType type21(Type::TENSOR_FLOAT16, {1, 8});
573 OperandType type22(Type::TENSOR_FLOAT16, {0, 4});
574 OperandType type23(Type::TENSOR_FLOAT16, {1, 2});
575 OperandType type26(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
576 OperandType type7(Type::TENSOR_INT32, {0});
577 OperandType type9(Type::TENSOR_INT32, {1});
578 // Phase 1, operands
579 auto scores = model->addOperand(&type23);
580 auto roi = model->addOperand(&type21);
581 auto param = model->addOperand(&type9);
582 auto param1 = model->addOperand(&type20);
583 auto param2 = model->addOperand(&type1);
584 auto param3 = model->addOperand(&type1);
585 auto param4 = model->addOperand(&type20);
586 auto param5 = model->addOperand(&type20);
587 auto param6 = model->addOperand(&type20);
588 auto scoresOut = model->addOperand(&type15);
589 auto roiOut = model->addOperand(&type22);
590 auto classesOut = model->addOperand(&type7);
591 auto batchSplitOut = model->addOperand(&type7);
592 auto in = model->addOperand(&type18);
593 auto param7 = model->addOperand(&type1);
594 auto param8 = model->addOperand(&type1);
595 auto param9 = model->addOperand(&type20);
596 auto param10 = model->addOperand(&type20);
597 auto param11 = model->addOperand(&type1);
598 auto param12 = model->addOperand(&type1);
599 auto layout = model->addOperand(&type11);
600 auto featureMap = model->addOperand(&type17);
601 auto op = model->addOperand(&type19);
602 auto param13 = model->addOperand(&type1);
603 auto out = model->addOperand(&type26);
604 // Phase 2, operations
605 static _Float16 scores_init[] = {0.8999999761581421f, 0.10000000149011612f};
606 model->setOperandValue(scores, scores_init, sizeof(_Float16) * 2);
607 static _Float16 roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
608 model->setOperandValue(roi, roi_init, sizeof(_Float16) * 8);
609 static int32_t param_init[] = {0};
610 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
611 static _Float16 param1_init[] = {0.30000001192092896f};
612 model->setOperandValue(param1, param1_init, sizeof(_Float16) * 1);
613 static int32_t param2_init[] = {-1};
614 model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
615 static int32_t param3_init[] = {0};
616 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
617 static _Float16 param4_init[] = {0.4000000059604645f};
618 model->setOperandValue(param4, param4_init, sizeof(_Float16) * 1);
619 static _Float16 param5_init[] = {1.0f};
620 model->setOperandValue(param5, param5_init, sizeof(_Float16) * 1);
621 static _Float16 param6_init[] = {0.30000001192092896f};
622 model->setOperandValue(param6, param6_init, sizeof(_Float16) * 1);
623 static int32_t param7_init[] = {2};
624 model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
625 static int32_t param8_init[] = {2};
626 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
627 static _Float16 param9_init[] = {2.0f};
628 model->setOperandValue(param9, param9_init, sizeof(_Float16) * 1);
629 static _Float16 param10_init[] = {2.0f};
630 model->setOperandValue(param10, param10_init, sizeof(_Float16) * 1);
631 static int32_t param11_init[] = {4};
632 model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
633 static int32_t param12_init[] = {4};
634 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
635 static bool8 layout_init[] = {false};
636 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
637 static _Float16 op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
638 model->setOperandValue(op, op_init, sizeof(_Float16) * 4);
639 static int32_t param13_init[] = {0};
640 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
641 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
642 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
643 model->addOperation(ANEURALNETWORKS_DIV, {featureMap, op, param13}, {out});
644 // Phase 3, inputs and outputs
645 model->identifyInputsAndOutputs(
646 {in},
647 {scoresOut, classesOut, out});
648 assert(model->isValid());
649 }
650
is_ignored_zero_sized_dynamic_output_shape_float16(int i)651 inline bool is_ignored_zero_sized_dynamic_output_shape_float16(int i) {
652 static std::set<int> ignore = {};
653 return ignore.find(i) != ignore.end();
654 }
655
656