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

Method ShowInternal

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

Source from the content-addressed store, hash-verified

70}
71
72const ShowNode* TFGraph::ShowInternal(const Options& opts, Timeline* timeline) {
73 root_->ResetTotalStats();
74 root_->show_children.clear();
75
76 if (opts.output_type == kOutput[3]) {
77 fprintf(stderr, "Only 'code' view supports pprof output now.\n");
78 return root_;
79 }
80 if (timeline && timeline->step() < 0) {
81 // TODO(xpan): Maybe pick a default step for users.
82 fprintf(stderr,
83 "Must specify -step option to generate timeline in graph view.\n");
84 return root_;
85 }
86 // 1. Account and aggregate the stats based on the graph structure.
87 // Returns a graph consists of accounted nodes.
88 std::set<string> visits;
89 std::vector<GraphNode*> roots = Account(root_->children, opts, &visits);
90 for (GraphNode* n : roots) {
91 root_->AggregateTotalStats(n);
92 }
93
94 // 2. Trim the nodes before start_name_regexes.
95 if (opts.start_name_regexes.size() != 1 ||
96 opts.start_name_regexes[0] != ".*") {
97 visits.clear();
98 roots = SearchRoot(roots, opts.start_name_regexes, &visits);
99 }
100
101 // 3. Trim the nodes not matching show/hide/trim_name_regexes.
102 // If account_displayed_op_only=true, redo the accounting.
103 visits.clear();
104 root_->show_children.assign(roots.begin(), roots.end());
105 GraphNode* root = PrintGraph({root_}, opts, 1, 0, &visits)[0];
106
107 // 4. Prepare output based on the final graphs.
108 root->formatted_str = FormatLegend(opts) + root->formatted_str;
109 Format(root->show_children, &root->formatted_str, root->mutable_proto());
110
111 if (timeline) {
112 timeline->GenerateGraphTimeline(root->show_children);
113 }
114 return root;
115}
116
117std::vector<GraphNode*> TFGraph::SearchRoot(
118 const std::vector<GraphNode*>& roots, const std::vector<string>& regexes,

Callers

nothing calls this directly

Calls 11

ResetTotalStatsMethod · 0.80
AggregateTotalStatsMethod · 0.80
GenerateGraphTimelineMethod · 0.80
FormatEnum · 0.50
clearMethod · 0.45
stepMethod · 0.45
sizeMethod · 0.45
assignMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
mutable_protoMethod · 0.45

Tested by

no test coverage detected