parameters: (self)
return_statement: return cnt
docstring: This method does the following:
          If a node has more than one successor, there is *branch*.
              [ e.g. A ->- B ->- D                                       ] 
              [       \->- C ->- / , B and C can be run at the same time ]
              case 1: if B or C is null (or D is directly dependent on A),
                      it's equivalent to A->C->D or A->B->D, fall back to self.merge_linear
              case 2: if both B and C are some op,
                      merged_cost = max(cost(B), cost(C))
docstring_summary: This method does the following:
          If a node has more than one successor, there is *branch*.
              [ e.g. A ->- B ->- D                                       ] 
              [       \->- C ->- / , B and C can be run at the same time ]
              case 1: if B or C is null (or D is directly dependent on A),
                      it's equivalent to A->C->D or A->B->D, fall back to self.merge_linear
              case 2: if both B and C are some op,
                      merged_cost = max(cost(B), cost(C))
docstring_tokens: This method does the following : If a node has more than one successor there is * branch * . [ e . g . A - > - B - > - D ] [ \ - > - C - > - / B and C can be run at the same time ] case 1 : if B or C is null ( or D is directly dependent on A ) it s equivalent to A - > C - > D or A - > B - > D fall back to self . merge_linear case 2 : if both B and C are some op merged_cost = max ( cost ( B ) cost ( C ))
function: def merge_branch(self):
          '''
          This method does the following:
          If a node has more than one successor, there is *branch*.
              [ e.g. A ->- B ->- D                                       ] 
              [       \->- C ->- / , B and C can be run at the same time ]
              case 1: if B or C is null (or D is directly dependent on A),
                      it's equivalent to A->C->D or A->B->D, fall back to self.merge_linear
              case 2: if both B and C are some op,
                      merged_cost = max(cost(B), cost(C))
          '''
          cnt = 0
          for sub_idx in range(self.total_rank):
              cnt += self._merge_branch(
                  self.nodes[sub_idx], self.runtime_graph[sub_idx], is_bwd=False)
              cnt += self._merge_branch(
                  self.nodes[sub_idx], self.runtime_graph[sub_idx], is_bwd=True)
          return cnt
function_tokens: def merge_branch ( self ) : cnt = 0 for sub_idx in range ( self . total_rank ) : cnt += self . _merge_branch ( self . nodes [ sub_idx ] , self . runtime_graph [ sub_idx ] , is_bwd = False ) cnt += self . _merge_branch ( self . nodes [ sub_idx ] , self . runtime_graph [ sub_idx ] , is_bwd = True ) return cnt