| 985 | } |
| 986 | |
| 987 | StatusOr<bool> MarkForCudaGraphModePassImpl::Initialize() { |
| 988 | TF_RET_CHECK(!initialized_ && !edges_contracted_ && !clusters_created_); |
| 989 | initialized_ = true; |
| 990 | |
| 991 | TF_RETURN_IF_ERROR(FindCompilationCandidates()); |
| 992 | |
| 993 | if (compilation_candidates_.empty()) { |
| 994 | VLOG(2) << "No compilable candidates"; |
| 995 | return false; |
| 996 | } |
| 997 | |
| 998 | TF_ASSIGN_OR_RETURN(bool cycle_detection_graph_ok, |
| 999 | CreateCycleDetectionGraph(graph_, &cycles_graph_)); |
| 1000 | if (!cycle_detection_graph_ok) { |
| 1001 | VLOG(2) << "Could not form cycle detection graph"; |
| 1002 | return false; |
| 1003 | } |
| 1004 | |
| 1005 | if (!debug_options_.ignore_deadness_checks) { |
| 1006 | TF_RETURN_IF_ERROR(DeadnessAnalysis::Run(*graph_, &deadness_analysis_)); |
| 1007 | } |
| 1008 | |
| 1009 | // Each compilation candidate belongs to a cluster. The cluster's |
| 1010 | // representative names the node in the 'cycles' graph that represents the |
| 1011 | // cluster. |
| 1012 | TF_RETURN_IF_ERROR(BuildInitialClusterSet()); |
| 1013 | return true; |
| 1014 | } |
| 1015 | |
| 1016 | template <typename FnTy> |
| 1017 | StatusOr<bool> MarkForCudaGraphModePassImpl::ForEachEdgeInPostOrder(FnTy fn) { |