parameters: (self, save_path, name, marked_nodes=None, remove_ctr_var=True)
docstring: Draw the graph. If `dot` command is installed, the drawn graph
          will be saved as pdf file type, otherwise dot file type is used.
  
          Args:
              save_path(str): the save path of drawn graph.
              name(str): the name of drawn graph.
              marked_nodes(set(IrNode)): nodes that are needed to be marked.
              Default value is None.
              remove_ctr_var(bool): If it is set True, all control variable nodes
              in the graph will be removed. Default value is True.
docstring_summary: Draw the graph. If `dot` command is installed, the drawn graph
          will be saved as pdf file type, otherwise dot file type is used.
docstring_tokens: Draw the graph . If dot command is installed the drawn graph will be saved as pdf file type otherwise dot file type is used .
function: def draw(self, save_path, name, marked_nodes=None, remove_ctr_var=True):
          """
          Draw the graph. If `dot` command is installed, the drawn graph
          will be saved as pdf file type, otherwise dot file type is used.
  
          Args:
              save_path(str): the save path of drawn graph.
              name(str): the name of drawn graph.
              marked_nodes(set(IrNode)): nodes that are needed to be marked.
              Default value is None.
              remove_ctr_var(bool): If it is set True, all control variable nodes
              in the graph will be removed. Default value is True.
          """
  
          def _convert_to_pdf(dot_file_path):
              pdf_save_path = os.path.splitext(dot_file_path)[0] + '.pdf'
              exited_code = subprocess.call(
                  'dot -Tpdf ' + dot_file_path + ' -o ' + pdf_save_path,
                  shell=True)
              if exited_code != 0:
                  print('The dot command is needed for creating pdf files.')
                  print('The {} is saved as the dot filetype.'.format(
                      dot_file_path))
  
          remove_ctr_vars = set()
          if remove_ctr_var:
              for node in self.all_var_nodes():
                  if node.is_ctrl_var():
                      remove_ctr_vars.add(node)
              self.safe_remove_nodes(remove_ctr_vars)
          print('Total ops num = {}.'.format(len(self.all_op_nodes())))
  
          if marked_nodes is not None:
              if not isinstance(marked_nodes, set):
                  if isinstance(marked_nodes, Iterable):
                      marked_nodes = set(marked_nodes)
                  else:
                      marked_nodes = {marked_nodes}
              marked_nodes = {n.node for n in marked_nodes}
              remove_ctr_vars = {n.node for n in remove_ctr_vars}
              marked_nodes = marked_nodes - remove_ctr_vars
              if self.graph.has('__graphviz__marked_node__'):
                  self.graph.erase('__graphviz__marked_node__')
              self.graph.set('__graphviz__marked_node__', marked_nodes)
          if not os.path.exists(save_path):
              os.makedirs(save_path)
          viz_dot_path = os.path.join(save_path, name) + '.dot'
          viz_pass = core.get_pass('graph_viz_pass')
          viz_pass.set('graph_viz_path', viz_dot_path)
          viz_pass.apply(self.graph)
          _convert_to_pdf(viz_dot_path)
function_tokens: def draw ( self , save_path , name , marked_nodes = None , remove_ctr_var = True ) : def _convert_to_pdf ( dot_file_path ) : pdf_save_path = os . path . splitext ( dot_file_path ) [ 0 ] + '.pdf' exited_code = subprocess . call ( 'dot -Tpdf ' + dot_file_path + ' -o ' + pdf_save_path , shell = True ) if exited_code != 0 : print ( 'The dot command is needed for creating pdf files.' ) print ( 'The {} is saved as the dot filetype.' . format ( dot_file_path ) ) remove_ctr_vars = set ( ) if remove_ctr_var : for node in self . all_var_nodes ( ) : if node . is_ctrl_var ( ) : remove_ctr_vars . add ( node ) self . safe_remove_nodes ( remove_ctr_vars ) print ( 'Total ops num = {}.' . format ( len ( self . all_op_nodes ( ) ) ) ) if marked_nodes is not None : if not isinstance ( marked_nodes , set ) : if isinstance ( marked_nodes , Iterable ) : marked_nodes = set ( marked_nodes ) else : marked_nodes = { marked_nodes } marked_nodes = { n . node for n in marked_nodes } remove_ctr_vars = { n . node for n in remove_ctr_vars } marked_nodes = marked_nodes - remove_ctr_vars if self . graph . has ( '__graphviz__marked_node__' ) : self . graph . erase ( '__graphviz__marked_node__' ) self . graph . set ( '__graphviz__marked_node__' , marked_nodes ) if not os . path . exists ( save_path ) : os . makedirs ( save_path ) viz_dot_path = os . path . join ( save_path , name ) + '.dot' viz_pass = core . get_pass ( 'graph_viz_pass' ) viz_pass . set ( 'graph_viz_path' , viz_dot_path ) viz_pass . apply ( self . graph ) _convert_to_pdf ( viz_dot_path )