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

Method BuildMulSubgraph

tensorflow/lite/kernels/subgraph_test_util.cc:92–119  ·  view source on GitHub ↗

Build a subgraph with an mul op. Helper function for testing.

Source from the content-addressed store, hash-verified

90
91// Build a subgraph with an mul op. Helper function for testing.
92void 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.
122void SubgraphBuilder::BuildPadSubgraph(Subgraph* subgraph) {

Callers 2

TEST_FFunction · 0.80
SetUpMethod · 0.80

Calls 6

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

Tested by

no test coverage detected