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