1 // clang-format off
2 // Generated file (from: unidirectional_sequence_lstm_cifg_peephole.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, {0});
9   OperandType type5(Type::TENSOR_FLOAT32, {1, 4});
10   OperandType type6(Type::INT32, {});
11   OperandType type7(Type::FLOAT32, {});
12   OperandType type8(Type::BOOL, {});
13   OperandType type9(Type::TENSOR_FLOAT32, {3, 1, 4});
14   // Phase 1, operands
15   auto input = model->addOperand(&type0);
16   auto input_to_input_weights = model->addOperand(&type1);
17   auto input_to_forget_weights = model->addOperand(&type1);
18   auto input_to_cell_weights = model->addOperand(&type1);
19   auto input_to_output_weights = model->addOperand(&type1);
20   auto recurrent_to_intput_weights = model->addOperand(&type2);
21   auto recurrent_to_forget_weights = model->addOperand(&type2);
22   auto recurrent_to_cell_weights = model->addOperand(&type2);
23   auto recurrent_to_output_weights = model->addOperand(&type2);
24   auto cell_to_input_weights = model->addOperand(&type3);
25   auto cell_to_forget_weights = model->addOperand(&type3);
26   auto cell_to_output_weights = model->addOperand(&type3);
27   auto input_gate_bias = model->addOperand(&type3);
28   auto forget_gate_bias = model->addOperand(&type3);
29   auto cell_gate_bias = model->addOperand(&type3);
30   auto output_gate_bias = model->addOperand(&type3);
31   auto projection_weights = model->addOperand(&type2);
32   auto projection_bias = model->addOperand(&type4);
33   auto output_state_in = model->addOperand(&type5);
34   auto cell_state_in = model->addOperand(&type5);
35   auto activation_param = model->addOperand(&type6);
36   auto cell_clip_param = model->addOperand(&type7);
37   auto proj_clip_param = model->addOperand(&type7);
38   auto time_major_param = model->addOperand(&type8);
39   auto input_layer_norm_weights = model->addOperand(&type3);
40   auto forget_layer_norm_weights = model->addOperand(&type3);
41   auto cell_layer_norm_weights = model->addOperand(&type3);
42   auto output_layer_norm_weights = model->addOperand(&type3);
43   auto output = model->addOperand(&type9);
44   // Phase 2, operations
45   static int32_t activation_param_init[] = {4};
46   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
47   static float cell_clip_param_init[] = {0.0f};
48   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1);
49   static float proj_clip_param_init[] = {0.0f};
50   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1);
51   static bool8 time_major_param_init[] = {true};
52   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
53   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});
54   // Phase 3, inputs and outputs
55   model->identifyInputsAndOutputs(
56     {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},
57     {output});
58   assert(model->isValid());
59 }
60 
is_ignored(int i)61 inline bool is_ignored(int i) {
62   static std::set<int> ignore = {};
63   return ignore.find(i) != ignore.end();
64 }
65 
CreateModel_dynamic_output_shape(Model * model)66 void CreateModel_dynamic_output_shape(Model *model) {
67   OperandType type0(Type::TENSOR_FLOAT32, {3, 1, 2});
68   OperandType type1(Type::TENSOR_FLOAT32, {4, 2});
69   OperandType type10(Type::TENSOR_FLOAT32, {0, 0, 0});
70   OperandType type2(Type::TENSOR_FLOAT32, {4, 4});
71   OperandType type3(Type::TENSOR_FLOAT32, {4});
72   OperandType type4(Type::TENSOR_FLOAT32, {0});
73   OperandType type5(Type::TENSOR_FLOAT32, {1, 4});
74   OperandType type6(Type::INT32, {});
75   OperandType type7(Type::FLOAT32, {});
76   OperandType type8(Type::BOOL, {});
77   // Phase 1, operands
78   auto input = model->addOperand(&type0);
79   auto input_to_input_weights = model->addOperand(&type1);
80   auto input_to_forget_weights = model->addOperand(&type1);
81   auto input_to_cell_weights = model->addOperand(&type1);
82   auto input_to_output_weights = model->addOperand(&type1);
83   auto recurrent_to_intput_weights = model->addOperand(&type2);
84   auto recurrent_to_forget_weights = model->addOperand(&type2);
85   auto recurrent_to_cell_weights = model->addOperand(&type2);
86   auto recurrent_to_output_weights = model->addOperand(&type2);
87   auto cell_to_input_weights = model->addOperand(&type3);
88   auto cell_to_forget_weights = model->addOperand(&type3);
89   auto cell_to_output_weights = model->addOperand(&type3);
90   auto input_gate_bias = model->addOperand(&type3);
91   auto forget_gate_bias = model->addOperand(&type3);
92   auto cell_gate_bias = model->addOperand(&type3);
93   auto output_gate_bias = model->addOperand(&type3);
94   auto projection_weights = model->addOperand(&type2);
95   auto projection_bias = model->addOperand(&type4);
96   auto output_state_in = model->addOperand(&type5);
97   auto cell_state_in = model->addOperand(&type5);
98   auto activation_param = model->addOperand(&type6);
99   auto cell_clip_param = model->addOperand(&type7);
100   auto proj_clip_param = model->addOperand(&type7);
101   auto time_major_param = model->addOperand(&type8);
102   auto input_layer_norm_weights = model->addOperand(&type3);
103   auto forget_layer_norm_weights = model->addOperand(&type3);
104   auto cell_layer_norm_weights = model->addOperand(&type3);
105   auto output_layer_norm_weights = model->addOperand(&type3);
106   auto output = model->addOperand(&type10);
107   // Phase 2, operations
108   static int32_t activation_param_init[] = {4};
109   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
110   static float cell_clip_param_init[] = {0.0f};
111   model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1);
112   static float proj_clip_param_init[] = {0.0f};
113   model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1);
114   static bool8 time_major_param_init[] = {true};
115   model->setOperandValue(time_major_param, time_major_param_init, sizeof(bool8) * 1);
116   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});
117   // Phase 3, inputs and outputs
118   model->identifyInputsAndOutputs(
119     {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},
120     {output});
121   assert(model->isValid());
122 }
123 
is_ignored_dynamic_output_shape(int i)124 inline bool is_ignored_dynamic_output_shape(int i) {
125   static std::set<int> ignore = {};
126   return ignore.find(i) != ignore.end();
127 }
128 
129