Yang Ni | f6d3074 | 2017-10-12 12:03:36 -0700 | [diff] [blame] | 1 | // Generated file (from: lstm_state.mod.py). Do not edit |
| 2 | void CreateModel(Model *model) { |
Michael Butler | 540bafe | 2018-03-27 11:01:39 -0700 | [diff] [blame^] | 3 | OperandType type8(Type::FLOAT32, {}); |
| 4 | OperandType type7(Type::INT32, {}); |
Yang Ni | f6d3074 | 2017-10-12 12:03:36 -0700 | [diff] [blame] | 5 | OperandType type5(Type::TENSOR_FLOAT32, {0,0}); |
| 6 | OperandType type3(Type::TENSOR_FLOAT32, {0}); |
| 7 | OperandType type9(Type::TENSOR_FLOAT32, {1, 16}); |
| 8 | OperandType type0(Type::TENSOR_FLOAT32, {1, 2}); |
| 9 | OperandType type6(Type::TENSOR_FLOAT32, {1, 4}); |
Yang Ni | f6d3074 | 2017-10-12 12:03:36 -0700 | [diff] [blame] | 10 | OperandType type1(Type::TENSOR_FLOAT32, {4, 2}); |
| 11 | OperandType type2(Type::TENSOR_FLOAT32, {4, 4}); |
| 12 | OperandType type4(Type::TENSOR_FLOAT32, {4}); |
Yang Ni | f6d3074 | 2017-10-12 12:03:36 -0700 | [diff] [blame] | 13 | // Phase 1, operands |
| 14 | auto input = model->addOperand(&type0); |
| 15 | auto input_to_input_weights = model->addOperand(&type1); |
| 16 | auto input_to_forget_weights = model->addOperand(&type1); |
| 17 | auto input_to_cell_weights = model->addOperand(&type1); |
| 18 | auto input_to_output_weights = model->addOperand(&type1); |
| 19 | auto recurrent_to_intput_weights = model->addOperand(&type2); |
| 20 | auto recurrent_to_forget_weights = model->addOperand(&type2); |
| 21 | auto recurrent_to_cell_weights = model->addOperand(&type2); |
| 22 | auto recurrent_to_output_weights = model->addOperand(&type2); |
| 23 | auto cell_to_input_weights = model->addOperand(&type3); |
| 24 | auto cell_to_forget_weights = model->addOperand(&type3); |
| 25 | auto cell_to_output_weights = model->addOperand(&type3); |
| 26 | auto input_gate_bias = model->addOperand(&type4); |
| 27 | auto forget_gate_bias = model->addOperand(&type4); |
| 28 | auto cell_gate_bias = model->addOperand(&type4); |
| 29 | auto output_gate_bias = model->addOperand(&type4); |
| 30 | auto projection_weights = model->addOperand(&type5); |
| 31 | auto projection_bias = model->addOperand(&type3); |
| 32 | auto output_state_in = model->addOperand(&type6); |
| 33 | auto cell_state_in = model->addOperand(&type6); |
| 34 | auto activation_param = model->addOperand(&type7); |
| 35 | auto cell_clip_param = model->addOperand(&type8); |
| 36 | auto proj_clip_param = model->addOperand(&type8); |
| 37 | auto scratch_buffer = model->addOperand(&type9); |
| 38 | auto output_state_out = model->addOperand(&type6); |
| 39 | auto cell_state_out = model->addOperand(&type6); |
| 40 | auto output = model->addOperand(&type6); |
| 41 | // Phase 2, operations |
Michael Butler | 540bafe | 2018-03-27 11:01:39 -0700 | [diff] [blame^] | 42 | static int32_t activation_param_init[] = {4}; |
| 43 | model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1); |
| 44 | static float cell_clip_param_init[] = {0.0f}; |
| 45 | model->setOperandValue(cell_clip_param, cell_clip_param_init, sizeof(float) * 1); |
| 46 | static float proj_clip_param_init[] = {0.0f}; |
| 47 | model->setOperandValue(proj_clip_param, proj_clip_param_init, sizeof(float) * 1); |
Yang Ni | f6d3074 | 2017-10-12 12:03:36 -0700 | [diff] [blame] | 48 | 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}); |
| 49 | // Phase 3, inputs and outputs |
| 50 | model->identifyInputsAndOutputs( |
Michael Butler | 540bafe | 2018-03-27 11:01:39 -0700 | [diff] [blame^] | 51 | {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}, |
Yang Ni | f6d3074 | 2017-10-12 12:03:36 -0700 | [diff] [blame] | 52 | {scratch_buffer, output_state_out, cell_state_out, output}); |
| 53 | assert(model->isValid()); |
| 54 | } |
| 55 | |
| 56 | bool is_ignored(int i) { |
| 57 | static std::set<int> ignore = {0}; |
| 58 | return ignore.find(i) != ignore.end(); |
| 59 | } |