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