1 // clang-format off
2 // Generated file (from: sub_v1_2.mod.py). Do not edit
CreateModel_none(Model * model)3 void CreateModel_none(Model *model) {
4 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
5 OperandType type1(Type::INT32, {});
6 // Phase 1, operands
7 auto input0 = model->addOperand(&type0);
8 auto input1 = model->addOperand(&type0);
9 auto act = model->addOperand(&type1);
10 auto output0 = 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_SUB, {input0, input1, act}, {output0});
15 // Phase 3, inputs and outputs
16 model->identifyInputsAndOutputs(
17 {input0, input1},
18 {output0});
19 assert(model->isValid());
20 }
21
is_ignored_none(int i)22 inline bool is_ignored_none(int i) {
23 static std::set<int> ignore = {};
24 return ignore.find(i) != ignore.end();
25 }
26
CreateModel_relu(Model * model)27 void CreateModel_relu(Model *model) {
28 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
29 OperandType type1(Type::INT32, {});
30 // Phase 1, operands
31 auto input0 = model->addOperand(&type0);
32 auto input1 = model->addOperand(&type0);
33 auto act = model->addOperand(&type1);
34 auto output0 = model->addOperand(&type0);
35 // Phase 2, operations
36 static int32_t act_init[] = {1};
37 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
38 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
39 // Phase 3, inputs and outputs
40 model->identifyInputsAndOutputs(
41 {input0, input1},
42 {output0});
43 assert(model->isValid());
44 }
45
is_ignored_relu(int i)46 inline bool is_ignored_relu(int i) {
47 static std::set<int> ignore = {};
48 return ignore.find(i) != ignore.end();
49 }
50
CreateModel_relu1(Model * model)51 void CreateModel_relu1(Model *model) {
52 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
53 OperandType type1(Type::INT32, {});
54 // Phase 1, operands
55 auto input0 = model->addOperand(&type0);
56 auto input1 = model->addOperand(&type0);
57 auto act = model->addOperand(&type1);
58 auto output0 = model->addOperand(&type0);
59 // Phase 2, operations
60 static int32_t act_init[] = {2};
61 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
62 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
63 // Phase 3, inputs and outputs
64 model->identifyInputsAndOutputs(
65 {input0, input1},
66 {output0});
67 assert(model->isValid());
68 }
69
is_ignored_relu1(int i)70 inline bool is_ignored_relu1(int i) {
71 static std::set<int> ignore = {};
72 return ignore.find(i) != ignore.end();
73 }
74
CreateModel_relu6(Model * model)75 void CreateModel_relu6(Model *model) {
76 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
77 OperandType type1(Type::INT32, {});
78 // Phase 1, operands
79 auto input0 = model->addOperand(&type0);
80 auto input1 = model->addOperand(&type0);
81 auto act = model->addOperand(&type1);
82 auto output0 = model->addOperand(&type0);
83 // Phase 2, operations
84 static int32_t act_init[] = {3};
85 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
86 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
87 // Phase 3, inputs and outputs
88 model->identifyInputsAndOutputs(
89 {input0, input1},
90 {output0});
91 assert(model->isValid());
92 }
93
is_ignored_relu6(int i)94 inline bool is_ignored_relu6(int i) {
95 static std::set<int> ignore = {};
96 return ignore.find(i) != ignore.end();
97 }
98
CreateModel_float16_none(Model * model)99 void CreateModel_float16_none(Model *model) {
100 OperandType type1(Type::INT32, {});
101 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
102 // Phase 1, operands
103 auto input0 = model->addOperand(&type13);
104 auto input1 = model->addOperand(&type13);
105 auto act = model->addOperand(&type1);
106 auto output0 = model->addOperand(&type13);
107 // Phase 2, operations
108 static int32_t act_init[] = {0};
109 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
110 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
111 // Phase 3, inputs and outputs
112 model->identifyInputsAndOutputs(
113 {input0, input1},
114 {output0});
115 assert(model->isValid());
116 }
117
is_ignored_float16_none(int i)118 inline bool is_ignored_float16_none(int i) {
119 static std::set<int> ignore = {};
120 return ignore.find(i) != ignore.end();
121 }
122
CreateModel_float16_relu(Model * model)123 void CreateModel_float16_relu(Model *model) {
124 OperandType type1(Type::INT32, {});
125 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
126 // Phase 1, operands
127 auto input0 = model->addOperand(&type13);
128 auto input1 = model->addOperand(&type13);
129 auto act = model->addOperand(&type1);
130 auto output0 = model->addOperand(&type13);
131 // Phase 2, operations
132 static int32_t act_init[] = {1};
133 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
134 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
135 // Phase 3, inputs and outputs
136 model->identifyInputsAndOutputs(
137 {input0, input1},
138 {output0});
139 assert(model->isValid());
140 }
141
is_ignored_float16_relu(int i)142 inline bool is_ignored_float16_relu(int i) {
143 static std::set<int> ignore = {};
144 return ignore.find(i) != ignore.end();
145 }
146
CreateModel_float16_relu1(Model * model)147 void CreateModel_float16_relu1(Model *model) {
148 OperandType type1(Type::INT32, {});
149 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
150 // Phase 1, operands
151 auto input0 = model->addOperand(&type13);
152 auto input1 = model->addOperand(&type13);
153 auto act = model->addOperand(&type1);
154 auto output0 = model->addOperand(&type13);
155 // Phase 2, operations
156 static int32_t act_init[] = {2};
157 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
158 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
159 // Phase 3, inputs and outputs
160 model->identifyInputsAndOutputs(
161 {input0, input1},
162 {output0});
163 assert(model->isValid());
164 }
165
is_ignored_float16_relu1(int i)166 inline bool is_ignored_float16_relu1(int i) {
167 static std::set<int> ignore = {};
168 return ignore.find(i) != ignore.end();
169 }
170
CreateModel_float16_relu6(Model * model)171 void CreateModel_float16_relu6(Model *model) {
172 OperandType type1(Type::INT32, {});
173 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
174 // Phase 1, operands
175 auto input0 = model->addOperand(&type13);
176 auto input1 = model->addOperand(&type13);
177 auto act = model->addOperand(&type1);
178 auto output0 = model->addOperand(&type13);
179 // Phase 2, operations
180 static int32_t act_init[] = {3};
181 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
182 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
183 // Phase 3, inputs and outputs
184 model->identifyInputsAndOutputs(
185 {input0, input1},
186 {output0});
187 assert(model->isValid());
188 }
189
is_ignored_float16_relu6(int i)190 inline bool is_ignored_float16_relu6(int i) {
191 static std::set<int> ignore = {};
192 return ignore.find(i) != ignore.end();
193 }
194
CreateModel_dynamic_output_shape_none(Model * model)195 void CreateModel_dynamic_output_shape_none(Model *model) {
196 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
197 OperandType type1(Type::INT32, {});
198 OperandType type14(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
199 // Phase 1, operands
200 auto input0 = model->addOperand(&type0);
201 auto input1 = model->addOperand(&type0);
202 auto act = model->addOperand(&type1);
203 auto output0 = model->addOperand(&type14);
204 // Phase 2, operations
205 static int32_t act_init[] = {0};
206 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
207 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
208 // Phase 3, inputs and outputs
209 model->identifyInputsAndOutputs(
210 {input0, input1},
211 {output0});
212 assert(model->isValid());
213 }
214
is_ignored_dynamic_output_shape_none(int i)215 inline bool is_ignored_dynamic_output_shape_none(int i) {
216 static std::set<int> ignore = {};
217 return ignore.find(i) != ignore.end();
218 }
219
CreateModel_dynamic_output_shape_relu(Model * model)220 void CreateModel_dynamic_output_shape_relu(Model *model) {
221 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
222 OperandType type1(Type::INT32, {});
223 OperandType type14(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
224 // Phase 1, operands
225 auto input0 = model->addOperand(&type0);
226 auto input1 = model->addOperand(&type0);
227 auto act = model->addOperand(&type1);
228 auto output0 = model->addOperand(&type14);
229 // Phase 2, operations
230 static int32_t act_init[] = {1};
231 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
232 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
233 // Phase 3, inputs and outputs
234 model->identifyInputsAndOutputs(
235 {input0, input1},
236 {output0});
237 assert(model->isValid());
238 }
239
is_ignored_dynamic_output_shape_relu(int i)240 inline bool is_ignored_dynamic_output_shape_relu(int i) {
241 static std::set<int> ignore = {};
242 return ignore.find(i) != ignore.end();
243 }
244
CreateModel_dynamic_output_shape_relu1(Model * model)245 void CreateModel_dynamic_output_shape_relu1(Model *model) {
246 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
247 OperandType type1(Type::INT32, {});
248 OperandType type14(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
249 // Phase 1, operands
250 auto input0 = model->addOperand(&type0);
251 auto input1 = model->addOperand(&type0);
252 auto act = model->addOperand(&type1);
253 auto output0 = model->addOperand(&type14);
254 // Phase 2, operations
255 static int32_t act_init[] = {2};
256 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
257 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
258 // Phase 3, inputs and outputs
259 model->identifyInputsAndOutputs(
260 {input0, input1},
261 {output0});
262 assert(model->isValid());
263 }
264
is_ignored_dynamic_output_shape_relu1(int i)265 inline bool is_ignored_dynamic_output_shape_relu1(int i) {
266 static std::set<int> ignore = {};
267 return ignore.find(i) != ignore.end();
268 }
269
CreateModel_dynamic_output_shape_relu6(Model * model)270 void CreateModel_dynamic_output_shape_relu6(Model *model) {
271 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
272 OperandType type1(Type::INT32, {});
273 OperandType type14(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
274 // Phase 1, operands
275 auto input0 = model->addOperand(&type0);
276 auto input1 = model->addOperand(&type0);
277 auto act = model->addOperand(&type1);
278 auto output0 = model->addOperand(&type14);
279 // Phase 2, operations
280 static int32_t act_init[] = {3};
281 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
282 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
283 // Phase 3, inputs and outputs
284 model->identifyInputsAndOutputs(
285 {input0, input1},
286 {output0});
287 assert(model->isValid());
288 }
289
is_ignored_dynamic_output_shape_relu6(int i)290 inline bool is_ignored_dynamic_output_shape_relu6(int i) {
291 static std::set<int> ignore = {};
292 return ignore.find(i) != ignore.end();
293 }
294
CreateModel_dynamic_output_shape_float16_none(Model * model)295 void CreateModel_dynamic_output_shape_float16_none(Model *model) {
296 OperandType type1(Type::INT32, {});
297 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
298 OperandType type15(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
299 // Phase 1, operands
300 auto input0 = model->addOperand(&type13);
301 auto input1 = model->addOperand(&type13);
302 auto act = model->addOperand(&type1);
303 auto output0 = model->addOperand(&type15);
304 // Phase 2, operations
305 static int32_t act_init[] = {0};
306 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
307 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
308 // Phase 3, inputs and outputs
309 model->identifyInputsAndOutputs(
310 {input0, input1},
311 {output0});
312 assert(model->isValid());
313 }
314
is_ignored_dynamic_output_shape_float16_none(int i)315 inline bool is_ignored_dynamic_output_shape_float16_none(int i) {
316 static std::set<int> ignore = {};
317 return ignore.find(i) != ignore.end();
318 }
319
CreateModel_dynamic_output_shape_float16_relu(Model * model)320 void CreateModel_dynamic_output_shape_float16_relu(Model *model) {
321 OperandType type1(Type::INT32, {});
322 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
323 OperandType type15(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
324 // Phase 1, operands
325 auto input0 = model->addOperand(&type13);
326 auto input1 = model->addOperand(&type13);
327 auto act = model->addOperand(&type1);
328 auto output0 = model->addOperand(&type15);
329 // Phase 2, operations
330 static int32_t act_init[] = {1};
331 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
332 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
333 // Phase 3, inputs and outputs
334 model->identifyInputsAndOutputs(
335 {input0, input1},
336 {output0});
337 assert(model->isValid());
338 }
339
is_ignored_dynamic_output_shape_float16_relu(int i)340 inline bool is_ignored_dynamic_output_shape_float16_relu(int i) {
341 static std::set<int> ignore = {};
342 return ignore.find(i) != ignore.end();
343 }
344
CreateModel_dynamic_output_shape_float16_relu1(Model * model)345 void CreateModel_dynamic_output_shape_float16_relu1(Model *model) {
346 OperandType type1(Type::INT32, {});
347 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
348 OperandType type15(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
349 // Phase 1, operands
350 auto input0 = model->addOperand(&type13);
351 auto input1 = model->addOperand(&type13);
352 auto act = model->addOperand(&type1);
353 auto output0 = model->addOperand(&type15);
354 // Phase 2, operations
355 static int32_t act_init[] = {2};
356 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
357 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
358 // Phase 3, inputs and outputs
359 model->identifyInputsAndOutputs(
360 {input0, input1},
361 {output0});
362 assert(model->isValid());
363 }
364
is_ignored_dynamic_output_shape_float16_relu1(int i)365 inline bool is_ignored_dynamic_output_shape_float16_relu1(int i) {
366 static std::set<int> ignore = {};
367 return ignore.find(i) != ignore.end();
368 }
369
CreateModel_dynamic_output_shape_float16_relu6(Model * model)370 void CreateModel_dynamic_output_shape_float16_relu6(Model *model) {
371 OperandType type1(Type::INT32, {});
372 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
373 OperandType type15(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
374 // Phase 1, operands
375 auto input0 = model->addOperand(&type13);
376 auto input1 = model->addOperand(&type13);
377 auto act = model->addOperand(&type1);
378 auto output0 = model->addOperand(&type15);
379 // Phase 2, operations
380 static int32_t act_init[] = {3};
381 model->setOperandValue(act, act_init, sizeof(int32_t) * 1);
382 model->addOperation(ANEURALNETWORKS_SUB, {input0, input1, act}, {output0});
383 // Phase 3, inputs and outputs
384 model->identifyInputsAndOutputs(
385 {input0, input1},
386 {output0});
387 assert(model->isValid());
388 }
389
is_ignored_dynamic_output_shape_float16_relu6(int i)390 inline bool is_ignored_dynamic_output_shape_float16_relu6(int i) {
391 static std::set<int> ignore = {};
392 return ignore.find(i) != ignore.end();
393 }
394
CreateModel_quant8(Model * model)395 void CreateModel_quant8(Model *model) {
396 OperandType type1(Type::INT32, {});
397 OperandType type2(Type::TENSOR_QUANT8_ASYMM, {2, 4, 16, 2}, 0.5f, 0);
398 // Phase 1, operands
399 auto input01 = model->addOperand(&type2);
400 auto input11 = model->addOperand(&type2);
401 auto param = model->addOperand(&type1);
402 auto output01 = model->addOperand(&type2);
403 // Phase 2, operations
404 static int32_t param_init[] = {0};
405 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
406 model->addOperation(ANEURALNETWORKS_SUB, {input01, input11, param}, {output01});
407 // Phase 3, inputs and outputs
408 model->identifyInputsAndOutputs(
409 {input01, input11},
410 {output01});
411 assert(model->isValid());
412 }
413
is_ignored_quant8(int i)414 inline bool is_ignored_quant8(int i) {
415 static std::set<int> ignore = {};
416 return ignore.find(i) != ignore.end();
417 }
418
CreateModel_quant8_dynamic_output_shape(Model * model)419 void CreateModel_quant8_dynamic_output_shape(Model *model) {
420 OperandType type1(Type::INT32, {});
421 OperandType type16(Type::TENSOR_QUANT8_ASYMM, {0, 0, 0, 0}, 0.5f, 0);
422 OperandType type2(Type::TENSOR_QUANT8_ASYMM, {2, 4, 16, 2}, 0.5f, 0);
423 // Phase 1, operands
424 auto input01 = model->addOperand(&type2);
425 auto input11 = model->addOperand(&type2);
426 auto param = model->addOperand(&type1);
427 auto output01 = model->addOperand(&type16);
428 // Phase 2, operations
429 static int32_t param_init[] = {0};
430 model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
431 model->addOperation(ANEURALNETWORKS_SUB, {input01, input11, param}, {output01});
432 // Phase 3, inputs and outputs
433 model->identifyInputsAndOutputs(
434 {input01, input11},
435 {output01});
436 assert(model->isValid());
437 }
438
is_ignored_quant8_dynamic_output_shape(int i)439 inline bool is_ignored_quant8_dynamic_output_shape(int i) {
440 static std::set<int> ignore = {};
441 return ignore.find(i) != ignore.end();
442 }
443
CreateModel_zero_sized(Model * model)444 void CreateModel_zero_sized(Model *model) {
445 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
446 OperandType type1(Type::INT32, {});
447 OperandType type10(Type::BOOL, {});
448 OperandType type11(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
449 OperandType type12(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
450 OperandType type3(Type::TENSOR_FLOAT32, {1, 2});
451 OperandType type4(Type::TENSOR_FLOAT32, {1, 8});
452 OperandType type5(Type::TENSOR_FLOAT32, {0});
453 OperandType type6(Type::TENSOR_INT32, {0});
454 OperandType type7(Type::TENSOR_FLOAT32, {0, 4});
455 OperandType type8(Type::TENSOR_INT32, {1});
456 OperandType type9(Type::FLOAT32, {});
457 // Phase 1, operands
458 auto scores = model->addOperand(&type3);
459 auto roi = model->addOperand(&type4);
460 auto param1 = model->addOperand(&type8);
461 auto param2 = model->addOperand(&type9);
462 auto param3 = model->addOperand(&type1);
463 auto param4 = model->addOperand(&type1);
464 auto param5 = model->addOperand(&type9);
465 auto param6 = model->addOperand(&type9);
466 auto param7 = model->addOperand(&type9);
467 auto scoresOut = model->addOperand(&type5);
468 auto roiOut = model->addOperand(&type7);
469 auto classesOut = model->addOperand(&type6);
470 auto batchSplitOut = model->addOperand(&type6);
471 auto in = model->addOperand(&type11);
472 auto param8 = model->addOperand(&type1);
473 auto param9 = model->addOperand(&type1);
474 auto param10 = model->addOperand(&type9);
475 auto param11 = model->addOperand(&type9);
476 auto param12 = model->addOperand(&type1);
477 auto param13 = model->addOperand(&type1);
478 auto layout = model->addOperand(&type10);
479 auto featureMap = model->addOperand(&type12);
480 auto op = model->addOperand(&type0);
481 auto param14 = model->addOperand(&type1);
482 auto out = model->addOperand(&type12);
483 // Phase 2, operations
484 static float scores_init[] = {0.9f, 0.1f};
485 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
486 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
487 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
488 static int32_t param1_init[] = {0};
489 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
490 static float param2_init[] = {0.3f};
491 model->setOperandValue(param2, param2_init, sizeof(float) * 1);
492 static int32_t param3_init[] = {-1};
493 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
494 static int32_t param4_init[] = {0};
495 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
496 static float param5_init[] = {0.4f};
497 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
498 static float param6_init[] = {1.0f};
499 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
500 static float param7_init[] = {0.3f};
501 model->setOperandValue(param7, param7_init, sizeof(float) * 1);
502 static int32_t param8_init[] = {2};
503 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
504 static int32_t param9_init[] = {2};
505 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
506 static float param10_init[] = {2.0f};
507 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
508 static float param11_init[] = {2.0f};
509 model->setOperandValue(param11, param11_init, sizeof(float) * 1);
510 static int32_t param12_init[] = {4};
511 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
512 static int32_t param13_init[] = {4};
513 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
514 static bool8 layout_init[] = {false};
515 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
516 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
517 model->setOperandValue(op, op_init, sizeof(float) * 4);
518 static int32_t param14_init[] = {0};
519 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
520 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
521 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
522 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
523 // Phase 3, inputs and outputs
524 model->identifyInputsAndOutputs(
525 {in},
526 {scoresOut, classesOut, out});
527 assert(model->isValid());
528 }
529
is_ignored_zero_sized(int i)530 inline bool is_ignored_zero_sized(int i) {
531 static std::set<int> ignore = {};
532 return ignore.find(i) != ignore.end();
533 }
534
CreateModel_zero_sized_relaxed(Model * model)535 void CreateModel_zero_sized_relaxed(Model *model) {
536 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
537 OperandType type1(Type::INT32, {});
538 OperandType type10(Type::BOOL, {});
539 OperandType type11(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
540 OperandType type12(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
541 OperandType type3(Type::TENSOR_FLOAT32, {1, 2});
542 OperandType type4(Type::TENSOR_FLOAT32, {1, 8});
543 OperandType type5(Type::TENSOR_FLOAT32, {0});
544 OperandType type6(Type::TENSOR_INT32, {0});
545 OperandType type7(Type::TENSOR_FLOAT32, {0, 4});
546 OperandType type8(Type::TENSOR_INT32, {1});
547 OperandType type9(Type::FLOAT32, {});
548 // Phase 1, operands
549 auto scores = model->addOperand(&type3);
550 auto roi = model->addOperand(&type4);
551 auto param1 = model->addOperand(&type8);
552 auto param2 = model->addOperand(&type9);
553 auto param3 = model->addOperand(&type1);
554 auto param4 = model->addOperand(&type1);
555 auto param5 = model->addOperand(&type9);
556 auto param6 = model->addOperand(&type9);
557 auto param7 = model->addOperand(&type9);
558 auto scoresOut = model->addOperand(&type5);
559 auto roiOut = model->addOperand(&type7);
560 auto classesOut = model->addOperand(&type6);
561 auto batchSplitOut = model->addOperand(&type6);
562 auto in = model->addOperand(&type11);
563 auto param8 = model->addOperand(&type1);
564 auto param9 = model->addOperand(&type1);
565 auto param10 = model->addOperand(&type9);
566 auto param11 = model->addOperand(&type9);
567 auto param12 = model->addOperand(&type1);
568 auto param13 = model->addOperand(&type1);
569 auto layout = model->addOperand(&type10);
570 auto featureMap = model->addOperand(&type12);
571 auto op = model->addOperand(&type0);
572 auto param14 = model->addOperand(&type1);
573 auto out = model->addOperand(&type12);
574 // Phase 2, operations
575 static float scores_init[] = {0.9f, 0.1f};
576 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
577 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
578 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
579 static int32_t param1_init[] = {0};
580 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
581 static float param2_init[] = {0.3f};
582 model->setOperandValue(param2, param2_init, sizeof(float) * 1);
583 static int32_t param3_init[] = {-1};
584 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
585 static int32_t param4_init[] = {0};
586 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
587 static float param5_init[] = {0.4f};
588 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
589 static float param6_init[] = {1.0f};
590 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
591 static float param7_init[] = {0.3f};
592 model->setOperandValue(param7, param7_init, sizeof(float) * 1);
593 static int32_t param8_init[] = {2};
594 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
595 static int32_t param9_init[] = {2};
596 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
597 static float param10_init[] = {2.0f};
598 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
599 static float param11_init[] = {2.0f};
600 model->setOperandValue(param11, param11_init, sizeof(float) * 1);
601 static int32_t param12_init[] = {4};
602 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
603 static int32_t param13_init[] = {4};
604 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
605 static bool8 layout_init[] = {false};
606 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
607 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
608 model->setOperandValue(op, op_init, sizeof(float) * 4);
609 static int32_t param14_init[] = {0};
610 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
611 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
612 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
613 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
614 // Phase 3, inputs and outputs
615 model->identifyInputsAndOutputs(
616 {in},
617 {scoresOut, classesOut, out});
618 // Phase 4: set relaxed execution
619 model->relaxComputationFloat32toFloat16(true);
620 assert(model->isValid());
621 }
622
is_ignored_zero_sized_relaxed(int i)623 inline bool is_ignored_zero_sized_relaxed(int i) {
624 static std::set<int> ignore = {};
625 return ignore.find(i) != ignore.end();
626 }
627
CreateModel_zero_sized_quant8(Model * model)628 void CreateModel_zero_sized_quant8(Model *model) {
629 OperandType type1(Type::INT32, {});
630 OperandType type10(Type::BOOL, {});
631 OperandType type17(Type::TENSOR_QUANT8_ASYMM, {0, 2, 2, 2}, 0.1f, 128);
632 OperandType type18(Type::TENSOR_QUANT8_ASYMM, {1, 1, 1, 2}, 0.1f, 128);
633 OperandType type19(Type::TENSOR_QUANT8_ASYMM, {1, 2, 2, 1}, 0.1f, 128);
634 OperandType type20(Type::TENSOR_QUANT16_ASYMM, {1, 8}, 0.125f, 0);
635 OperandType type21(Type::TENSOR_QUANT16_ASYMM, {0, 4}, 0.125f, 0);
636 OperandType type22(Type::TENSOR_QUANT8_ASYMM, {1, 2}, 0.1f, 128);
637 OperandType type23(Type::TENSOR_QUANT8_ASYMM, {0}, 0.1f, 128);
638 OperandType type6(Type::TENSOR_INT32, {0});
639 OperandType type8(Type::TENSOR_INT32, {1});
640 OperandType type9(Type::FLOAT32, {});
641 // Phase 1, operands
642 auto scores = model->addOperand(&type22);
643 auto roi = model->addOperand(&type20);
644 auto param1 = model->addOperand(&type8);
645 auto param2 = model->addOperand(&type9);
646 auto param3 = model->addOperand(&type1);
647 auto param4 = model->addOperand(&type1);
648 auto param5 = model->addOperand(&type9);
649 auto param6 = model->addOperand(&type9);
650 auto param7 = model->addOperand(&type9);
651 auto scoresOut = model->addOperand(&type23);
652 auto roiOut = model->addOperand(&type21);
653 auto classesOut = model->addOperand(&type6);
654 auto batchSplitOut = model->addOperand(&type6);
655 auto in = model->addOperand(&type18);
656 auto param8 = model->addOperand(&type1);
657 auto param9 = model->addOperand(&type1);
658 auto param10 = model->addOperand(&type9);
659 auto param11 = model->addOperand(&type9);
660 auto param12 = model->addOperand(&type1);
661 auto param13 = model->addOperand(&type1);
662 auto layout = model->addOperand(&type10);
663 auto featureMap = model->addOperand(&type17);
664 auto op = model->addOperand(&type19);
665 auto param14 = model->addOperand(&type1);
666 auto out = model->addOperand(&type17);
667 // Phase 2, operations
668 static uint8_t scores_init[] = {137, 129};
669 model->setOperandValue(scores, scores_init, sizeof(uint8_t) * 2);
670 static uint16_t roi_init[] = {8, 8, 80, 80, 0, 0, 80, 80};
671 model->setOperandValue(roi, roi_init, sizeof(uint16_t) * 8);
672 static int32_t param1_init[] = {0};
673 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
674 static float param2_init[] = {0.3f};
675 model->setOperandValue(param2, param2_init, sizeof(float) * 1);
676 static int32_t param3_init[] = {-1};
677 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
678 static int32_t param4_init[] = {0};
679 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
680 static float param5_init[] = {0.4f};
681 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
682 static float param6_init[] = {1.0f};
683 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
684 static float param7_init[] = {0.3f};
685 model->setOperandValue(param7, param7_init, sizeof(float) * 1);
686 static int32_t param8_init[] = {2};
687 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
688 static int32_t param9_init[] = {2};
689 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
690 static float param10_init[] = {2.0f};
691 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
692 static float param11_init[] = {2.0f};
693 model->setOperandValue(param11, param11_init, sizeof(float) * 1);
694 static int32_t param12_init[] = {4};
695 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
696 static int32_t param13_init[] = {4};
697 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
698 static bool8 layout_init[] = {false};
699 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
700 static uint8_t op_init[] = {138, 148, 158, 168};
701 model->setOperandValue(op, op_init, sizeof(uint8_t) * 4);
702 static int32_t param14_init[] = {0};
703 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
704 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
705 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
706 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
707 // Phase 3, inputs and outputs
708 model->identifyInputsAndOutputs(
709 {in},
710 {scoresOut, classesOut, out});
711 assert(model->isValid());
712 }
713
is_ignored_zero_sized_quant8(int i)714 inline bool is_ignored_zero_sized_quant8(int i) {
715 static std::set<int> ignore = {};
716 return ignore.find(i) != ignore.end();
717 }
718
CreateModel_zero_sized_float16(Model * model)719 void CreateModel_zero_sized_float16(Model *model) {
720 OperandType type1(Type::INT32, {});
721 OperandType type10(Type::BOOL, {});
722 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
723 OperandType type24(Type::TENSOR_FLOAT16, {0, 2, 2, 2});
724 OperandType type25(Type::TENSOR_FLOAT16, {1, 1, 1, 2});
725 OperandType type26(Type::FLOAT16, {});
726 OperandType type27(Type::TENSOR_FLOAT16, {1, 8});
727 OperandType type28(Type::TENSOR_FLOAT16, {0, 4});
728 OperandType type29(Type::TENSOR_FLOAT16, {1, 2});
729 OperandType type30(Type::TENSOR_FLOAT16, {0});
730 OperandType type6(Type::TENSOR_INT32, {0});
731 OperandType type8(Type::TENSOR_INT32, {1});
732 // Phase 1, operands
733 auto scores = model->addOperand(&type29);
734 auto roi = model->addOperand(&type27);
735 auto param1 = model->addOperand(&type8);
736 auto param2 = model->addOperand(&type26);
737 auto param3 = model->addOperand(&type1);
738 auto param4 = model->addOperand(&type1);
739 auto param5 = model->addOperand(&type26);
740 auto param6 = model->addOperand(&type26);
741 auto param7 = model->addOperand(&type26);
742 auto scoresOut = model->addOperand(&type30);
743 auto roiOut = model->addOperand(&type28);
744 auto classesOut = model->addOperand(&type6);
745 auto batchSplitOut = model->addOperand(&type6);
746 auto in = model->addOperand(&type25);
747 auto param8 = model->addOperand(&type1);
748 auto param9 = model->addOperand(&type1);
749 auto param10 = model->addOperand(&type26);
750 auto param11 = model->addOperand(&type26);
751 auto param12 = model->addOperand(&type1);
752 auto param13 = model->addOperand(&type1);
753 auto layout = model->addOperand(&type10);
754 auto featureMap = model->addOperand(&type24);
755 auto op = model->addOperand(&type13);
756 auto param14 = model->addOperand(&type1);
757 auto out = model->addOperand(&type24);
758 // Phase 2, operations
759 static _Float16 scores_init[] = {0.8999999761581421f, 0.10000000149011612f};
760 model->setOperandValue(scores, scores_init, sizeof(_Float16) * 2);
761 static _Float16 roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
762 model->setOperandValue(roi, roi_init, sizeof(_Float16) * 8);
763 static int32_t param1_init[] = {0};
764 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
765 static _Float16 param2_init[] = {0.30000001192092896f};
766 model->setOperandValue(param2, param2_init, sizeof(_Float16) * 1);
767 static int32_t param3_init[] = {-1};
768 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
769 static int32_t param4_init[] = {0};
770 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
771 static _Float16 param5_init[] = {0.4000000059604645f};
772 model->setOperandValue(param5, param5_init, sizeof(_Float16) * 1);
773 static _Float16 param6_init[] = {1.0f};
774 model->setOperandValue(param6, param6_init, sizeof(_Float16) * 1);
775 static _Float16 param7_init[] = {0.30000001192092896f};
776 model->setOperandValue(param7, param7_init, sizeof(_Float16) * 1);
777 static int32_t param8_init[] = {2};
778 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
779 static int32_t param9_init[] = {2};
780 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
781 static _Float16 param10_init[] = {2.0f};
782 model->setOperandValue(param10, param10_init, sizeof(_Float16) * 1);
783 static _Float16 param11_init[] = {2.0f};
784 model->setOperandValue(param11, param11_init, sizeof(_Float16) * 1);
785 static int32_t param12_init[] = {4};
786 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
787 static int32_t param13_init[] = {4};
788 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
789 static bool8 layout_init[] = {false};
790 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
791 static _Float16 op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
792 model->setOperandValue(op, op_init, sizeof(_Float16) * 4);
793 static int32_t param14_init[] = {0};
794 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
795 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
796 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
797 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
798 // Phase 3, inputs and outputs
799 model->identifyInputsAndOutputs(
800 {in},
801 {scoresOut, classesOut, out});
802 assert(model->isValid());
803 }
804
is_ignored_zero_sized_float16(int i)805 inline bool is_ignored_zero_sized_float16(int i) {
806 static std::set<int> ignore = {};
807 return ignore.find(i) != ignore.end();
808 }
809
CreateModel_zero_sized_dynamic_output_shape(Model * model)810 void CreateModel_zero_sized_dynamic_output_shape(Model *model) {
811 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
812 OperandType type1(Type::INT32, {});
813 OperandType type10(Type::BOOL, {});
814 OperandType type11(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
815 OperandType type12(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
816 OperandType type14(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
817 OperandType type3(Type::TENSOR_FLOAT32, {1, 2});
818 OperandType type4(Type::TENSOR_FLOAT32, {1, 8});
819 OperandType type5(Type::TENSOR_FLOAT32, {0});
820 OperandType type6(Type::TENSOR_INT32, {0});
821 OperandType type7(Type::TENSOR_FLOAT32, {0, 4});
822 OperandType type8(Type::TENSOR_INT32, {1});
823 OperandType type9(Type::FLOAT32, {});
824 // Phase 1, operands
825 auto scores = model->addOperand(&type3);
826 auto roi = model->addOperand(&type4);
827 auto param1 = model->addOperand(&type8);
828 auto param2 = model->addOperand(&type9);
829 auto param3 = model->addOperand(&type1);
830 auto param4 = model->addOperand(&type1);
831 auto param5 = model->addOperand(&type9);
832 auto param6 = model->addOperand(&type9);
833 auto param7 = model->addOperand(&type9);
834 auto scoresOut = model->addOperand(&type5);
835 auto roiOut = model->addOperand(&type7);
836 auto classesOut = model->addOperand(&type6);
837 auto batchSplitOut = model->addOperand(&type6);
838 auto in = model->addOperand(&type11);
839 auto param8 = model->addOperand(&type1);
840 auto param9 = model->addOperand(&type1);
841 auto param10 = model->addOperand(&type9);
842 auto param11 = model->addOperand(&type9);
843 auto param12 = model->addOperand(&type1);
844 auto param13 = model->addOperand(&type1);
845 auto layout = model->addOperand(&type10);
846 auto featureMap = model->addOperand(&type12);
847 auto op = model->addOperand(&type0);
848 auto param14 = model->addOperand(&type1);
849 auto out = model->addOperand(&type14);
850 // Phase 2, operations
851 static float scores_init[] = {0.9f, 0.1f};
852 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
853 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
854 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
855 static int32_t param1_init[] = {0};
856 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
857 static float param2_init[] = {0.3f};
858 model->setOperandValue(param2, param2_init, sizeof(float) * 1);
859 static int32_t param3_init[] = {-1};
860 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
861 static int32_t param4_init[] = {0};
862 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
863 static float param5_init[] = {0.4f};
864 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
865 static float param6_init[] = {1.0f};
866 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
867 static float param7_init[] = {0.3f};
868 model->setOperandValue(param7, param7_init, sizeof(float) * 1);
869 static int32_t param8_init[] = {2};
870 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
871 static int32_t param9_init[] = {2};
872 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
873 static float param10_init[] = {2.0f};
874 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
875 static float param11_init[] = {2.0f};
876 model->setOperandValue(param11, param11_init, sizeof(float) * 1);
877 static int32_t param12_init[] = {4};
878 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
879 static int32_t param13_init[] = {4};
880 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
881 static bool8 layout_init[] = {false};
882 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
883 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
884 model->setOperandValue(op, op_init, sizeof(float) * 4);
885 static int32_t param14_init[] = {0};
886 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
887 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
888 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
889 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
890 // Phase 3, inputs and outputs
891 model->identifyInputsAndOutputs(
892 {in},
893 {scoresOut, classesOut, out});
894 assert(model->isValid());
895 }
896
is_ignored_zero_sized_dynamic_output_shape(int i)897 inline bool is_ignored_zero_sized_dynamic_output_shape(int i) {
898 static std::set<int> ignore = {};
899 return ignore.find(i) != ignore.end();
900 }
901
CreateModel_zero_sized_dynamic_output_shape_relaxed(Model * model)902 void CreateModel_zero_sized_dynamic_output_shape_relaxed(Model *model) {
903 OperandType type0(Type::TENSOR_FLOAT32, {1, 2, 2, 1});
904 OperandType type1(Type::INT32, {});
905 OperandType type10(Type::BOOL, {});
906 OperandType type11(Type::TENSOR_FLOAT32, {1, 1, 1, 2});
907 OperandType type12(Type::TENSOR_FLOAT32, {0, 2, 2, 2});
908 OperandType type14(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
909 OperandType type3(Type::TENSOR_FLOAT32, {1, 2});
910 OperandType type4(Type::TENSOR_FLOAT32, {1, 8});
911 OperandType type5(Type::TENSOR_FLOAT32, {0});
912 OperandType type6(Type::TENSOR_INT32, {0});
913 OperandType type7(Type::TENSOR_FLOAT32, {0, 4});
914 OperandType type8(Type::TENSOR_INT32, {1});
915 OperandType type9(Type::FLOAT32, {});
916 // Phase 1, operands
917 auto scores = model->addOperand(&type3);
918 auto roi = model->addOperand(&type4);
919 auto param1 = model->addOperand(&type8);
920 auto param2 = model->addOperand(&type9);
921 auto param3 = model->addOperand(&type1);
922 auto param4 = model->addOperand(&type1);
923 auto param5 = model->addOperand(&type9);
924 auto param6 = model->addOperand(&type9);
925 auto param7 = model->addOperand(&type9);
926 auto scoresOut = model->addOperand(&type5);
927 auto roiOut = model->addOperand(&type7);
928 auto classesOut = model->addOperand(&type6);
929 auto batchSplitOut = model->addOperand(&type6);
930 auto in = model->addOperand(&type11);
931 auto param8 = model->addOperand(&type1);
932 auto param9 = model->addOperand(&type1);
933 auto param10 = model->addOperand(&type9);
934 auto param11 = model->addOperand(&type9);
935 auto param12 = model->addOperand(&type1);
936 auto param13 = model->addOperand(&type1);
937 auto layout = model->addOperand(&type10);
938 auto featureMap = model->addOperand(&type12);
939 auto op = model->addOperand(&type0);
940 auto param14 = model->addOperand(&type1);
941 auto out = model->addOperand(&type14);
942 // Phase 2, operations
943 static float scores_init[] = {0.9f, 0.1f};
944 model->setOperandValue(scores, scores_init, sizeof(float) * 2);
945 static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
946 model->setOperandValue(roi, roi_init, sizeof(float) * 8);
947 static int32_t param1_init[] = {0};
948 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
949 static float param2_init[] = {0.3f};
950 model->setOperandValue(param2, param2_init, sizeof(float) * 1);
951 static int32_t param3_init[] = {-1};
952 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
953 static int32_t param4_init[] = {0};
954 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
955 static float param5_init[] = {0.4f};
956 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
957 static float param6_init[] = {1.0f};
958 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
959 static float param7_init[] = {0.3f};
960 model->setOperandValue(param7, param7_init, sizeof(float) * 1);
961 static int32_t param8_init[] = {2};
962 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
963 static int32_t param9_init[] = {2};
964 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
965 static float param10_init[] = {2.0f};
966 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
967 static float param11_init[] = {2.0f};
968 model->setOperandValue(param11, param11_init, sizeof(float) * 1);
969 static int32_t param12_init[] = {4};
970 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
971 static int32_t param13_init[] = {4};
972 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
973 static bool8 layout_init[] = {false};
974 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
975 static float op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
976 model->setOperandValue(op, op_init, sizeof(float) * 4);
977 static int32_t param14_init[] = {0};
978 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
979 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
980 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
981 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
982 // Phase 3, inputs and outputs
983 model->identifyInputsAndOutputs(
984 {in},
985 {scoresOut, classesOut, out});
986 // Phase 4: set relaxed execution
987 model->relaxComputationFloat32toFloat16(true);
988 assert(model->isValid());
989 }
990
is_ignored_zero_sized_dynamic_output_shape_relaxed(int i)991 inline bool is_ignored_zero_sized_dynamic_output_shape_relaxed(int i) {
992 static std::set<int> ignore = {};
993 return ignore.find(i) != ignore.end();
994 }
995
CreateModel_zero_sized_dynamic_output_shape_quant8(Model * model)996 void CreateModel_zero_sized_dynamic_output_shape_quant8(Model *model) {
997 OperandType type1(Type::INT32, {});
998 OperandType type10(Type::BOOL, {});
999 OperandType type17(Type::TENSOR_QUANT8_ASYMM, {0, 2, 2, 2}, 0.1f, 128);
1000 OperandType type18(Type::TENSOR_QUANT8_ASYMM, {1, 1, 1, 2}, 0.1f, 128);
1001 OperandType type19(Type::TENSOR_QUANT8_ASYMM, {1, 2, 2, 1}, 0.1f, 128);
1002 OperandType type20(Type::TENSOR_QUANT16_ASYMM, {1, 8}, 0.125f, 0);
1003 OperandType type21(Type::TENSOR_QUANT16_ASYMM, {0, 4}, 0.125f, 0);
1004 OperandType type22(Type::TENSOR_QUANT8_ASYMM, {1, 2}, 0.1f, 128);
1005 OperandType type23(Type::TENSOR_QUANT8_ASYMM, {0}, 0.1f, 128);
1006 OperandType type31(Type::TENSOR_QUANT8_ASYMM, {0, 0, 0, 0}, 0.1f, 128);
1007 OperandType type6(Type::TENSOR_INT32, {0});
1008 OperandType type8(Type::TENSOR_INT32, {1});
1009 OperandType type9(Type::FLOAT32, {});
1010 // Phase 1, operands
1011 auto scores = model->addOperand(&type22);
1012 auto roi = model->addOperand(&type20);
1013 auto param1 = model->addOperand(&type8);
1014 auto param2 = model->addOperand(&type9);
1015 auto param3 = model->addOperand(&type1);
1016 auto param4 = model->addOperand(&type1);
1017 auto param5 = model->addOperand(&type9);
1018 auto param6 = model->addOperand(&type9);
1019 auto param7 = model->addOperand(&type9);
1020 auto scoresOut = model->addOperand(&type23);
1021 auto roiOut = model->addOperand(&type21);
1022 auto classesOut = model->addOperand(&type6);
1023 auto batchSplitOut = model->addOperand(&type6);
1024 auto in = model->addOperand(&type18);
1025 auto param8 = model->addOperand(&type1);
1026 auto param9 = model->addOperand(&type1);
1027 auto param10 = model->addOperand(&type9);
1028 auto param11 = model->addOperand(&type9);
1029 auto param12 = model->addOperand(&type1);
1030 auto param13 = model->addOperand(&type1);
1031 auto layout = model->addOperand(&type10);
1032 auto featureMap = model->addOperand(&type17);
1033 auto op = model->addOperand(&type19);
1034 auto param14 = model->addOperand(&type1);
1035 auto out = model->addOperand(&type31);
1036 // Phase 2, operations
1037 static uint8_t scores_init[] = {137, 129};
1038 model->setOperandValue(scores, scores_init, sizeof(uint8_t) * 2);
1039 static uint16_t roi_init[] = {8, 8, 80, 80, 0, 0, 80, 80};
1040 model->setOperandValue(roi, roi_init, sizeof(uint16_t) * 8);
1041 static int32_t param1_init[] = {0};
1042 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
1043 static float param2_init[] = {0.3f};
1044 model->setOperandValue(param2, param2_init, sizeof(float) * 1);
1045 static int32_t param3_init[] = {-1};
1046 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
1047 static int32_t param4_init[] = {0};
1048 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
1049 static float param5_init[] = {0.4f};
1050 model->setOperandValue(param5, param5_init, sizeof(float) * 1);
1051 static float param6_init[] = {1.0f};
1052 model->setOperandValue(param6, param6_init, sizeof(float) * 1);
1053 static float param7_init[] = {0.3f};
1054 model->setOperandValue(param7, param7_init, sizeof(float) * 1);
1055 static int32_t param8_init[] = {2};
1056 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
1057 static int32_t param9_init[] = {2};
1058 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
1059 static float param10_init[] = {2.0f};
1060 model->setOperandValue(param10, param10_init, sizeof(float) * 1);
1061 static float param11_init[] = {2.0f};
1062 model->setOperandValue(param11, param11_init, sizeof(float) * 1);
1063 static int32_t param12_init[] = {4};
1064 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
1065 static int32_t param13_init[] = {4};
1066 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
1067 static bool8 layout_init[] = {false};
1068 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
1069 static uint8_t op_init[] = {138, 148, 158, 168};
1070 model->setOperandValue(op, op_init, sizeof(uint8_t) * 4);
1071 static int32_t param14_init[] = {0};
1072 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
1073 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
1074 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
1075 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
1076 // Phase 3, inputs and outputs
1077 model->identifyInputsAndOutputs(
1078 {in},
1079 {scoresOut, classesOut, out});
1080 assert(model->isValid());
1081 }
1082
is_ignored_zero_sized_dynamic_output_shape_quant8(int i)1083 inline bool is_ignored_zero_sized_dynamic_output_shape_quant8(int i) {
1084 static std::set<int> ignore = {};
1085 return ignore.find(i) != ignore.end();
1086 }
1087
CreateModel_zero_sized_dynamic_output_shape_float16(Model * model)1088 void CreateModel_zero_sized_dynamic_output_shape_float16(Model *model) {
1089 OperandType type1(Type::INT32, {});
1090 OperandType type10(Type::BOOL, {});
1091 OperandType type13(Type::TENSOR_FLOAT16, {1, 2, 2, 1});
1092 OperandType type15(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
1093 OperandType type24(Type::TENSOR_FLOAT16, {0, 2, 2, 2});
1094 OperandType type25(Type::TENSOR_FLOAT16, {1, 1, 1, 2});
1095 OperandType type26(Type::FLOAT16, {});
1096 OperandType type27(Type::TENSOR_FLOAT16, {1, 8});
1097 OperandType type28(Type::TENSOR_FLOAT16, {0, 4});
1098 OperandType type29(Type::TENSOR_FLOAT16, {1, 2});
1099 OperandType type32(Type::TENSOR_FLOAT16, {0});
1100 OperandType type6(Type::TENSOR_INT32, {0});
1101 OperandType type8(Type::TENSOR_INT32, {1});
1102 // Phase 1, operands
1103 auto scores = model->addOperand(&type29);
1104 auto roi = model->addOperand(&type27);
1105 auto param1 = model->addOperand(&type8);
1106 auto param2 = model->addOperand(&type26);
1107 auto param3 = model->addOperand(&type1);
1108 auto param4 = model->addOperand(&type1);
1109 auto param5 = model->addOperand(&type26);
1110 auto param6 = model->addOperand(&type26);
1111 auto param7 = model->addOperand(&type26);
1112 auto scoresOut = model->addOperand(&type32);
1113 auto roiOut = model->addOperand(&type28);
1114 auto classesOut = model->addOperand(&type6);
1115 auto batchSplitOut = model->addOperand(&type6);
1116 auto in = model->addOperand(&type25);
1117 auto param8 = model->addOperand(&type1);
1118 auto param9 = model->addOperand(&type1);
1119 auto param10 = model->addOperand(&type26);
1120 auto param11 = model->addOperand(&type26);
1121 auto param12 = model->addOperand(&type1);
1122 auto param13 = model->addOperand(&type1);
1123 auto layout = model->addOperand(&type10);
1124 auto featureMap = model->addOperand(&type24);
1125 auto op = model->addOperand(&type13);
1126 auto param14 = model->addOperand(&type1);
1127 auto out = model->addOperand(&type15);
1128 // Phase 2, operations
1129 static _Float16 scores_init[] = {0.8999999761581421f, 0.10000000149011612f};
1130 model->setOperandValue(scores, scores_init, sizeof(_Float16) * 2);
1131 static _Float16 roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
1132 model->setOperandValue(roi, roi_init, sizeof(_Float16) * 8);
1133 static int32_t param1_init[] = {0};
1134 model->setOperandValue(param1, param1_init, sizeof(int32_t) * 1);
1135 static _Float16 param2_init[] = {0.30000001192092896f};
1136 model->setOperandValue(param2, param2_init, sizeof(_Float16) * 1);
1137 static int32_t param3_init[] = {-1};
1138 model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
1139 static int32_t param4_init[] = {0};
1140 model->setOperandValue(param4, param4_init, sizeof(int32_t) * 1);
1141 static _Float16 param5_init[] = {0.4000000059604645f};
1142 model->setOperandValue(param5, param5_init, sizeof(_Float16) * 1);
1143 static _Float16 param6_init[] = {1.0f};
1144 model->setOperandValue(param6, param6_init, sizeof(_Float16) * 1);
1145 static _Float16 param7_init[] = {0.30000001192092896f};
1146 model->setOperandValue(param7, param7_init, sizeof(_Float16) * 1);
1147 static int32_t param8_init[] = {2};
1148 model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
1149 static int32_t param9_init[] = {2};
1150 model->setOperandValue(param9, param9_init, sizeof(int32_t) * 1);
1151 static _Float16 param10_init[] = {2.0f};
1152 model->setOperandValue(param10, param10_init, sizeof(_Float16) * 1);
1153 static _Float16 param11_init[] = {2.0f};
1154 model->setOperandValue(param11, param11_init, sizeof(_Float16) * 1);
1155 static int32_t param12_init[] = {4};
1156 model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
1157 static int32_t param13_init[] = {4};
1158 model->setOperandValue(param13, param13_init, sizeof(int32_t) * 1);
1159 static bool8 layout_init[] = {false};
1160 model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
1161 static _Float16 op_init[] = {1.0f, 2.0f, 3.0f, 4.0f};
1162 model->setOperandValue(op, op_init, sizeof(_Float16) * 4);
1163 static int32_t param14_init[] = {0};
1164 model->setOperandValue(param14, param14_init, sizeof(int32_t) * 1);
1165 model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param1, param2, param3, param4, param5, param6, param7}, {scoresOut, roiOut, classesOut, batchSplitOut});
1166 model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param8, param9, param10, param11, param12, param13, layout}, {featureMap});
1167 model->addOperation(ANEURALNETWORKS_SUB, {featureMap, op, param14}, {out});
1168 // Phase 3, inputs and outputs
1169 model->identifyInputsAndOutputs(
1170 {in},
1171 {scoresOut, classesOut, out});
1172 assert(model->isValid());
1173 }
1174
is_ignored_zero_sized_dynamic_output_shape_float16(int i)1175 inline bool is_ignored_zero_sized_dynamic_output_shape_float16(int i) {
1176 static std::set<int> ignore = {};
1177 return ignore.find(i) != ignore.end();
1178 }
1179
1180