1 // clang-format off
2 // Generated file (from: unidirectional_sequence_lstm_layer_norm_cifg_peephole.mod.py). Do not edit
CreateModel(Model * model)3 void CreateModel(Model *model) {
4   OperandType type0(Type::TENSOR_FLOAT32, {3, 2, 5});
5   OperandType type1(Type::TENSOR_FLOAT32, {0, 0});
6   OperandType type10(Type::FLOAT32, {});
7   OperandType type11(Type::BOOL, {});
8   OperandType type12(Type::TENSOR_FLOAT32, {3, 2, 3});
9   OperandType type2(Type::TENSOR_FLOAT32, {4, 5});
10   OperandType type3(Type::TENSOR_FLOAT32, {4, 3});
11   OperandType type4(Type::TENSOR_FLOAT32, {0});
12   OperandType type5(Type::TENSOR_FLOAT32, {4});
13   OperandType type6(Type::TENSOR_FLOAT32, {3, 4});
14   OperandType type7(Type::TENSOR_FLOAT32, {2, 3});
15   OperandType type8(Type::TENSOR_FLOAT32, {2, 4});
16   OperandType type9(Type::INT32, {});
17   // Phase 1, operands
18   auto input = model->addOperand(&type0);
19   auto input_to_input_weights = model->addOperand(&type1);
20   auto input_to_forget_weights = model->addOperand(&type2);
21   auto input_to_cell_weights = model->addOperand(&type2);
22   auto input_to_output_weights = model->addOperand(&type2);
23   auto recurrent_to_intput_weights = model->addOperand(&type1);
24   auto recurrent_to_forget_weights = model->addOperand(&type3);
25   auto recurrent_to_cell_weights = model->addOperand(&type3);
26   auto recurrent_to_output_weights = model->addOperand(&type3);
27   auto cell_to_input_weights = model->addOperand(&type4);
28   auto cell_to_forget_weights = model->addOperand(&type5);
29   auto cell_to_output_weights = model->addOperand(&type5);
30   auto input_gate_bias = model->addOperand(&type4);
31   auto forget_gate_bias = model->addOperand(&type5);
32   auto cell_gate_bias = model->addOperand(&type5);
33   auto output_gate_bias = model->addOperand(&type5);
34   auto projection_weights = model->addOperand(&type6);
35   auto projection_bias = model->addOperand(&type4);
36   auto output_state_in = model->addOperand(&type7);
37   auto cell_state_in = model->addOperand(&type8);
38   auto activation_param = model->addOperand(&type9);
39   auto cell_clip_param = model->addOperand(&type10);
40   auto proj_clip_param = model->addOperand(&type10);
41   auto time_major_param = model->addOperand(&type11);
42   auto input_layer_norm_weights = model->addOperand(&type4);
43   auto forget_layer_norm_weights = model->addOperand(&type5);
44   auto cell_layer_norm_weights = model->addOperand(&type5);
45   auto output_layer_norm_weights = model->addOperand(&type5);
46   auto output = model->addOperand(&type12);
47   // Phase 2, operations
48   static int32_t activation_param_init[] = {4};
49   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
50   static float cell_clip_param_init[] = {0.0f};
51   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1);
52   static float proj_clip_param_init[] = {0.0f};
53   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1);
54   static bool8 time_major_param_init[] = {true};
55   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
56   model->addOperation(ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param, time_major_param, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights}, {output});
57   // Phase 3, inputs and outputs
58   model->identifyInputsAndOutputs(
59     {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights},
60     {output});
61   assert(model->isValid());
62 }
63 
is_ignored(int i)64 inline bool is_ignored(int i) {
65   static std::set<int> ignore = {};
66   return ignore.find(i) != ignore.end();
67 }
68 
CreateModel_relaxed(Model * model)69 void CreateModel_relaxed(Model *model) {
70   OperandType type0(Type::TENSOR_FLOAT32, {3, 2, 5});
71   OperandType type1(Type::TENSOR_FLOAT32, {0, 0});
72   OperandType type10(Type::FLOAT32, {});
73   OperandType type11(Type::BOOL, {});
74   OperandType type12(Type::TENSOR_FLOAT32, {3, 2, 3});
75   OperandType type2(Type::TENSOR_FLOAT32, {4, 5});
76   OperandType type3(Type::TENSOR_FLOAT32, {4, 3});
77   OperandType type4(Type::TENSOR_FLOAT32, {0});
78   OperandType type5(Type::TENSOR_FLOAT32, {4});
79   OperandType type6(Type::TENSOR_FLOAT32, {3, 4});
80   OperandType type7(Type::TENSOR_FLOAT32, {2, 3});
81   OperandType type8(Type::TENSOR_FLOAT32, {2, 4});
82   OperandType type9(Type::INT32, {});
83   // Phase 1, operands
84   auto input = model->addOperand(&type0);
85   auto input_to_input_weights = model->addOperand(&type1);
86   auto input_to_forget_weights = model->addOperand(&type2);
87   auto input_to_cell_weights = model->addOperand(&type2);
88   auto input_to_output_weights = model->addOperand(&type2);
89   auto recurrent_to_intput_weights = model->addOperand(&type1);
90   auto recurrent_to_forget_weights = model->addOperand(&type3);
91   auto recurrent_to_cell_weights = model->addOperand(&type3);
92   auto recurrent_to_output_weights = model->addOperand(&type3);
93   auto cell_to_input_weights = model->addOperand(&type4);
94   auto cell_to_forget_weights = model->addOperand(&type5);
95   auto cell_to_output_weights = model->addOperand(&type5);
96   auto input_gate_bias = model->addOperand(&type4);
97   auto forget_gate_bias = model->addOperand(&type5);
98   auto cell_gate_bias = model->addOperand(&type5);
99   auto output_gate_bias = model->addOperand(&type5);
100   auto projection_weights = model->addOperand(&type6);
101   auto projection_bias = model->addOperand(&type4);
102   auto output_state_in = model->addOperand(&type7);
103   auto cell_state_in = model->addOperand(&type8);
104   auto activation_param = model->addOperand(&type9);
105   auto cell_clip_param = model->addOperand(&type10);
106   auto proj_clip_param = model->addOperand(&type10);
107   auto time_major_param = model->addOperand(&type11);
108   auto input_layer_norm_weights = model->addOperand(&type4);
109   auto forget_layer_norm_weights = model->addOperand(&type5);
110   auto cell_layer_norm_weights = model->addOperand(&type5);
111   auto output_layer_norm_weights = model->addOperand(&type5);
112   auto output = model->addOperand(&type12);
113   // Phase 2, operations
114   static int32_t activation_param_init[] = {4};
115   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
116   static float cell_clip_param_init[] = {0.0f};
117   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1);
118   static float proj_clip_param_init[] = {0.0f};
119   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1);
120   static bool8 time_major_param_init[] = {true};
121   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
122   model->addOperation(ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param, time_major_param, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights}, {output});
123   // Phase 3, inputs and outputs
124   model->identifyInputsAndOutputs(
125     {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights},
126     {output});
127   // Phase 4: set relaxed execution
128   model->relaxComputationFloat32toFloat16(true);
129   assert(model->isValid());
130 }
131 
is_ignored_relaxed(int i)132 inline bool is_ignored_relaxed(int i) {
133   static std::set<int> ignore = {};
134   return ignore.find(i) != ignore.end();
135 }
136 
CreateModel_float16(Model * model)137 void CreateModel_float16(Model *model) {
138   OperandType type11(Type::BOOL, {});
139   OperandType type13(Type::FLOAT16, {});
140   OperandType type14(Type::TENSOR_FLOAT16, {4});
141   OperandType type15(Type::TENSOR_FLOAT16, {2, 4});
142   OperandType type16(Type::TENSOR_FLOAT16, {0});
143   OperandType type17(Type::TENSOR_FLOAT16, {3, 2, 5});
144   OperandType type18(Type::TENSOR_FLOAT16, {4, 5});
145   OperandType type19(Type::TENSOR_FLOAT16, {0, 0});
146   OperandType type20(Type::TENSOR_FLOAT16, {3, 2, 3});
147   OperandType type21(Type::TENSOR_FLOAT16, {2, 3});
148   OperandType type22(Type::TENSOR_FLOAT16, {3, 4});
149   OperandType type23(Type::TENSOR_FLOAT16, {4, 3});
150   OperandType type9(Type::INT32, {});
151   // Phase 1, operands
152   auto input = model->addOperand(&type17);
153   auto input_to_input_weights = model->addOperand(&type19);
154   auto input_to_forget_weights = model->addOperand(&type18);
155   auto input_to_cell_weights = model->addOperand(&type18);
156   auto input_to_output_weights = model->addOperand(&type18);
157   auto recurrent_to_intput_weights = model->addOperand(&type19);
158   auto recurrent_to_forget_weights = model->addOperand(&type23);
159   auto recurrent_to_cell_weights = model->addOperand(&type23);
160   auto recurrent_to_output_weights = model->addOperand(&type23);
161   auto cell_to_input_weights = model->addOperand(&type16);
162   auto cell_to_forget_weights = model->addOperand(&type14);
163   auto cell_to_output_weights = model->addOperand(&type14);
164   auto input_gate_bias = model->addOperand(&type16);
165   auto forget_gate_bias = model->addOperand(&type14);
166   auto cell_gate_bias = model->addOperand(&type14);
167   auto output_gate_bias = model->addOperand(&type14);
168   auto projection_weights = model->addOperand(&type22);
169   auto projection_bias = model->addOperand(&type16);
170   auto output_state_in = model->addOperand(&type21);
171   auto cell_state_in = model->addOperand(&type15);
172   auto activation_param = model->addOperand(&type9);
173   auto cell_clip_param = model->addOperand(&type13);
174   auto proj_clip_param = model->addOperand(&type13);
175   auto time_major_param = model->addOperand(&type11);
176   auto input_layer_norm_weights = model->addOperand(&type16);
177   auto forget_layer_norm_weights = model->addOperand(&type14);
178   auto cell_layer_norm_weights = model->addOperand(&type14);
179   auto output_layer_norm_weights = model->addOperand(&type14);
180   auto output = model->addOperand(&type20);
181   // Phase 2, operations
182   static int32_t activation_param_init[] = {4};
183   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
184   static _Float16 cell_clip_param_init[] = {0.0f};
185   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(_Float16) * 1);
186   static _Float16 proj_clip_param_init[] = {0.0f};
187   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(_Float16) * 1);
188   static bool8 time_major_param_init[] = {true};
189   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
190   model->addOperation(ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param, time_major_param, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights}, {output});
191   // Phase 3, inputs and outputs
192   model->identifyInputsAndOutputs(
193     {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights},
194     {output});
195   assert(model->isValid());
196 }
197 
is_ignored_float16(int i)198 inline bool is_ignored_float16(int i) {
199   static std::set<int> ignore = {};
200   return ignore.find(i) != ignore.end();
201 }
202 
CreateModel_dynamic_output_shape(Model * model)203 void CreateModel_dynamic_output_shape(Model *model) {
204   OperandType type0(Type::TENSOR_FLOAT32, {3, 2, 5});
205   OperandType type1(Type::TENSOR_FLOAT32, {0, 0});
206   OperandType type10(Type::FLOAT32, {});
207   OperandType type11(Type::BOOL, {});
208   OperandType type2(Type::TENSOR_FLOAT32, {4, 5});
209   OperandType type24(Type::TENSOR_FLOAT32, {0, 0, 0});
210   OperandType type3(Type::TENSOR_FLOAT32, {4, 3});
211   OperandType type4(Type::TENSOR_FLOAT32, {0});
212   OperandType type5(Type::TENSOR_FLOAT32, {4});
213   OperandType type6(Type::TENSOR_FLOAT32, {3, 4});
214   OperandType type7(Type::TENSOR_FLOAT32, {2, 3});
215   OperandType type8(Type::TENSOR_FLOAT32, {2, 4});
216   OperandType type9(Type::INT32, {});
217   // Phase 1, operands
218   auto input = model->addOperand(&type0);
219   auto input_to_input_weights = model->addOperand(&type1);
220   auto input_to_forget_weights = model->addOperand(&type2);
221   auto input_to_cell_weights = model->addOperand(&type2);
222   auto input_to_output_weights = model->addOperand(&type2);
223   auto recurrent_to_intput_weights = model->addOperand(&type1);
224   auto recurrent_to_forget_weights = model->addOperand(&type3);
225   auto recurrent_to_cell_weights = model->addOperand(&type3);
226   auto recurrent_to_output_weights = model->addOperand(&type3);
227   auto cell_to_input_weights = model->addOperand(&type4);
228   auto cell_to_forget_weights = model->addOperand(&type5);
229   auto cell_to_output_weights = model->addOperand(&type5);
230   auto input_gate_bias = model->addOperand(&type4);
231   auto forget_gate_bias = model->addOperand(&type5);
232   auto cell_gate_bias = model->addOperand(&type5);
233   auto output_gate_bias = model->addOperand(&type5);
234   auto projection_weights = model->addOperand(&type6);
235   auto projection_bias = model->addOperand(&type4);
236   auto output_state_in = model->addOperand(&type7);
237   auto cell_state_in = model->addOperand(&type8);
238   auto activation_param = model->addOperand(&type9);
239   auto cell_clip_param = model->addOperand(&type10);
240   auto proj_clip_param = model->addOperand(&type10);
241   auto time_major_param = model->addOperand(&type11);
242   auto input_layer_norm_weights = model->addOperand(&type4);
243   auto forget_layer_norm_weights = model->addOperand(&type5);
244   auto cell_layer_norm_weights = model->addOperand(&type5);
245   auto output_layer_norm_weights = model->addOperand(&type5);
246   auto output = model->addOperand(&type24);
247   // Phase 2, operations
248   static int32_t activation_param_init[] = {4};
249   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
250   static float cell_clip_param_init[] = {0.0f};
251   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1);
252   static float proj_clip_param_init[] = {0.0f};
253   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1);
254   static bool8 time_major_param_init[] = {true};
255   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
256   model->addOperation(ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param, time_major_param, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights}, {output});
257   // Phase 3, inputs and outputs
258   model->identifyInputsAndOutputs(
259     {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights},
260     {output});
261   assert(model->isValid());
262 }
263 
is_ignored_dynamic_output_shape(int i)264 inline bool is_ignored_dynamic_output_shape(int i) {
265   static std::set<int> ignore = {};
266   return ignore.find(i) != ignore.end();
267 }
268 
CreateModel_dynamic_output_shape_relaxed(Model * model)269 void CreateModel_dynamic_output_shape_relaxed(Model *model) {
270   OperandType type0(Type::TENSOR_FLOAT32, {3, 2, 5});
271   OperandType type1(Type::TENSOR_FLOAT32, {0, 0});
272   OperandType type10(Type::FLOAT32, {});
273   OperandType type11(Type::BOOL, {});
274   OperandType type2(Type::TENSOR_FLOAT32, {4, 5});
275   OperandType type24(Type::TENSOR_FLOAT32, {0, 0, 0});
276   OperandType type3(Type::TENSOR_FLOAT32, {4, 3});
277   OperandType type4(Type::TENSOR_FLOAT32, {0});
278   OperandType type5(Type::TENSOR_FLOAT32, {4});
279   OperandType type6(Type::TENSOR_FLOAT32, {3, 4});
280   OperandType type7(Type::TENSOR_FLOAT32, {2, 3});
281   OperandType type8(Type::TENSOR_FLOAT32, {2, 4});
282   OperandType type9(Type::INT32, {});
283   // Phase 1, operands
284   auto input = model->addOperand(&type0);
285   auto input_to_input_weights = model->addOperand(&type1);
286   auto input_to_forget_weights = model->addOperand(&type2);
287   auto input_to_cell_weights = model->addOperand(&type2);
288   auto input_to_output_weights = model->addOperand(&type2);
289   auto recurrent_to_intput_weights = model->addOperand(&type1);
290   auto recurrent_to_forget_weights = model->addOperand(&type3);
291   auto recurrent_to_cell_weights = model->addOperand(&type3);
292   auto recurrent_to_output_weights = model->addOperand(&type3);
293   auto cell_to_input_weights = model->addOperand(&type4);
294   auto cell_to_forget_weights = model->addOperand(&type5);
295   auto cell_to_output_weights = model->addOperand(&type5);
296   auto input_gate_bias = model->addOperand(&type4);
297   auto forget_gate_bias = model->addOperand(&type5);
298   auto cell_gate_bias = model->addOperand(&type5);
299   auto output_gate_bias = model->addOperand(&type5);
300   auto projection_weights = model->addOperand(&type6);
301   auto projection_bias = model->addOperand(&type4);
302   auto output_state_in = model->addOperand(&type7);
303   auto cell_state_in = model->addOperand(&type8);
304   auto activation_param = model->addOperand(&type9);
305   auto cell_clip_param = model->addOperand(&type10);
306   auto proj_clip_param = model->addOperand(&type10);
307   auto time_major_param = model->addOperand(&type11);
308   auto input_layer_norm_weights = model->addOperand(&type4);
309   auto forget_layer_norm_weights = model->addOperand(&type5);
310   auto cell_layer_norm_weights = model->addOperand(&type5);
311   auto output_layer_norm_weights = model->addOperand(&type5);
312   auto output = model->addOperand(&type24);
313   // Phase 2, operations
314   static int32_t activation_param_init[] = {4};
315   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
316   static float cell_clip_param_init[] = {0.0f};
317   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1);
318   static float proj_clip_param_init[] = {0.0f};
319   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1);
320   static bool8 time_major_param_init[] = {true};
321   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
322   model->addOperation(ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param, time_major_param, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights}, {output});
323   // Phase 3, inputs and outputs
324   model->identifyInputsAndOutputs(
325     {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights},
326     {output});
327   // Phase 4: set relaxed execution
328   model->relaxComputationFloat32toFloat16(true);
329   assert(model->isValid());
330 }
331 
is_ignored_dynamic_output_shape_relaxed(int i)332 inline bool is_ignored_dynamic_output_shape_relaxed(int i) {
333   static std::set<int> ignore = {};
334   return ignore.find(i) != ignore.end();
335 }
336 
CreateModel_dynamic_output_shape_float16(Model * model)337 void CreateModel_dynamic_output_shape_float16(Model *model) {
338   OperandType type11(Type::BOOL, {});
339   OperandType type13(Type::FLOAT16, {});
340   OperandType type14(Type::TENSOR_FLOAT16, {4});
341   OperandType type15(Type::TENSOR_FLOAT16, {2, 4});
342   OperandType type16(Type::TENSOR_FLOAT16, {0});
343   OperandType type17(Type::TENSOR_FLOAT16, {3, 2, 5});
344   OperandType type18(Type::TENSOR_FLOAT16, {4, 5});
345   OperandType type19(Type::TENSOR_FLOAT16, {0, 0});
346   OperandType type21(Type::TENSOR_FLOAT16, {2, 3});
347   OperandType type22(Type::TENSOR_FLOAT16, {3, 4});
348   OperandType type23(Type::TENSOR_FLOAT16, {4, 3});
349   OperandType type25(Type::TENSOR_FLOAT16, {0, 0, 0});
350   OperandType type9(Type::INT32, {});
351   // Phase 1, operands
352   auto input = model->addOperand(&type17);
353   auto input_to_input_weights = model->addOperand(&type19);
354   auto input_to_forget_weights = model->addOperand(&type18);
355   auto input_to_cell_weights = model->addOperand(&type18);
356   auto input_to_output_weights = model->addOperand(&type18);
357   auto recurrent_to_intput_weights = model->addOperand(&type19);
358   auto recurrent_to_forget_weights = model->addOperand(&type23);
359   auto recurrent_to_cell_weights = model->addOperand(&type23);
360   auto recurrent_to_output_weights = model->addOperand(&type23);
361   auto cell_to_input_weights = model->addOperand(&type16);
362   auto cell_to_forget_weights = model->addOperand(&type14);
363   auto cell_to_output_weights = model->addOperand(&type14);
364   auto input_gate_bias = model->addOperand(&type16);
365   auto forget_gate_bias = model->addOperand(&type14);
366   auto cell_gate_bias = model->addOperand(&type14);
367   auto output_gate_bias = model->addOperand(&type14);
368   auto projection_weights = model->addOperand(&type22);
369   auto projection_bias = model->addOperand(&type16);
370   auto output_state_in = model->addOperand(&type21);
371   auto cell_state_in = model->addOperand(&type15);
372   auto activation_param = model->addOperand(&type9);
373   auto cell_clip_param = model->addOperand(&type13);
374   auto proj_clip_param = model->addOperand(&type13);
375   auto time_major_param = model->addOperand(&type11);
376   auto input_layer_norm_weights = model->addOperand(&type16);
377   auto forget_layer_norm_weights = model->addOperand(&type14);
378   auto cell_layer_norm_weights = model->addOperand(&type14);
379   auto output_layer_norm_weights = model->addOperand(&type14);
380   auto output = model->addOperand(&type25);
381   // Phase 2, operations
382   static int32_t activation_param_init[] = {4};
383   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
384   static _Float16 cell_clip_param_init[] = {0.0f};
385   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(_Float16) * 1);
386   static _Float16 proj_clip_param_init[] = {0.0f};
387   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(_Float16) * 1);
388   static bool8 time_major_param_init[] = {true};
389   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
390   model->addOperation(ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM, {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, activation_param, cell_clip_param, proj_clip_param, time_major_param, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights}, {output});
391   // Phase 3, inputs and outputs
392   model->identifyInputsAndOutputs(
393     {input, input_to_input_weights, input_to_forget_weights, input_to_cell_weights, input_to_output_weights, recurrent_to_intput_weights, recurrent_to_forget_weights, recurrent_to_cell_weights, recurrent_to_output_weights, cell_to_input_weights, cell_to_forget_weights, cell_to_output_weights, input_gate_bias, forget_gate_bias, cell_gate_bias, output_gate_bias, projection_weights, projection_bias, output_state_in, cell_state_in, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights},
394     {output});
395   assert(model->isValid());
396 }
397 
is_ignored_dynamic_output_shape_float16(int i)398 inline bool is_ignored_dynamic_output_shape_float16(int i) {
399   static std::set<int> ignore = {};
400   return ignore.find(i) != ignore.end();
401 }
402 
403