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