MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / BuildPadSubgraph

Method BuildPadSubgraph

tensorflow/lite/kernels/subgraph_test_util.cc:122–148  ·  view source on GitHub ↗

Build a subgraph with a pad op. Helper function for testing.

Source from the content-addressed store, hash-verified

120
121// Build a subgraph with a pad op. Helper function for testing.
122void 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
150void SubgraphBuilder::BuildIfSubgraph(Subgraph* subgraph) {
151 const int kCondInput = 0;

Callers 2

TEST_FFunction · 0.80
SetUpMethod · 0.80

Calls 6

SetupTensorFunction · 0.85
Register_PADFunction · 0.85
AddTensorsMethod · 0.45
SetInputsMethod · 0.45
SetOutputsMethod · 0.45
AddNodeWithParametersMethod · 0.45

Tested by

no test coverage detected