1 // clang-format off
2 // Generated file (from: bidirectional_sequence_lstm_merge_outputs.mod.py). Do not edit
CreateModel(Model * model)3 void CreateModel(Model *model) {
4   OperandType type0(Type::TENSOR_FLOAT32, {3, 1, 2});
5   OperandType type1(Type::TENSOR_FLOAT32, {4, 2});
6   OperandType type2(Type::TENSOR_FLOAT32, {4, 4});
7   OperandType type3(Type::TENSOR_FLOAT32, {4});
8   OperandType type4(Type::TENSOR_FLOAT32, {1, 4});
9   OperandType type5(Type::TENSOR_FLOAT32, {3, 1, 8});
10   OperandType type6(Type::INT32, {});
11   OperandType type7(Type::FLOAT32, {});
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   // Phase 2, operations
77   static int32_t activation_init[] = {4};
78   model->setOperandValue(activation, activation_init, sizeof(int32_t) * 1);
79   static float cell_clip_init[] = {0.0f};
80   model->setOperandValue(cell_clip, cell_clip_init, sizeof(float) * 1);
81   static float proj_clip_init[] = {0.0f};
82   model->setOperandValue(proj_clip, proj_clip_init, sizeof(float) * 1);
83   static bool8 merge_outputs_init[] = {true};
84   model->setOperandValue(merge_outputs, merge_outputs_init, sizeof(bool8) * 1);
85   static bool8 time_major_init[] = {true};
86   model->setOperandValue(time_major, time_major_init, sizeof(bool8) * 1);
87   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});
88   // Phase 3, inputs and outputs
89   model->identifyInputsAndOutputs(
90     {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},
91     {fw_output});
92   assert(model->isValid());
93 }
94 
is_ignored(int i)95 inline bool is_ignored(int i) {
96   static std::set<int> ignore = {};
97   return ignore.find(i) != ignore.end();
98 }
99 
CreateModel_dynamic_output_shape(Model * model)100 void CreateModel_dynamic_output_shape(Model *model) {
101   OperandType type0(Type::TENSOR_FLOAT32, {3, 1, 2});
102   OperandType type1(Type::TENSOR_FLOAT32, {4, 2});
103   OperandType type2(Type::TENSOR_FLOAT32, {4, 4});
104   OperandType type3(Type::TENSOR_FLOAT32, {4});
105   OperandType type4(Type::TENSOR_FLOAT32, {1, 4});
106   OperandType type6(Type::INT32, {});
107   OperandType type7(Type::FLOAT32, {});
108   OperandType type8(Type::BOOL, {});
109   OperandType type9(Type::TENSOR_FLOAT32, {0, 0, 0});
110   // Phase 1, operands
111   auto input = model->addOperand(&type0);
112   auto fw_input_to_input_weights = model->addOperand(&type1);
113   auto fw_input_to_forget_weights = model->addOperand(&type1);
114   auto fw_input_to_cell_weights = model->addOperand(&type1);
115   auto fw_input_to_output_weights = model->addOperand(&type1);
116   auto fw_recurrent_to_input_weights = model->addOperand(&type2);
117   auto fw_recurrent_to_forget_weights = model->addOperand(&type2);
118   auto fw_recurrent_to_cell_weights = model->addOperand(&type2);
119   auto fw_recurrent_to_output_weights = model->addOperand(&type2);
120   auto fw_cell_to_input_weights = model->addOperand(&type3);
121   auto fw_cell_to_forget_weights = model->addOperand(&type3);
122   auto fw_cell_to_output_weights = model->addOperand(&type3);
123   auto fw_input_gate_bias = model->addOperand(&type3);
124   auto fw_forget_gate_bias = model->addOperand(&type3);
125   auto fw_cell_bias = model->addOperand(&type3);
126   auto fw_output_gate_bias = model->addOperand(&type3);
127   auto fw_projection_weights = model->addOperand(&type2);
128   auto fw_projection_bias = model->addOperand(&type3);
129   auto bw_input_to_input_weights = model->addOperand(&type1);
130   auto bw_input_to_forget_weights = model->addOperand(&type1);
131   auto bw_input_to_cell_weights = model->addOperand(&type1);
132   auto bw_input_to_output_weights = model->addOperand(&type1);
133   auto bw_recurrent_to_input_weights = model->addOperand(&type2);
134   auto bw_recurrent_to_forget_weights = model->addOperand(&type2);
135   auto bw_recurrent_to_cell_weights = model->addOperand(&type2);
136   auto bw_recurrent_to_output_weights = model->addOperand(&type2);
137   auto bw_cell_to_input_weights = model->addOperand(&type3);
138   auto bw_cell_to_forget_weights = model->addOperand(&type3);
139   auto bw_cell_to_output_weights = model->addOperand(&type3);
140   auto bw_input_gate_bias = model->addOperand(&type3);
141   auto bw_forget_gate_bias = model->addOperand(&type3);
142   auto bw_cell_bias = model->addOperand(&type3);
143   auto bw_output_gate_bias = model->addOperand(&type3);
144   auto bw_projection_weights = model->addOperand(&type2);
145   auto bw_projection_bias = model->addOperand(&type3);
146   auto fw_activatiom_state = model->addOperand(&type4);
147   auto fw_cell_state = model->addOperand(&type4);
148   auto bw_activatiom_state = model->addOperand(&type4);
149   auto bw_cell_state = model->addOperand(&type4);
150   auto input1 = model->addOperand(&type0);
151   auto fw_aux_input_to_input_weights = model->addOperand(&type1);
152   auto fw_input_to_forget_weights1 = model->addOperand(&type1);
153   auto fw_aux_input_to_cell_weights = model->addOperand(&type1);
154   auto fw_aux_input_to_output_weights = model->addOperand(&type1);
155   auto bw_aux_input_to_input_weights = model->addOperand(&type1);
156   auto bw_input_to_forget_weights1 = model->addOperand(&type1);
157   auto bw_aux_input_to_cell_weights = model->addOperand(&type1);
158   auto bw_aux_input_to_output_weights = model->addOperand(&type1);
159   auto activation = model->addOperand(&type6);
160   auto cell_clip = model->addOperand(&type7);
161   auto proj_clip = model->addOperand(&type7);
162   auto merge_outputs = model->addOperand(&type8);
163   auto time_major = model->addOperand(&type8);
164   auto input_layer_norm_weights = model->addOperand(&type3);
165   auto forget_layer_norm_weights = model->addOperand(&type3);
166   auto cell_layer_norm_weights = model->addOperand(&type3);
167   auto output_layer_norm_weights = model->addOperand(&type3);
168   auto input_layer_norm_weights1 = model->addOperand(&type3);
169   auto forget_layer_norm_weights1 = model->addOperand(&type3);
170   auto cell_layer_norm_weights1 = model->addOperand(&type3);
171   auto output_layer_norm_weights1 = model->addOperand(&type3);
172   auto fw_output = model->addOperand(&type9);
173   // Phase 2, operations
174   static int32_t activation_init[] = {4};
175   model->setOperandValue(activation, activation_init, sizeof(int32_t) * 1);
176   static float cell_clip_init[] = {0.0f};
177   model->setOperandValue(cell_clip, cell_clip_init, sizeof(float) * 1);
178   static float proj_clip_init[] = {0.0f};
179   model->setOperandValue(proj_clip, proj_clip_init, sizeof(float) * 1);
180   static bool8 merge_outputs_init[] = {true};
181   model->setOperandValue(merge_outputs, merge_outputs_init, sizeof(bool8) * 1);
182   static bool8 time_major_init[] = {true};
183   model->setOperandValue(time_major, time_major_init, sizeof(bool8) * 1);
184   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});
185   // Phase 3, inputs and outputs
186   model->identifyInputsAndOutputs(
187     {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},
188     {fw_output});
189   assert(model->isValid());
190 }
191 
is_ignored_dynamic_output_shape(int i)192 inline bool is_ignored_dynamic_output_shape(int i) {
193   static std::set<int> ignore = {};
194   return ignore.find(i) != ignore.end();
195 }
196 
197