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