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

Function CreateFaninFanoutNodeGraph

tensorflow/core/graph/benchmark_testlib.h:138–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138GraphDef CreateFaninFanoutNodeGraph(int num_regular_fanins,
139 int num_regular_fanouts,
140 int num_controlling_fanins,
141 int num_controlled_fanouts,
142 bool fanout_unique_index) {
143 GraphDef graph;
144
145 auto create_node = [](const string& name) {
146 NodeDef node;
147 node.set_name(name);
148 return node;
149 };
150
151 NodeDef node = create_node(/*name=*/"node");
152
153 for (int i = 0; i < num_regular_fanins; ++i) {
154 const string input_node_name = absl::StrFormat("in%05d", i);
155 NodeDef input_node = create_node(/*name=*/input_node_name);
156 *graph.add_node() = std::move(input_node);
157 node.add_input(input_node_name);
158 }
159
160 for (int i = 0; i < num_controlling_fanins; ++i) {
161 const string input_node_name = absl::StrFormat("control_in%05d", i);
162 NodeDef input_node = create_node(/*name=*/input_node_name);
163 *graph.add_node() = std::move(input_node);
164 node.add_input(absl::StrCat("^", input_node_name));
165 }
166
167 for (int i = 0; i < num_regular_fanouts; ++i) {
168 NodeDef output_node = create_node(/*name=*/absl::StrFormat("out%05d", i));
169 const string input_node_index =
170 fanout_unique_index ? absl::StrCat(node.name(), ":", i) : node.name();
171 output_node.add_input(input_node_index);
172 *graph.add_node() = std::move(output_node);
173 }
174
175 const string controlled_fanout_input = absl::StrCat("^", node.name());
176 for (int i = 0; i < num_controlled_fanouts; ++i) {
177 NodeDef output_node =
178 create_node(/*name=*/absl::StrFormat("control_out%05d", i));
179 output_node.add_input(controlled_fanout_input);
180 *graph.add_node() = std::move(output_node);
181 }
182
183 *graph.add_node() = std::move(node);
184
185 return graph;
186}
187
188} // namespace test
189} // namespace tensorflow

Calls 4

nameMethod · 0.65
StrCatFunction · 0.50
set_nameMethod · 0.45
add_inputMethod · 0.45

Tested by

no test coverage detected