Build a subgraph with a pad op. Helper function for testing.
| 120 | |
| 121 | // Build a subgraph with a pad op. Helper function for testing. |
| 122 | void SubgraphBuilder::BuildPadSubgraph(Subgraph* subgraph) { |
| 123 | const int kInput1 = 0; |
| 124 | const int kInput2 = 1; |
| 125 | const int kOutput = 2; |
| 126 | const int kTensorCount = 3; |
| 127 | // kInput1(0) --> +---+ |
| 128 | // |PAD| --> kOutput(2) |
| 129 | // kInput2(1) --> +---+ |
| 130 | |
| 131 | int first_new_tensor_index; |
| 132 | ASSERT_EQ(subgraph->AddTensors(kTensorCount, &first_new_tensor_index), |
| 133 | kTfLiteOk); |
| 134 | ASSERT_EQ(first_new_tensor_index, 0); |
| 135 | ASSERT_EQ(subgraph->SetInputs({kInput1, kInput2}), kTfLiteOk); |
| 136 | ASSERT_EQ(subgraph->SetOutputs({kOutput}), kTfLiteOk); |
| 137 | |
| 138 | SetupTensor(subgraph, kInput1, kTfLiteInt32); |
| 139 | SetupTensor(subgraph, kInput2, kTfLiteInt32); |
| 140 | SetupTensor(subgraph, kOutput, kTfLiteInt32); |
| 141 | |
| 142 | TfLitePadParams* params = |
| 143 | reinterpret_cast<TfLitePadParams*>(malloc(sizeof(TfLitePadParams))); |
| 144 | int node_index; |
| 145 | subgraph->AddNodeWithParameters( |
| 146 | {kInput1, kInput2}, {kOutput}, {}, nullptr, 0, params, |
| 147 | ::tflite::ops::builtin::Register_PAD(), &node_index); |
| 148 | } |
| 149 | |
| 150 | void SubgraphBuilder::BuildIfSubgraph(Subgraph* subgraph) { |
| 151 | const int kCondInput = 0; |
no test coverage detected