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