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

Method Build

tensorflow/compiler/xla/service/call_graph.cc:279–318  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

277
278/* static */
279std::unique_ptr<CallGraph> CallGraph::Build(const HloModule* module) {
280 // Constructor for CallGraph is private so absl::make_unique can't be used.
281 auto call_graph = absl::WrapUnique<CallGraph>(new CallGraph(module));
282
283 VLOG(3) << "Building call graph for:";
284 XLA_VLOG_LINES(3, module->ToString());
285
286 // Construct nodes of the call graph and populate the callsites.
287 for (HloComputation* computation : module->computations()) {
288 auto it_added = call_graph->node_indices_.insert(
289 {computation, call_graph->nodes_.size()});
290 // All computations should be unique, so the computation should not already
291 // exist in the map.
292 CHECK(it_added.second);
293 call_graph->nodes_.emplace_back(computation);
294
295 // Add all callsites in this computation.
296 for (HloInstruction* instruction : computation->instructions()) {
297 call_graph->nodes_.back().AddCallSiteForInstruction(instruction);
298 }
299 }
300
301 // Add caller callsites to each node.
302 for (const HloComputation* computation : module->computations()) {
303 for (const CallSite& callsite :
304 call_graph->GetNode(computation).callsites()) {
305 for (auto* callee : callsite.called_computations()) {
306 // Add caller callsites.
307 call_graph->GetNode(callee).AddCallerCallSite(callsite);
308 }
309 }
310 }
311
312 call_graph->SetCallContexts();
313 call_graph->SetNodeDepths();
314
315 XLA_VLOG_LINES(2, call_graph->ToString());
316
317 return call_graph;
318}
319
320Status CallGraph::VisitNodesInternal(
321 const VisitorFunction& visitor_func, const CallGraphNode& node,

Callers 15

TEST_FFunction · 0.45
TEST_FFunction · 0.45
MakeScalarComputationMethod · 0.45

Calls 12

computationsMethod · 0.80
instructionsMethod · 0.80
AddCallerCallSiteMethod · 0.80
SetCallContextsMethod · 0.80
SetNodeDepthsMethod · 0.80
ToStringMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
backMethod · 0.45
GetNodeMethod · 0.45

Tested by 15

TEST_FFunction · 0.36
TEST_FFunction · 0.36
MakeScalarComputationMethod · 0.36