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

Method BuildAddSubgraph

tensorflow/lite/kernels/subgraph_test_util.cc:62–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void SubgraphBuilder::BuildAddSubgraph(Subgraph* subgraph) {
63 const int kInput1 = 0;
64 const int kInput2 = 1;
65 const int kOutput = 2;
66 const int kTensorCount = 3;
67 // kInput1(0) --> +---+
68 // |ADD| --> kOutput(2)
69 // kInput2(1) --> +---+
70
71 int first_new_tensor_index;
72 ASSERT_EQ(subgraph->AddTensors(kTensorCount, &first_new_tensor_index),
73 kTfLiteOk);
74 ASSERT_EQ(first_new_tensor_index, 0);
75 ASSERT_EQ(subgraph->SetInputs({kInput1, kInput2}), kTfLiteOk);
76 ASSERT_EQ(subgraph->SetOutputs({kOutput}), kTfLiteOk);
77
78 SetupTensor(subgraph, kInput1, kTfLiteInt32);
79 SetupTensor(subgraph, kInput2, kTfLiteInt32);
80 SetupTensor(subgraph, kOutput, kTfLiteInt32);
81
82 TfLiteAddParams* params =
83 reinterpret_cast<TfLiteAddParams*>(malloc(sizeof(TfLiteAddParams)));
84 params->activation = kTfLiteActNone;
85 int node_index;
86 subgraph->AddNodeWithParameters(
87 {kInput1, kInput2}, {kOutput}, {}, nullptr, 0, params,
88 ::tflite::ops::builtin::Register_ADD(), &node_index);
89}
90
91// Build a subgraph with an mul op. Helper function for testing.
92void SubgraphBuilder::BuildMulSubgraph(Subgraph* subgraph) {

Callers 3

TEST_FFunction · 0.80
SetUpMethod · 0.80
SetUpMethod · 0.80

Calls 6

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

Tested by

no test coverage detected