1 // clang-format off
2 // Generated file (from: bidirectional_sequence_lstm_float16_batch_major.mod.py). Do not edit
CreateModel(Model * model)3 void CreateModel(Model *model) {
4   OperandType type0(Type::TENSOR_FLOAT16, {1, 3, 2});
5   OperandType type1(Type::TENSOR_FLOAT16, {4, 2});
6   OperandType type2(Type::TENSOR_FLOAT16, {4, 4});
7   OperandType type3(Type::TENSOR_FLOAT16, {4});
8   OperandType type4(Type::TENSOR_FLOAT16, {1, 4});
9   OperandType type5(Type::TENSOR_FLOAT16, {1, 3, 4});
10   OperandType type6(Type::INT32, {});
11   OperandType type7(Type::FLOAT16, {});
12   OperandType type8(Type::BOOL, {});
13   // Phase 1, operands
14   auto input = model->addOperand(&type0);
15   auto fw_input_to_input_weights = model->addOperand(&type1);
16   auto fw_input_to_forget_weights = model->addOperand(&type1);
17   auto fw_input_to_cell_weights = model->addOperand(&type1);
18   auto fw_input_to_output_weights = model->addOperand(&type1);
19   auto fw_recurrent_to_input_weights = model->addOperand(&type2);
20   auto fw_recurrent_to_forget_weights = model->addOperand(&type2);
21   auto fw_recurrent_to_cell_weights = model->addOperand(&type2);
22   auto fw_recurrent_to_output_weights = model->addOperand(&type2);
23   auto fw_cell_to_input_weights = model->addOperand(&type3);
24   auto fw_cell_to_forget_weights = model->addOperand(&type3);
25   auto fw_cell_to_output_weights = model->addOperand(&type3);
26   auto fw_input_gate_bias = model->addOperand(&type3);
27   auto fw_forget_gate_bias = model->addOperand(&type3);
28   auto fw_cell_bias = model->addOperand(&type3);
29   auto fw_output_gate_bias = model->addOperand(&type3);
30   auto fw_projection_weights = model->addOperand(&type2);
31   auto fw_projection_bias = model->addOperand(&type3);
32   auto bw_input_to_input_weights = model->addOperand(&type1);
33   auto bw_input_to_forget_weights = model->addOperand(&type1);
34   auto bw_input_to_cell_weights = model->addOperand(&type1);
35   auto bw_input_to_output_weights = model->addOperand(&type1);
36   auto bw_recurrent_to_input_weights = model->addOperand(&type2);
37   auto bw_recurrent_to_forget_weights = model->addOperand(&type2);
38   auto bw_recurrent_to_cell_weights = model->addOperand(&type2);
39   auto bw_recurrent_to_output_weights = model->addOperand(&type2);
40   auto bw_cell_to_input_weights = model->addOperand(&type3);
41   auto bw_cell_to_forget_weights = model->addOperand(&type3);
42   auto bw_cell_to_output_weights = model->addOperand(&type3);
43   auto bw_input_gate_bias = model->addOperand(&type3);
44   auto bw_forget_gate_bias = model->addOperand(&type3);
45   auto bw_cell_bias = model->addOperand(&type3);
46   auto bw_output_gate_bias = model->addOperand(&type3);
47   auto bw_projection_weights = model->addOperand(&type2);
48   auto bw_projection_bias = model->addOperand(&type3);
49   auto fw_activatiom_state = model->addOperand(&type4);
50   auto fw_cell_state = model->addOperand(&type4);
51   auto bw_activatiom_state = model->addOperand(&type4);
52   auto bw_cell_state = model->addOperand(&type4);
53   auto input1 = model->addOperand(&type0);
54   auto fw_aux_input_to_input_weights = model->addOperand(&type1);
55   auto fw_input_to_forget_weights1 = model->addOperand(&type1);
56   auto fw_aux_input_to_cell_weights = model->addOperand(&type1);
57   auto fw_aux_input_to_output_weights = model->addOperand(&type1);
58   auto bw_aux_input_to_input_weights = model->addOperand(&type1);
59   auto bw_input_to_forget_weights1 = model->addOperand(&type1);
60   auto bw_aux_input_to_cell_weights = model->addOperand(&type1);
61   auto bw_aux_input_to_output_weights = model->addOperand(&type1);
62   auto activation = model->addOperand(&type6);
63   auto cell_clip = model->addOperand(&type7);
64   auto proj_clip = model->addOperand(&type7);
65   auto merge_outputs = model->addOperand(&type8);
66   auto time_major = model->addOperand(&type8);
67   auto input_layer_norm_weights = model->addOperand(&type3);
68   auto forget_layer_norm_weights = model->addOperand(&type3);
69   auto cell_layer_norm_weights = model->addOperand(&type3);
70   auto output_layer_norm_weights = model->addOperand(&type3);
71   auto input_layer_norm_weights1 = model->addOperand(&type3);
72   auto forget_layer_norm_weights1 = model->addOperand(&type3);
73   auto cell_layer_norm_weights1 = model->addOperand(&type3);
74   auto output_layer_norm_weights1 = model->addOperand(&type3);
75   auto fw_output = model->addOperand(&type5);
76   auto bw_output = model->addOperand(&type5);
77   // Phase 2, operations
78   static int32_t activation_init[] = {4};
79   model->setOperandValue(activation, activation_init, sizeof(int32_t) * 1);
80   static _Float16 cell_clip_init[] = {0.0f};
81   model->setOperandValue(cell_clip, cell_clip_init, sizeof(_Float16) * 1);
82   static _Float16 proj_clip_init[] = {0.0f};
83   model->setOperandValue(proj_clip, proj_clip_init, sizeof(_Float16) * 1);
84   static bool8 merge_outputs_init[] = {false};
85   model->setOperandValue(merge_outputs, merge_outputs_init, sizeof(bool8) * 1);
86   static bool8 time_major_init[] = {false};
87   model->setOperandValue(time_major, time_major_init, sizeof(bool8) * 1);
88   model->addOperation(ANEURALNETWORKS_BIDIRECTIONAL_SEQUENCE_LSTM, {input, fw_input_to_input_weights, fw_input_to_forget_weights, fw_input_to_cell_weights, fw_input_to_output_weights, fw_recurrent_to_input_weights, fw_recurrent_to_forget_weights, fw_recurrent_to_cell_weights, fw_recurrent_to_output_weights, fw_cell_to_input_weights, fw_cell_to_forget_weights, fw_cell_to_output_weights, fw_input_gate_bias, fw_forget_gate_bias, fw_cell_bias, fw_output_gate_bias, fw_projection_weights, fw_projection_bias, bw_input_to_input_weights, bw_input_to_forget_weights, bw_input_to_cell_weights, bw_input_to_output_weights, bw_recurrent_to_input_weights, bw_recurrent_to_forget_weights, bw_recurrent_to_cell_weights, bw_recurrent_to_output_weights, bw_cell_to_input_weights, bw_cell_to_forget_weights, bw_cell_to_output_weights, bw_input_gate_bias, bw_forget_gate_bias, bw_cell_bias, bw_output_gate_bias, bw_projection_weights, bw_projection_bias, fw_activatiom_state, fw_cell_state, bw_activatiom_state, bw_cell_state, input1, fw_aux_input_to_input_weights, fw_input_to_forget_weights1, fw_aux_input_to_cell_weights, fw_aux_input_to_output_weights, bw_aux_input_to_input_weights, bw_input_to_forget_weights1, bw_aux_input_to_cell_weights, bw_aux_input_to_output_weights, activation, cell_clip, proj_clip, merge_outputs, time_major, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights, input_layer_norm_weights1, forget_layer_norm_weights1, cell_layer_norm_weights1, output_layer_norm_weights1}, {fw_output, bw_output});
89   // Phase 3, inputs and outputs
90   model->identifyInputsAndOutputs(
91     {input, fw_input_to_input_weights, fw_input_to_forget_weights, fw_input_to_cell_weights, fw_input_to_output_weights, fw_recurrent_to_input_weights, fw_recurrent_to_forget_weights, fw_recurrent_to_cell_weights, fw_recurrent_to_output_weights, fw_cell_to_input_weights, fw_cell_to_forget_weights, fw_cell_to_output_weights, fw_input_gate_bias, fw_forget_gate_bias, fw_cell_bias, fw_output_gate_bias, fw_projection_weights, fw_projection_bias, bw_input_to_input_weights, bw_input_to_forget_weights, bw_input_to_cell_weights, bw_input_to_output_weights, bw_recurrent_to_input_weights, bw_recurrent_to_forget_weights, bw_recurrent_to_cell_weights, bw_recurrent_to_output_weights, bw_cell_to_input_weights, bw_cell_to_forget_weights, bw_cell_to_output_weights, bw_input_gate_bias, bw_forget_gate_bias, bw_cell_bias, bw_output_gate_bias, bw_projection_weights, bw_projection_bias, fw_activatiom_state, fw_cell_state, bw_activatiom_state, bw_cell_state, input1, fw_aux_input_to_input_weights, fw_input_to_forget_weights1, fw_aux_input_to_cell_weights, fw_aux_input_to_output_weights, bw_aux_input_to_input_weights, bw_input_to_forget_weights1, bw_aux_input_to_cell_weights, bw_aux_input_to_output_weights, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights, input_layer_norm_weights1, forget_layer_norm_weights1, cell_layer_norm_weights1, output_layer_norm_weights1},
92     {fw_output, bw_output});
93   assert(model->isValid());
94 }
95 
is_ignored(int i)96 inline bool is_ignored(int i) {
97   static std::set<int> ignore = {};
98   return ignore.find(i) != ignore.end();
99 }
100 
CreateModel_dynamic_output_shape(Model * model)101 void CreateModel_dynamic_output_shape(Model *model) {
102   OperandType type0(Type::TENSOR_FLOAT16, {1, 3, 2});
103   OperandType type1(Type::TENSOR_FLOAT16, {4, 2});
104   OperandType type2(Type::TENSOR_FLOAT16, {4, 4});
105   OperandType type3(Type::TENSOR_FLOAT16, {4});
106   OperandType type4(Type::TENSOR_FLOAT16, {1, 4});
107   OperandType type6(Type::INT32, {});
108   OperandType type7(Type::FLOAT16, {});
109   OperandType type8(Type::BOOL, {});
110   OperandType type9(Type::TENSOR_FLOAT16, {0, 0, 0});
111   // Phase 1, operands
112   auto input = model->addOperand(&type0);
113   auto fw_input_to_input_weights = model->addOperand(&type1);
114   auto fw_input_to_forget_weights = model->addOperand(&type1);
115   auto fw_input_to_cell_weights = model->addOperand(&type1);
116   auto fw_input_to_output_weights = model->addOperand(&type1);
117   auto fw_recurrent_to_input_weights = model->addOperand(&type2);
118   auto fw_recurrent_to_forget_weights = model->addOperand(&type2);
119   auto fw_recurrent_to_cell_weights = model->addOperand(&type2);
120   auto fw_recurrent_to_output_weights = model->addOperand(&type2);
121   auto fw_cell_to_input_weights = model->addOperand(&type3);
122   auto fw_cell_to_forget_weights = model->addOperand(&type3);
123   auto fw_cell_to_output_weights = model->addOperand(&type3);
124   auto fw_input_gate_bias = model->addOperand(&type3);
125   auto fw_forget_gate_bias = model->addOperand(&type3);
126   auto fw_cell_bias = model->addOperand(&type3);
127   auto fw_output_gate_bias = model->addOperand(&type3);
128   auto fw_projection_weights = model->addOperand(&type2);
129   auto fw_projection_bias = model->addOperand(&type3);
130   auto bw_input_to_input_weights = model->addOperand(&type1);
131   auto bw_input_to_forget_weights = model->addOperand(&type1);
132   auto bw_input_to_cell_weights = model->addOperand(&type1);
133   auto bw_input_to_output_weights = model->addOperand(&type1);
134   auto bw_recurrent_to_input_weights = model->addOperand(&type2);
135   auto bw_recurrent_to_forget_weights = model->addOperand(&type2);
136   auto bw_recurrent_to_cell_weights = model->addOperand(&type2);
137   auto bw_recurrent_to_output_weights = model->addOperand(&type2);
138   auto bw_cell_to_input_weights = model->addOperand(&type3);
139   auto bw_cell_to_forget_weights = model->addOperand(&type3);
140   auto bw_cell_to_output_weights = model->addOperand(&type3);
141   auto bw_input_gate_bias = model->addOperand(&type3);
142   auto bw_forget_gate_bias = model->addOperand(&type3);
143   auto bw_cell_bias = model->addOperand(&type3);
144   auto bw_output_gate_bias = model->addOperand(&type3);
145   auto bw_projection_weights = model->addOperand(&type2);
146   auto bw_projection_bias = model->addOperand(&type3);
147   auto fw_activatiom_state = model->addOperand(&type4);
148   auto fw_cell_state = model->addOperand(&type4);
149   auto bw_activatiom_state = model->addOperand(&type4);
150   auto bw_cell_state = model->addOperand(&type4);
151   auto input1 = model->addOperand(&type0);
152   auto fw_aux_input_to_input_weights = model->addOperand(&type1);
153   auto fw_input_to_forget_weights1 = model->addOperand(&type1);
154   auto fw_aux_input_to_cell_weights = model->addOperand(&type1);
155   auto fw_aux_input_to_output_weights = model->addOperand(&type1);
156   auto bw_aux_input_to_input_weights = model->addOperand(&type1);
157   auto bw_input_to_forget_weights1 = model->addOperand(&type1);
158   auto bw_aux_input_to_cell_weights = model->addOperand(&type1);
159   auto bw_aux_input_to_output_weights = model->addOperand(&type1);
160   auto activation = model->addOperand(&type6);
161   auto cell_clip = model->addOperand(&type7);
162   auto proj_clip = model->addOperand(&type7);
163   auto merge_outputs = model->addOperand(&type8);
164   auto time_major = model->addOperand(&type8);
165   auto input_layer_norm_weights = model->addOperand(&type3);
166   auto forget_layer_norm_weights = model->addOperand(&type3);
167   auto cell_layer_norm_weights = model->addOperand(&type3);
168   auto output_layer_norm_weights = model->addOperand(&type3);
169   auto input_layer_norm_weights1 = model->addOperand(&type3);
170   auto forget_layer_norm_weights1 = model->addOperand(&type3);
171   auto cell_layer_norm_weights1 = model->addOperand(&type3);
172   auto output_layer_norm_weights1 = model->addOperand(&type3);
173   auto fw_output = model->addOperand(&type9);
174   auto bw_output = model->addOperand(&type9);
175   // Phase 2, operations
176   static int32_t activation_init[] = {4};
177   model->setOperandValue(activation, activation_init, sizeof(int32_t) * 1);
178   static _Float16 cell_clip_init[] = {0.0f};
179   model->setOperandValue(cell_clip, cell_clip_init, sizeof(_Float16) * 1);
180   static _Float16 proj_clip_init[] = {0.0f};
181   model->setOperandValue(proj_clip, proj_clip_init, sizeof(_Float16) * 1);
182   static bool8 merge_outputs_init[] = {false};
183   model->setOperandValue(merge_outputs, merge_outputs_init, sizeof(bool8) * 1);
184   static bool8 time_major_init[] = {false};
185   model->setOperandValue(time_major, time_major_init, sizeof(bool8) * 1);
186   model->addOperation(ANEURALNETWORKS_BIDIRECTIONAL_SEQUENCE_LSTM, {input, fw_input_to_input_weights, fw_input_to_forget_weights, fw_input_to_cell_weights, fw_input_to_output_weights, fw_recurrent_to_input_weights, fw_recurrent_to_forget_weights, fw_recurrent_to_cell_weights, fw_recurrent_to_output_weights, fw_cell_to_input_weights, fw_cell_to_forget_weights, fw_cell_to_output_weights, fw_input_gate_bias, fw_forget_gate_bias, fw_cell_bias, fw_output_gate_bias, fw_projection_weights, fw_projection_bias, bw_input_to_input_weights, bw_input_to_forget_weights, bw_input_to_cell_weights, bw_input_to_output_weights, bw_recurrent_to_input_weights, bw_recurrent_to_forget_weights, bw_recurrent_to_cell_weights, bw_recurrent_to_output_weights, bw_cell_to_input_weights, bw_cell_to_forget_weights, bw_cell_to_output_weights, bw_input_gate_bias, bw_forget_gate_bias, bw_cell_bias, bw_output_gate_bias, bw_projection_weights, bw_projection_bias, fw_activatiom_state, fw_cell_state, bw_activatiom_state, bw_cell_state, input1, fw_aux_input_to_input_weights, fw_input_to_forget_weights1, fw_aux_input_to_cell_weights, fw_aux_input_to_output_weights, bw_aux_input_to_input_weights, bw_input_to_forget_weights1, bw_aux_input_to_cell_weights, bw_aux_input_to_output_weights, activation, cell_clip, proj_clip, merge_outputs, time_major, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights, input_layer_norm_weights1, forget_layer_norm_weights1, cell_layer_norm_weights1, output_layer_norm_weights1}, {fw_output, bw_output});
187   // Phase 3, inputs and outputs
188   model->identifyInputsAndOutputs(
189     {input, fw_input_to_input_weights, fw_input_to_forget_weights, fw_input_to_cell_weights, fw_input_to_output_weights, fw_recurrent_to_input_weights, fw_recurrent_to_forget_weights, fw_recurrent_to_cell_weights, fw_recurrent_to_output_weights, fw_cell_to_input_weights, fw_cell_to_forget_weights, fw_cell_to_output_weights, fw_input_gate_bias, fw_forget_gate_bias, fw_cell_bias, fw_output_gate_bias, fw_projection_weights, fw_projection_bias, bw_input_to_input_weights, bw_input_to_forget_weights, bw_input_to_cell_weights, bw_input_to_output_weights, bw_recurrent_to_input_weights, bw_recurrent_to_forget_weights, bw_recurrent_to_cell_weights, bw_recurrent_to_output_weights, bw_cell_to_input_weights, bw_cell_to_forget_weights, bw_cell_to_output_weights, bw_input_gate_bias, bw_forget_gate_bias, bw_cell_bias, bw_output_gate_bias, bw_projection_weights, bw_projection_bias, fw_activatiom_state, fw_cell_state, bw_activatiom_state, bw_cell_state, input1, fw_aux_input_to_input_weights, fw_input_to_forget_weights1, fw_aux_input_to_cell_weights, fw_aux_input_to_output_weights, bw_aux_input_to_input_weights, bw_input_to_forget_weights1, bw_aux_input_to_cell_weights, bw_aux_input_to_output_weights, input_layer_norm_weights, forget_layer_norm_weights, cell_layer_norm_weights, output_layer_norm_weights, input_layer_norm_weights1, forget_layer_norm_weights1, cell_layer_norm_weights1, output_layer_norm_weights1},
190     {fw_output, bw_output});
191   assert(model->isValid());
192 }
193 
is_ignored_dynamic_output_shape(int i)194 inline bool is_ignored_dynamic_output_shape(int i) {
195   static std::set<int> ignore = {};
196   return ignore.find(i) != ignore.end();
197 }
198 
199