1 // clang-format off
2 // Generated file (from: rnn_state.mod.py). Do not edit
CreateModel(Model * model)3 void CreateModel(Model *model) {
4 OperandType type0(Type::TENSOR_FLOAT32, {2, 8});
5 OperandType type1(Type::TENSOR_FLOAT32, {16, 8});
6 OperandType type2(Type::TENSOR_FLOAT32, {16, 16});
7 OperandType type3(Type::TENSOR_FLOAT32, {16});
8 OperandType type4(Type::TENSOR_FLOAT32, {2, 16});
9 OperandType type5(Type::INT32, {});
10 // Phase 1, operands
11 auto input = model->addOperand(&type0);
12 auto weights = model->addOperand(&type1);
13 auto recurrent_weights = model->addOperand(&type2);
14 auto bias = model->addOperand(&type3);
15 auto hidden_state_in = model->addOperand(&type4);
16 auto activation_param = model->addOperand(&type5);
17 auto hidden_state_out = model->addOperand(&type4);
18 auto output = model->addOperand(&type4);
19 // Phase 2, operations
20 static int32_t activation_param_init[] = {1};
21 model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
22 model->addOperation(ANEURALNETWORKS_RNN, {input, weights, recurrent_weights, bias, hidden_state_in, activation_param}, {hidden_state_out, output});
23 // Phase 3, inputs and outputs
24 model->identifyInputsAndOutputs(
25 {input, weights, recurrent_weights, bias, hidden_state_in},
26 {hidden_state_out, output});
27 assert(model->isValid());
28 }
29
is_ignored(int i)30 inline bool is_ignored(int i) {
31 static std::set<int> ignore = {0};
32 return ignore.find(i) != ignore.end();
33 }
34
CreateModel_dynamic_output_shape(Model * model)35 void CreateModel_dynamic_output_shape(Model *model) {
36 OperandType type0(Type::TENSOR_FLOAT32, {2, 8});
37 OperandType type1(Type::TENSOR_FLOAT32, {16, 8});
38 OperandType type2(Type::TENSOR_FLOAT32, {16, 16});
39 OperandType type3(Type::TENSOR_FLOAT32, {16});
40 OperandType type4(Type::TENSOR_FLOAT32, {2, 16});
41 OperandType type5(Type::INT32, {});
42 OperandType type6(Type::TENSOR_FLOAT32, {0, 0});
43 // Phase 1, operands
44 auto input = model->addOperand(&type0);
45 auto weights = model->addOperand(&type1);
46 auto recurrent_weights = model->addOperand(&type2);
47 auto bias = model->addOperand(&type3);
48 auto hidden_state_in = model->addOperand(&type4);
49 auto activation_param = model->addOperand(&type5);
50 auto hidden_state_out = model->addOperand(&type6);
51 auto output = model->addOperand(&type6);
52 // Phase 2, operations
53 static int32_t activation_param_init[] = {1};
54 model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
55 model->addOperation(ANEURALNETWORKS_RNN, {input, weights, recurrent_weights, bias, hidden_state_in, activation_param}, {hidden_state_out, output});
56 // Phase 3, inputs and outputs
57 model->identifyInputsAndOutputs(
58 {input, weights, recurrent_weights, bias, hidden_state_in},
59 {hidden_state_out, output});
60 assert(model->isValid());
61 }
62
is_ignored_dynamic_output_shape(int i)63 inline bool is_ignored_dynamic_output_shape(int i) {
64 static std::set<int> ignore = {0};
65 return ignore.find(i) != ignore.end();
66 }
67
68