• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // clang-format off
2 // Generated file (from: rnn_state_relaxed.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   // Phase 4: set relaxed execution
28   model->relaxComputationFloat32toFloat16(true);
29   assert(model->isValid());
30 }
31 
is_ignored(int i)32 inline bool is_ignored(int i) {
33   static std::set<int> ignore = {0};
34   return ignore.find(i) != ignore.end();
35 }
36 
CreateModel_dynamic_output_shape(Model * model)37 void CreateModel_dynamic_output_shape(Model *model) {
38   OperandType type0(Type::TENSOR_FLOAT32, {2, 8});
39   OperandType type1(Type::TENSOR_FLOAT32, {16, 8});
40   OperandType type2(Type::TENSOR_FLOAT32, {16, 16});
41   OperandType type3(Type::TENSOR_FLOAT32, {16});
42   OperandType type4(Type::TENSOR_FLOAT32, {2, 16});
43   OperandType type5(Type::INT32, {});
44   OperandType type6(Type::TENSOR_FLOAT32, {0, 0});
45   // Phase 1, operands
46   auto input = model->addOperand(&type0);
47   auto weights = model->addOperand(&type1);
48   auto recurrent_weights = model->addOperand(&type2);
49   auto bias = model->addOperand(&type3);
50   auto hidden_state_in = model->addOperand(&type4);
51   auto activation_param = model->addOperand(&type5);
52   auto hidden_state_out = model->addOperand(&type6);
53   auto output = model->addOperand(&type6);
54   // Phase 2, operations
55   static int32_t activation_param_init[] = {1};
56   model->setOperandValue(activation_param, activation_param_init, sizeof(int32_t) * 1);
57   model->addOperation(ANEURALNETWORKS_RNN, {input, weights, recurrent_weights, bias, hidden_state_in, activation_param}, {hidden_state_out, output});
58   // Phase 3, inputs and outputs
59   model->identifyInputsAndOutputs(
60     {input, weights, recurrent_weights, bias, hidden_state_in},
61     {hidden_state_out, output});
62   // Phase 4: set relaxed execution
63   model->relaxComputationFloat32toFloat16(true);
64   assert(model->isValid());
65 }
66 
is_ignored_dynamic_output_shape(int i)67 inline bool is_ignored_dynamic_output_shape(int i) {
68   static std::set<int> ignore = {0};
69   return ignore.find(i) != ignore.end();
70 }
71 
72