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

Method PrintGraph

tensorflow/core/profiler/internal/tfprof_graph.cc:158–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158std::vector<GraphNode*> TFGraph::PrintGraph(const std::vector<GraphNode*> roots,
159 const Options& opts, int depth,
160 int last_ident,
161 std::set<string>* visits) {
162 std::vector<GraphNode*> show_nodes;
163
164 for (GraphNode* node : roots) {
165 if (visits->find(node->name()) != visits->end()) continue;
166 visits->insert(node->name());
167
168 bool show = ShouldShow(node, opts, depth);
169 int indent = last_ident;
170 if (show) indent += 2;
171
172 std::vector<GraphNode*> show_cnodes;
173 if (!ShouldTrim(node, opts.trim_name_regexes) && depth <= opts.max_depth) {
174 show_cnodes =
175 PrintGraph(node->show_children, opts, depth + 1, indent, visits);
176 }
177 if (show) {
178 node->show_children.clear();
179 if (opts.account_displayed_op_only) {
180 node->ResetTotalStats();
181 node->AddSelfToTotalStats();
182 }
183
184 show_cnodes = SortNodes(show_cnodes, opts);
185 for (GraphNode* sc : show_cnodes) {
186 node->show_children.push_back(sc);
187 if (opts.account_displayed_op_only) {
188 node->AggregateTotalStats(sc);
189 }
190 }
191 node->formatted_str =
192 strings::Printf("%s%s\n", string(last_ident, ' ').c_str(),
193 FormatNode(node, opts).c_str());
194
195 if (opts.select.find(kShown[4]) != opts.select.end()) {
196 std::unique_ptr<TFProfTensor> tfprof_tensor;
197 if (LookUpCheckPoint(node->name(), &tfprof_tensor)) {
198 string value_str;
199 tfprof_tensor->Display(&value_str,
200 node->mutable_proto()->mutable_tensor_value());
201 node->formatted_str += value_str;
202 }
203 }
204 show_nodes.push_back(node);
205 } else {
206 show_nodes.insert(show_nodes.end(), show_cnodes.begin(),
207 show_cnodes.end());
208 }
209 }
210 return show_nodes;
211}
212
213std::vector<GraphNode*> TFGraph::Account(const std::vector<GraphNode*>& roots,
214 const Options& opts,

Callers

nothing calls this directly

Calls 14

PrintfFunction · 0.85
ResetTotalStatsMethod · 0.80
AddSelfToTotalStatsMethod · 0.80
AggregateTotalStatsMethod · 0.80
c_strMethod · 0.80
DisplayMethod · 0.80
nameMethod · 0.65
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected