• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // clang-format off
2 // Generated file (from: relu1_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 op2 = model->addOperand(&type0);
8   // Phase 2, operations
9   model->addOperation(ANEURALNETWORKS_RELU1, {op1}, {op2});
10   // Phase 3, inputs and outputs
11   model->identifyInputsAndOutputs(
12     {op1},
13     {op2});
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 op2 = model->addOperand(&type13);
28   // Phase 2, operations
29   model->addOperation(ANEURALNETWORKS_RELU1, {op1}, {op2});
30   // Phase 3, inputs and outputs
31   model->identifyInputsAndOutputs(
32     {op1},
33     {op2});
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, 30, 24, 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_RELU1, {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, 30, 24, 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_RELU1, {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_RELU1, {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_RELU1, {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_QUANT16_ASYMM, {1, 8}, 0.125f, 0);
256   OperandType type17(Type::TENSOR_QUANT16_ASYMM, {0, 4}, 0.125f, 0);
257   OperandType type18(Type::TENSOR_QUANT8_ASYMM, {1, 2}, 0.1f, 128);
258   OperandType type19(Type::TENSOR_QUANT8_ASYMM, {0}, 0.1f, 128);
259   OperandType type5(Type::TENSOR_INT32, {0});
260   OperandType type7(Type::TENSOR_INT32, {1});
261   OperandType type8(Type::FLOAT32, {});
262   OperandType type9(Type::INT32, {});
263   // Phase 1, operands
264   auto scores = model->addOperand(&type18);
265   auto roi = model->addOperand(&type16);
266   auto param = model->addOperand(&type7);
267   auto param1 = model->addOperand(&type8);
268   auto param2 = model->addOperand(&type9);
269   auto param3 = model->addOperand(&type9);
270   auto param4 = model->addOperand(&type8);
271   auto param5 = model->addOperand(&type8);
272   auto param6 = model->addOperand(&type8);
273   auto scoresOut = model->addOperand(&type19);
274   auto roiOut = model->addOperand(&type17);
275   auto classesOut = model->addOperand(&type5);
276   auto batchSplitOut = model->addOperand(&type5);
277   auto in = model->addOperand(&type15);
278   auto param7 = model->addOperand(&type9);
279   auto param8 = model->addOperand(&type9);
280   auto param9 = model->addOperand(&type8);
281   auto param10 = model->addOperand(&type8);
282   auto param11 = model->addOperand(&type9);
283   auto param12 = model->addOperand(&type9);
284   auto layout = model->addOperand(&type10);
285   auto featureMap = model->addOperand(&type14);
286   auto out = model->addOperand(&type14);
287   // Phase 2, operations
288   static uint8_t scores_init[] = {137, 129};
289   model->setOperandValue(scores, scores_init, sizeof(uint8_t) * 2);
290   static uint16_t roi_init[] = {8, 8, 80, 80, 0, 0, 80, 80};
291   model->setOperandValue(roi, roi_init, sizeof(uint16_t) * 8);
292   static int32_t param_init[] = {0};
293   model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
294   static float param1_init[] = {0.3f};
295   model->setOperandValue(param1, param1_init, sizeof(float) * 1);
296   static int32_t param2_init[] = {-1};
297   model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
298   static int32_t param3_init[] = {0};
299   model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
300   static float param4_init[] = {0.4f};
301   model->setOperandValue(param4, param4_init, sizeof(float) * 1);
302   static float param5_init[] = {1.0f};
303   model->setOperandValue(param5, param5_init, sizeof(float) * 1);
304   static float param6_init[] = {0.3f};
305   model->setOperandValue(param6, param6_init, sizeof(float) * 1);
306   static int32_t param7_init[] = {2};
307   model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
308   static int32_t param8_init[] = {2};
309   model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
310   static float param9_init[] = {2.0f};
311   model->setOperandValue(param9, param9_init, sizeof(float) * 1);
312   static float param10_init[] = {2.0f};
313   model->setOperandValue(param10, param10_init, sizeof(float) * 1);
314   static int32_t param11_init[] = {4};
315   model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
316   static int32_t param12_init[] = {4};
317   model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
318   static bool8 layout_init[] = {false};
319   model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
320   model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
321   model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
322   model->addOperation(ANEURALNETWORKS_RELU1, {featureMap}, {out});
323   // Phase 3, inputs and outputs
324   model->identifyInputsAndOutputs(
325     {in},
326     {scoresOut, classesOut, out});
327   assert(model->isValid());
328 }
329 
is_ignored_zero_sized_quant8(int i)330 inline bool is_ignored_zero_sized_quant8(int i) {
331   static std::set<int> ignore = {};
332   return ignore.find(i) != ignore.end();
333 }
334 
CreateModel_zero_sized_float16(Model * model)335 void CreateModel_zero_sized_float16(Model *model) {
336   OperandType type10(Type::BOOL, {});
337   OperandType type20(Type::TENSOR_FLOAT16, {0, 2, 2, 1});
338   OperandType type21(Type::TENSOR_FLOAT16, {1, 1, 1, 1});
339   OperandType type22(Type::FLOAT16, {});
340   OperandType type23(Type::TENSOR_FLOAT16, {1, 8});
341   OperandType type24(Type::TENSOR_FLOAT16, {0, 4});
342   OperandType type25(Type::TENSOR_FLOAT16, {1, 2});
343   OperandType type26(Type::TENSOR_FLOAT16, {0});
344   OperandType type5(Type::TENSOR_INT32, {0});
345   OperandType type7(Type::TENSOR_INT32, {1});
346   OperandType type9(Type::INT32, {});
347   // Phase 1, operands
348   auto scores = model->addOperand(&type25);
349   auto roi = model->addOperand(&type23);
350   auto param = model->addOperand(&type7);
351   auto param1 = model->addOperand(&type22);
352   auto param2 = model->addOperand(&type9);
353   auto param3 = model->addOperand(&type9);
354   auto param4 = model->addOperand(&type22);
355   auto param5 = model->addOperand(&type22);
356   auto param6 = model->addOperand(&type22);
357   auto scoresOut = model->addOperand(&type26);
358   auto roiOut = model->addOperand(&type24);
359   auto classesOut = model->addOperand(&type5);
360   auto batchSplitOut = model->addOperand(&type5);
361   auto in = model->addOperand(&type21);
362   auto param7 = model->addOperand(&type9);
363   auto param8 = model->addOperand(&type9);
364   auto param9 = model->addOperand(&type22);
365   auto param10 = model->addOperand(&type22);
366   auto param11 = model->addOperand(&type9);
367   auto param12 = model->addOperand(&type9);
368   auto layout = model->addOperand(&type10);
369   auto featureMap = model->addOperand(&type20);
370   auto out = model->addOperand(&type20);
371   // Phase 2, operations
372   static _Float16 scores_init[] = {0.8999999761581421f, 0.10000000149011612f};
373   model->setOperandValue(scores, scores_init, sizeof(_Float16) * 2);
374   static _Float16 roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
375   model->setOperandValue(roi, roi_init, sizeof(_Float16) * 8);
376   static int32_t param_init[] = {0};
377   model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
378   static _Float16 param1_init[] = {0.30000001192092896f};
379   model->setOperandValue(param1, param1_init, sizeof(_Float16) * 1);
380   static int32_t param2_init[] = {-1};
381   model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
382   static int32_t param3_init[] = {0};
383   model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
384   static _Float16 param4_init[] = {0.4000000059604645f};
385   model->setOperandValue(param4, param4_init, sizeof(_Float16) * 1);
386   static _Float16 param5_init[] = {1.0f};
387   model->setOperandValue(param5, param5_init, sizeof(_Float16) * 1);
388   static _Float16 param6_init[] = {0.30000001192092896f};
389   model->setOperandValue(param6, param6_init, sizeof(_Float16) * 1);
390   static int32_t param7_init[] = {2};
391   model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
392   static int32_t param8_init[] = {2};
393   model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
394   static _Float16 param9_init[] = {2.0f};
395   model->setOperandValue(param9, param9_init, sizeof(_Float16) * 1);
396   static _Float16 param10_init[] = {2.0f};
397   model->setOperandValue(param10, param10_init, sizeof(_Float16) * 1);
398   static int32_t param11_init[] = {4};
399   model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
400   static int32_t param12_init[] = {4};
401   model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
402   static bool8 layout_init[] = {false};
403   model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
404   model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
405   model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
406   model->addOperation(ANEURALNETWORKS_RELU1, {featureMap}, {out});
407   // Phase 3, inputs and outputs
408   model->identifyInputsAndOutputs(
409     {in},
410     {scoresOut, classesOut, out});
411   assert(model->isValid());
412 }
413 
is_ignored_zero_sized_float16(int i)414 inline bool is_ignored_zero_sized_float16(int i) {
415   static std::set<int> ignore = {};
416   return ignore.find(i) != ignore.end();
417 }
418 
CreateModel_zero_sized_dynamic_output_shape(Model * model)419 void CreateModel_zero_sized_dynamic_output_shape(Model *model) {
420   OperandType type10(Type::BOOL, {});
421   OperandType type11(Type::TENSOR_FLOAT32, {1, 1, 1, 1});
422   OperandType type12(Type::TENSOR_FLOAT32, {0, 2, 2, 1});
423   OperandType type2(Type::TENSOR_FLOAT32, {1, 2});
424   OperandType type27(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
425   OperandType type3(Type::TENSOR_FLOAT32, {1, 8});
426   OperandType type4(Type::TENSOR_FLOAT32, {0});
427   OperandType type5(Type::TENSOR_INT32, {0});
428   OperandType type6(Type::TENSOR_FLOAT32, {0, 4});
429   OperandType type7(Type::TENSOR_INT32, {1});
430   OperandType type8(Type::FLOAT32, {});
431   OperandType type9(Type::INT32, {});
432   // Phase 1, operands
433   auto scores = model->addOperand(&type2);
434   auto roi = model->addOperand(&type3);
435   auto param = model->addOperand(&type7);
436   auto param1 = model->addOperand(&type8);
437   auto param2 = model->addOperand(&type9);
438   auto param3 = model->addOperand(&type9);
439   auto param4 = model->addOperand(&type8);
440   auto param5 = model->addOperand(&type8);
441   auto param6 = model->addOperand(&type8);
442   auto scoresOut = model->addOperand(&type4);
443   auto roiOut = model->addOperand(&type6);
444   auto classesOut = model->addOperand(&type5);
445   auto batchSplitOut = model->addOperand(&type5);
446   auto in = model->addOperand(&type11);
447   auto param7 = model->addOperand(&type9);
448   auto param8 = model->addOperand(&type9);
449   auto param9 = model->addOperand(&type8);
450   auto param10 = model->addOperand(&type8);
451   auto param11 = model->addOperand(&type9);
452   auto param12 = model->addOperand(&type9);
453   auto layout = model->addOperand(&type10);
454   auto featureMap = model->addOperand(&type12);
455   auto out = model->addOperand(&type27);
456   // Phase 2, operations
457   static float scores_init[] = {0.9f, 0.1f};
458   model->setOperandValue(scores, scores_init, sizeof(float) * 2);
459   static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
460   model->setOperandValue(roi, roi_init, sizeof(float) * 8);
461   static int32_t param_init[] = {0};
462   model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
463   static float param1_init[] = {0.3f};
464   model->setOperandValue(param1, param1_init, sizeof(float) * 1);
465   static int32_t param2_init[] = {-1};
466   model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
467   static int32_t param3_init[] = {0};
468   model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
469   static float param4_init[] = {0.4f};
470   model->setOperandValue(param4, param4_init, sizeof(float) * 1);
471   static float param5_init[] = {1.0f};
472   model->setOperandValue(param5, param5_init, sizeof(float) * 1);
473   static float param6_init[] = {0.3f};
474   model->setOperandValue(param6, param6_init, sizeof(float) * 1);
475   static int32_t param7_init[] = {2};
476   model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
477   static int32_t param8_init[] = {2};
478   model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
479   static float param9_init[] = {2.0f};
480   model->setOperandValue(param9, param9_init, sizeof(float) * 1);
481   static float param10_init[] = {2.0f};
482   model->setOperandValue(param10, param10_init, sizeof(float) * 1);
483   static int32_t param11_init[] = {4};
484   model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
485   static int32_t param12_init[] = {4};
486   model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
487   static bool8 layout_init[] = {false};
488   model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
489   model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
490   model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
491   model->addOperation(ANEURALNETWORKS_RELU1, {featureMap}, {out});
492   // Phase 3, inputs and outputs
493   model->identifyInputsAndOutputs(
494     {in},
495     {scoresOut, classesOut, out});
496   assert(model->isValid());
497 }
498 
is_ignored_zero_sized_dynamic_output_shape(int i)499 inline bool is_ignored_zero_sized_dynamic_output_shape(int i) {
500   static std::set<int> ignore = {};
501   return ignore.find(i) != ignore.end();
502 }
503 
CreateModel_zero_sized_dynamic_output_shape_relaxed(Model * model)504 void CreateModel_zero_sized_dynamic_output_shape_relaxed(Model *model) {
505   OperandType type10(Type::BOOL, {});
506   OperandType type11(Type::TENSOR_FLOAT32, {1, 1, 1, 1});
507   OperandType type12(Type::TENSOR_FLOAT32, {0, 2, 2, 1});
508   OperandType type2(Type::TENSOR_FLOAT32, {1, 2});
509   OperandType type27(Type::TENSOR_FLOAT32, {0, 0, 0, 0});
510   OperandType type3(Type::TENSOR_FLOAT32, {1, 8});
511   OperandType type4(Type::TENSOR_FLOAT32, {0});
512   OperandType type5(Type::TENSOR_INT32, {0});
513   OperandType type6(Type::TENSOR_FLOAT32, {0, 4});
514   OperandType type7(Type::TENSOR_INT32, {1});
515   OperandType type8(Type::FLOAT32, {});
516   OperandType type9(Type::INT32, {});
517   // Phase 1, operands
518   auto scores = model->addOperand(&type2);
519   auto roi = model->addOperand(&type3);
520   auto param = model->addOperand(&type7);
521   auto param1 = model->addOperand(&type8);
522   auto param2 = model->addOperand(&type9);
523   auto param3 = model->addOperand(&type9);
524   auto param4 = model->addOperand(&type8);
525   auto param5 = model->addOperand(&type8);
526   auto param6 = model->addOperand(&type8);
527   auto scoresOut = model->addOperand(&type4);
528   auto roiOut = model->addOperand(&type6);
529   auto classesOut = model->addOperand(&type5);
530   auto batchSplitOut = model->addOperand(&type5);
531   auto in = model->addOperand(&type11);
532   auto param7 = model->addOperand(&type9);
533   auto param8 = model->addOperand(&type9);
534   auto param9 = model->addOperand(&type8);
535   auto param10 = model->addOperand(&type8);
536   auto param11 = model->addOperand(&type9);
537   auto param12 = model->addOperand(&type9);
538   auto layout = model->addOperand(&type10);
539   auto featureMap = model->addOperand(&type12);
540   auto out = model->addOperand(&type27);
541   // Phase 2, operations
542   static float scores_init[] = {0.9f, 0.1f};
543   model->setOperandValue(scores, scores_init, sizeof(float) * 2);
544   static float roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
545   model->setOperandValue(roi, roi_init, sizeof(float) * 8);
546   static int32_t param_init[] = {0};
547   model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
548   static float param1_init[] = {0.3f};
549   model->setOperandValue(param1, param1_init, sizeof(float) * 1);
550   static int32_t param2_init[] = {-1};
551   model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
552   static int32_t param3_init[] = {0};
553   model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
554   static float param4_init[] = {0.4f};
555   model->setOperandValue(param4, param4_init, sizeof(float) * 1);
556   static float param5_init[] = {1.0f};
557   model->setOperandValue(param5, param5_init, sizeof(float) * 1);
558   static float param6_init[] = {0.3f};
559   model->setOperandValue(param6, param6_init, sizeof(float) * 1);
560   static int32_t param7_init[] = {2};
561   model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
562   static int32_t param8_init[] = {2};
563   model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
564   static float param9_init[] = {2.0f};
565   model->setOperandValue(param9, param9_init, sizeof(float) * 1);
566   static float param10_init[] = {2.0f};
567   model->setOperandValue(param10, param10_init, sizeof(float) * 1);
568   static int32_t param11_init[] = {4};
569   model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
570   static int32_t param12_init[] = {4};
571   model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
572   static bool8 layout_init[] = {false};
573   model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
574   model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
575   model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
576   model->addOperation(ANEURALNETWORKS_RELU1, {featureMap}, {out});
577   // Phase 3, inputs and outputs
578   model->identifyInputsAndOutputs(
579     {in},
580     {scoresOut, classesOut, out});
581   // Phase 4: set relaxed execution
582   model->relaxComputationFloat32toFloat16(true);
583   assert(model->isValid());
584 }
585 
is_ignored_zero_sized_dynamic_output_shape_relaxed(int i)586 inline bool is_ignored_zero_sized_dynamic_output_shape_relaxed(int i) {
587   static std::set<int> ignore = {};
588   return ignore.find(i) != ignore.end();
589 }
590 
CreateModel_zero_sized_dynamic_output_shape_quant8(Model * model)591 void CreateModel_zero_sized_dynamic_output_shape_quant8(Model *model) {
592   OperandType type10(Type::BOOL, {});
593   OperandType type14(Type::TENSOR_QUANT8_ASYMM, {0, 2, 2, 1}, 0.1f, 128);
594   OperandType type15(Type::TENSOR_QUANT8_ASYMM, {1, 1, 1, 1}, 0.1f, 128);
595   OperandType type16(Type::TENSOR_QUANT16_ASYMM, {1, 8}, 0.125f, 0);
596   OperandType type17(Type::TENSOR_QUANT16_ASYMM, {0, 4}, 0.125f, 0);
597   OperandType type18(Type::TENSOR_QUANT8_ASYMM, {1, 2}, 0.1f, 128);
598   OperandType type19(Type::TENSOR_QUANT8_ASYMM, {0}, 0.1f, 128);
599   OperandType type28(Type::TENSOR_QUANT8_ASYMM, {0, 0, 0, 0}, 0.1f, 128);
600   OperandType type5(Type::TENSOR_INT32, {0});
601   OperandType type7(Type::TENSOR_INT32, {1});
602   OperandType type8(Type::FLOAT32, {});
603   OperandType type9(Type::INT32, {});
604   // Phase 1, operands
605   auto scores = model->addOperand(&type18);
606   auto roi = model->addOperand(&type16);
607   auto param = model->addOperand(&type7);
608   auto param1 = model->addOperand(&type8);
609   auto param2 = model->addOperand(&type9);
610   auto param3 = model->addOperand(&type9);
611   auto param4 = model->addOperand(&type8);
612   auto param5 = model->addOperand(&type8);
613   auto param6 = model->addOperand(&type8);
614   auto scoresOut = model->addOperand(&type19);
615   auto roiOut = model->addOperand(&type17);
616   auto classesOut = model->addOperand(&type5);
617   auto batchSplitOut = model->addOperand(&type5);
618   auto in = model->addOperand(&type15);
619   auto param7 = model->addOperand(&type9);
620   auto param8 = model->addOperand(&type9);
621   auto param9 = model->addOperand(&type8);
622   auto param10 = model->addOperand(&type8);
623   auto param11 = model->addOperand(&type9);
624   auto param12 = model->addOperand(&type9);
625   auto layout = model->addOperand(&type10);
626   auto featureMap = model->addOperand(&type14);
627   auto out = model->addOperand(&type28);
628   // Phase 2, operations
629   static uint8_t scores_init[] = {137, 129};
630   model->setOperandValue(scores, scores_init, sizeof(uint8_t) * 2);
631   static uint16_t roi_init[] = {8, 8, 80, 80, 0, 0, 80, 80};
632   model->setOperandValue(roi, roi_init, sizeof(uint16_t) * 8);
633   static int32_t param_init[] = {0};
634   model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
635   static float param1_init[] = {0.3f};
636   model->setOperandValue(param1, param1_init, sizeof(float) * 1);
637   static int32_t param2_init[] = {-1};
638   model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
639   static int32_t param3_init[] = {0};
640   model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
641   static float param4_init[] = {0.4f};
642   model->setOperandValue(param4, param4_init, sizeof(float) * 1);
643   static float param5_init[] = {1.0f};
644   model->setOperandValue(param5, param5_init, sizeof(float) * 1);
645   static float param6_init[] = {0.3f};
646   model->setOperandValue(param6, param6_init, sizeof(float) * 1);
647   static int32_t param7_init[] = {2};
648   model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
649   static int32_t param8_init[] = {2};
650   model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
651   static float param9_init[] = {2.0f};
652   model->setOperandValue(param9, param9_init, sizeof(float) * 1);
653   static float param10_init[] = {2.0f};
654   model->setOperandValue(param10, param10_init, sizeof(float) * 1);
655   static int32_t param11_init[] = {4};
656   model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
657   static int32_t param12_init[] = {4};
658   model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
659   static bool8 layout_init[] = {false};
660   model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
661   model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
662   model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
663   model->addOperation(ANEURALNETWORKS_RELU1, {featureMap}, {out});
664   // Phase 3, inputs and outputs
665   model->identifyInputsAndOutputs(
666     {in},
667     {scoresOut, classesOut, out});
668   assert(model->isValid());
669 }
670 
is_ignored_zero_sized_dynamic_output_shape_quant8(int i)671 inline bool is_ignored_zero_sized_dynamic_output_shape_quant8(int i) {
672   static std::set<int> ignore = {};
673   return ignore.find(i) != ignore.end();
674 }
675 
CreateModel_zero_sized_dynamic_output_shape_float16(Model * model)676 void CreateModel_zero_sized_dynamic_output_shape_float16(Model *model) {
677   OperandType type10(Type::BOOL, {});
678   OperandType type13(Type::TENSOR_FLOAT16, {0, 0, 0, 0});
679   OperandType type20(Type::TENSOR_FLOAT16, {0, 2, 2, 1});
680   OperandType type21(Type::TENSOR_FLOAT16, {1, 1, 1, 1});
681   OperandType type22(Type::FLOAT16, {});
682   OperandType type23(Type::TENSOR_FLOAT16, {1, 8});
683   OperandType type24(Type::TENSOR_FLOAT16, {0, 4});
684   OperandType type25(Type::TENSOR_FLOAT16, {1, 2});
685   OperandType type29(Type::TENSOR_FLOAT16, {0});
686   OperandType type5(Type::TENSOR_INT32, {0});
687   OperandType type7(Type::TENSOR_INT32, {1});
688   OperandType type9(Type::INT32, {});
689   // Phase 1, operands
690   auto scores = model->addOperand(&type25);
691   auto roi = model->addOperand(&type23);
692   auto param = model->addOperand(&type7);
693   auto param1 = model->addOperand(&type22);
694   auto param2 = model->addOperand(&type9);
695   auto param3 = model->addOperand(&type9);
696   auto param4 = model->addOperand(&type22);
697   auto param5 = model->addOperand(&type22);
698   auto param6 = model->addOperand(&type22);
699   auto scoresOut = model->addOperand(&type29);
700   auto roiOut = model->addOperand(&type24);
701   auto classesOut = model->addOperand(&type5);
702   auto batchSplitOut = model->addOperand(&type5);
703   auto in = model->addOperand(&type21);
704   auto param7 = model->addOperand(&type9);
705   auto param8 = model->addOperand(&type9);
706   auto param9 = model->addOperand(&type22);
707   auto param10 = model->addOperand(&type22);
708   auto param11 = model->addOperand(&type9);
709   auto param12 = model->addOperand(&type9);
710   auto layout = model->addOperand(&type10);
711   auto featureMap = model->addOperand(&type20);
712   auto out = model->addOperand(&type13);
713   // Phase 2, operations
714   static _Float16 scores_init[] = {0.8999999761581421f, 0.10000000149011612f};
715   model->setOperandValue(scores, scores_init, sizeof(_Float16) * 2);
716   static _Float16 roi_init[] = {1.0f, 1.0f, 10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f};
717   model->setOperandValue(roi, roi_init, sizeof(_Float16) * 8);
718   static int32_t param_init[] = {0};
719   model->setOperandValue(param, param_init, sizeof(int32_t) * 1);
720   static _Float16 param1_init[] = {0.30000001192092896f};
721   model->setOperandValue(param1, param1_init, sizeof(_Float16) * 1);
722   static int32_t param2_init[] = {-1};
723   model->setOperandValue(param2, param2_init, sizeof(int32_t) * 1);
724   static int32_t param3_init[] = {0};
725   model->setOperandValue(param3, param3_init, sizeof(int32_t) * 1);
726   static _Float16 param4_init[] = {0.4000000059604645f};
727   model->setOperandValue(param4, param4_init, sizeof(_Float16) * 1);
728   static _Float16 param5_init[] = {1.0f};
729   model->setOperandValue(param5, param5_init, sizeof(_Float16) * 1);
730   static _Float16 param6_init[] = {0.30000001192092896f};
731   model->setOperandValue(param6, param6_init, sizeof(_Float16) * 1);
732   static int32_t param7_init[] = {2};
733   model->setOperandValue(param7, param7_init, sizeof(int32_t) * 1);
734   static int32_t param8_init[] = {2};
735   model->setOperandValue(param8, param8_init, sizeof(int32_t) * 1);
736   static _Float16 param9_init[] = {2.0f};
737   model->setOperandValue(param9, param9_init, sizeof(_Float16) * 1);
738   static _Float16 param10_init[] = {2.0f};
739   model->setOperandValue(param10, param10_init, sizeof(_Float16) * 1);
740   static int32_t param11_init[] = {4};
741   model->setOperandValue(param11, param11_init, sizeof(int32_t) * 1);
742   static int32_t param12_init[] = {4};
743   model->setOperandValue(param12, param12_init, sizeof(int32_t) * 1);
744   static bool8 layout_init[] = {false};
745   model->setOperandValue(layout, layout_init, sizeof(bool8) * 1);
746   model->addOperation(ANEURALNETWORKS_BOX_WITH_NMS_LIMIT, {scores, roi, param, param1, param2, param3, param4, param5, param6}, {scoresOut, roiOut, classesOut, batchSplitOut});
747   model->addOperation(ANEURALNETWORKS_ROI_ALIGN, {in, roiOut, batchSplitOut, param7, param8, param9, param10, param11, param12, layout}, {featureMap});
748   model->addOperation(ANEURALNETWORKS_RELU1, {featureMap}, {out});
749   // Phase 3, inputs and outputs
750   model->identifyInputsAndOutputs(
751     {in},
752     {scoresOut, classesOut, out});
753   assert(model->isValid());
754 }
755 
is_ignored_zero_sized_dynamic_output_shape_float16(int i)756 inline bool is_ignored_zero_sized_dynamic_output_shape_float16(int i) {
757   static std::set<int> ignore = {};
758   return ignore.find(i) != ignore.end();
759 }
760 
761