class_docstr: An approximation method to deal with intractably
  large size of graph tuning problem.
  
  This graph coloring algorithm mainly comes from:
  
  Lang Hames and Bernhard Scholz.
  Nearly optimal register allocation with pbqp.JMLC 2006.
  LNCS, vol.4228,pp. 346-361, 2016
class_docstr_tok: ["An","approximation","method","to","deal","with","intractably","large","size","of","graph","tuning","problem",".","This","graph","coloring","algorithm","mainly","comes","from",":","Lang","Hames","and","Bernhard","Scholz",".","Nearly","optimal","register","allocation","with","pbqp.JMLC","2006",".","LNCS",",","vol.4228",",","pp",".","346-361",",","2016"]
docstr: Reduce nodes with degree greater than 2.
docstr_tok: ["Reduce","nodes","with","degree","greater","than","2","."]
code: def _RN_reduction(self, node_idx):
      """Reduce nodes with degree greater than 2."""
      min_cost = INVALID_LAYOUT_TIME
      record_idx = -1
  
      for i, record_cost in enumerate(self._record_cost_dict[node_idx]):
          current_cost = record_cost
          for adj_node in self._adj_dict[node_idx]:
              ltf_matrix = self._layout_transform_interlayer_cost[
                  (node_idx, adj_node)
              ]
              adj_record_cost = list(self._record_cost_dict[adj_node])
              for j, ltf_cost in enumerate(ltf_matrix[i]):
                  adj_record_cost[j] += ltf_cost
              current_cost += min(adj_record_cost)
          if current_cost < min_cost:
              min_cost = current_cost
              record_idx = i
  
      if record_idx < 0:
          raise RuntimeError(
              f"Can't find a soltuion for node {node_idx} when applying RN reduction"
          )
      self._optimal_record_dict[node_idx] = record_idx
      self._is_optimal = False
  
      for adj_node in self._adj_dict[node_idx]:
          ltf_matrix = self._layout_transform_interlayer_cost[
              (node_idx, adj_node)
          ]
          for i, ltf_cost in enumerate(ltf_matrix[record_idx]):
              self._record_cost_dict[adj_node][i] += ltf_cost
  
      self._remove_node(node_idx)
      self._reorder_adj_nodes(node_idx)
      self._stack.append(node_idx)
  
file_path: tvm/python/tvm/autotvm/graph_tuner/pbqp_tuner.py
imports: from ._base import INVALID_LAYOUT_TIME
  from .base_graph_tuner import BaseGraphTuner
  from .utils import is_boundary_node, has_multiple_inputs
label_desc: Use image node_id 9 for calling the PBQPTuner obj's underlying member method code with example usage: obj._RN_reduction(node_idx) without return types