| 589 | } |
| 590 | |
| 591 | StatusOr<bool> MarkForCompilationPassImpl::Initialize() { |
| 592 | TF_RET_CHECK(!initialized_ && !edges_contracted_ && !clusters_created_); |
| 593 | initialized_ = true; |
| 594 | |
| 595 | TF_RETURN_IF_ERROR(FindCompilationCandidates()); |
| 596 | |
| 597 | if (compilation_candidates_.empty()) { |
| 598 | VLOG(2) << "No compilable candidates"; |
| 599 | return false; |
| 600 | } |
| 601 | |
| 602 | TF_ASSIGN_OR_RETURN(bool cycle_detection_graph_ok, |
| 603 | CreateCycleDetectionGraph(graph_, &cycles_graph_)); |
| 604 | if (!cycle_detection_graph_ok) { |
| 605 | // TODO(sanjoy): This should be logged via the XLA activity listener. |
| 606 | VLOG(2) << "Could not form cycle detection graph"; |
| 607 | return false; |
| 608 | } |
| 609 | |
| 610 | if (!debug_options_.ignore_deadness_checks) { |
| 611 | XLA_SCOPED_LOGGING_TIMER_LEVEL("DeadnessAnalysis", 1); |
| 612 | TF_RETURN_IF_ERROR(DeadnessAnalysis::Run(*graph_, &deadness_analysis_)); |
| 613 | } |
| 614 | |
| 615 | // Each compilation candidate belongs to a cluster. The cluster's |
| 616 | // representative names the node in the 'cycles' graph that represents the |
| 617 | // cluster. |
| 618 | TF_RETURN_IF_ERROR(BuildInitialClusterSet()); |
| 619 | return true; |
| 620 | } |
| 621 | |
| 622 | template <typename FnTy> |
| 623 | StatusOr<bool> MarkForCompilationPassImpl::ForEachEdgeInPostOrder(FnTy fn) { |