Build a subgraph with an mul op. Helper function for testing.
| 90 | |
| 91 | // Build a subgraph with an mul op. Helper function for testing. |
| 92 | void SubgraphBuilder::BuildMulSubgraph(Subgraph* subgraph) { |
| 93 | const int kInput1 = 0; |
| 94 | const int kInput2 = 1; |
| 95 | const int kOutput = 2; |
| 96 | const int kTensorCount = 3; |
| 97 | // kInput1(0) --> +---+ |
| 98 | // |MUL| --> kOutput(2) |
| 99 | // kInput2(1) --> +---+ |
| 100 | |
| 101 | int first_new_tensor_index; |
| 102 | ASSERT_EQ(subgraph->AddTensors(kTensorCount, &first_new_tensor_index), |
| 103 | kTfLiteOk); |
| 104 | ASSERT_EQ(first_new_tensor_index, 0); |
| 105 | ASSERT_EQ(subgraph->SetInputs({kInput1, kInput2}), kTfLiteOk); |
| 106 | ASSERT_EQ(subgraph->SetOutputs({kOutput}), kTfLiteOk); |
| 107 | |
| 108 | SetupTensor(subgraph, kInput1, kTfLiteInt32); |
| 109 | SetupTensor(subgraph, kInput2, kTfLiteInt32); |
| 110 | SetupTensor(subgraph, kOutput, kTfLiteInt32); |
| 111 | |
| 112 | TfLiteMulParams* params = |
| 113 | reinterpret_cast<TfLiteMulParams*>(malloc(sizeof(TfLiteMulParams))); |
| 114 | params->activation = kTfLiteActNone; |
| 115 | int node_index; |
| 116 | subgraph->AddNodeWithParameters( |
| 117 | {kInput1, kInput2}, {kOutput}, {}, nullptr, 0, params, |
| 118 | ::tflite::ops::builtin::Register_MUL(), &node_index); |
| 119 | } |
| 120 | |
| 121 | // Build a subgraph with a pad op. Helper function for testing. |
| 122 | void SubgraphBuilder::BuildPadSubgraph(Subgraph* subgraph) { |
no test coverage detected