parameters: (graph: Graph, nodes: List[Node], constant_subgraph_only: bool = False)
docstring: Run "infer" function of the specified nodes.
  
      :param graph: graph with nodes
      :param nodes: list of node ids in the topological order
      :param constant_subgraph_only: flag which specifies whether only inference of constant sub-graphs should be done
docstring_summary: Run "infer" function of the specified nodes.
docstring_tokens: Run infer function of the specified nodes .
function: def infer_nodes(graph: Graph, nodes: List[Node], constant_subgraph_only: bool = False):
      """
      Run "infer" function of the specified nodes.
  
      :param graph: graph with nodes
      :param nodes: list of node ids in the topological order
      :param constant_subgraph_only: flag which specifies whether only inference of constant sub-graphs should be done
      """
      debug_logger = log.getLogger().isEnabledFor(log.DEBUG)
      for n in nodes:
          # Data Flow Infer
          node = Node(graph, n)
          node_name = node.soft_get('name', node.id)
          try:
              if node.has('is_partial_inferred') and not node.is_partial_inferred:
                  if node.has('infer') and not node.infer is None:
                      # we consider that operation will produce value if all inputs are constants or it is
                      # 'ShapeOf' operation
                      if constant_subgraph_only:
                          in_values = [port.data.get_value() for port in node.in_ports().values()]
                          if node.soft_get('op') == 'Parameter' or any(value is None for value in in_values) or \
                                  (node.soft_get('op') == 'ShapeOf' and node.in_port(0).data.get_shape() is None):
                              # if here will be any new ShapeOf type operation, we should update condition above
                              continue
  
                      if debug_logger:
                          log.debug('-' * 20)
                          log.debug('Partial infer for {}'.format(node.soft_get('name')))
                          log.debug('Op: {}'.format(node.soft_get('op')))
                          log.debug('Inputs:')
                          log_debug_dict(node.in_nodes(), 'input')
  
                      node.infer(node)
                      out_nodes = node.out_nodes()
  
                      # propagate nchw_layout attributes to data nodes
                      if node.has('nchw_layout'):
                          for out_node in out_nodes.values():
                              out_node['nchw_layout'] = node.nchw_layout
  
                      # In debug print current node attributes, input shapes/values and output shape/values
                      if debug_logger:
                          log.debug('Outputs:')
                          log_debug_dict(node.out_nodes(), 'output')
  
                      if not constant_subgraph_only:
                          not_all_output_shapes = False
  
                          for out_port, out_node in out_nodes.items():
                              not_all_output_shapes = False
                              if not out_node.has_valid('shape'):
                                  log.error('Shape is not defined for output {} of "{}".'.format(out_port, node_name))
                                  not_all_output_shapes = True
  
                          if not_all_output_shapes:
                              raise Error('Not all output shapes were inferred or fully defined for node "{}". ' +
                                          refer_to_faq_msg(40),
                                          node_name)
                  elif node.kind != 'data':
                      raise Error(
                          'There is no registered "infer" function for node "{}" with op = "{}". ' +
                          'Please implement this function in the extensions. ' +
                          refer_to_faq_msg(37),
                          node_name,
                          node.soft_get('op')
                      )
                  node.is_partial_inferred = True
          except Exception as err:
              log.error('Cannot infer shapes or values for node "{}".'.format(node.soft_get('name')))
              log.error(str(err))
              log.error('')
              log.error('It can happen due to bug in custom shape infer function {}.'.format(node.soft_get('infer')))
              log.error('Or because the node inputs have incorrect values/shapes.')
              log.error('Or because input shapes are incorrect (embedded to the model or passed via --input_shape).')
              debug_messages = '\n'.join(
                  ['Layer "' + node_name + '": ' + node_attrs['debug_message'] for node_name, node_attrs in
                   graph.nodes(data=True) if 'debug_message' in node_attrs])
              if debug_messages != "":
                  log.error('')
                  log.error('Other possible failure reasons are listed below:')
                  log.error(debug_messages)
              if not debug_logger:
                  log.error('Run Model Optimizer with --log_level=DEBUG for more information.')
              else:
                  log.debug('Node "{}" attributes: {}'.format(node.soft_get('name'), node.graph.node[node.id]))
              raise Error('Stopped shape/value propagation at "{}" node. '.format(node.soft_get('name')) +
                          refer_to_faq_msg(38)) from err
          control_flow_infer(graph, n)
function_tokens: def infer_nodes ( graph : Graph , nodes : List [ Node ] , constant_subgraph_only : bool = False ) : debug_logger = log . getLogger ( ) . isEnabledFor ( log . DEBUG ) for n in nodes : # Data Flow Infer node = Node ( graph , n ) node_name = node . soft_get ( 'name' , node . id ) try : if node . has ( 'is_partial_inferred' ) and not node . is_partial_inferred : if node . has ( 'infer' ) and not node . infer is None : # we consider that operation will produce value if all inputs are constants or it is # 'ShapeOf' operation if constant_subgraph_only : in_values = [ port . data . get_value ( ) for port in node . in_ports ( ) . values ( ) ] if node . soft_get ( 'op' ) == 'Parameter' or any ( value is None for value in in_values ) or ( node . soft_get ( 'op' ) == 'ShapeOf' and node . in_port ( 0 ) . data . get_shape ( ) is None ) : # if here will be any new ShapeOf type operation, we should update condition above continue if debug_logger : log . debug ( '-' * 20 ) log . debug ( 'Partial infer for {}' . format ( node . soft_get ( 'name' ) ) ) log . debug ( 'Op: {}' . format ( node . soft_get ( 'op' ) ) ) log . debug ( 'Inputs:' ) log_debug_dict ( node . in_nodes ( ) , 'input' ) node . infer ( node ) out_nodes = node . out_nodes ( ) # propagate nchw_layout attributes to data nodes if node . has ( 'nchw_layout' ) : for out_node in out_nodes . values ( ) : out_node [ 'nchw_layout' ] = node . nchw_layout # In debug print current node attributes, input shapes/values and output shape/values if debug_logger : log . debug ( 'Outputs:' ) log_debug_dict ( node . out_nodes ( ) , 'output' ) if not constant_subgraph_only : not_all_output_shapes = False for out_port , out_node in out_nodes . items ( ) : not_all_output_shapes = False if not out_node . has_valid ( 'shape' ) : log . error ( 'Shape is not defined for output {} of "{}".' . format ( out_port , node_name ) ) not_all_output_shapes = True if not_all_output_shapes : raise Error ( 'Not all output shapes were inferred or fully defined for node "{}". ' + refer_to_faq_msg ( 40 ) , node_name ) elif node . kind != 'data' : raise Error ( 'There is no registered "infer" function for node "{}" with op = "{}". ' + 'Please implement this function in the extensions. ' + refer_to_faq_msg ( 37 ) , node_name , node . soft_get ( 'op' ) ) node . is_partial_inferred = True except Exception as err : log . error ( 'Cannot infer shapes or values for node "{}".' . format ( node . soft_get ( 'name' ) ) ) log . error ( str ( err ) ) log . error ( '' ) log . error ( 'It can happen due to bug in custom shape infer function {}.' . format ( node . soft_get ( 'infer' ) ) ) log . error ( 'Or because the node inputs have incorrect values/shapes.' ) log . error ( 'Or because input shapes are incorrect (embedded to the model or passed via --input_shape).' ) debug_messages = '\n' . join ( [ 'Layer "' + node_name + '": ' + node_attrs [ 'debug_message' ] for node_name , node_attrs in graph . nodes ( data = True ) if 'debug_message' in node_attrs ] ) if debug_messages != "" : log . error ( '' ) log . error ( 'Other possible failure reasons are listed below:' ) log . error ( debug_messages ) if not debug_logger : log . error ( 'Run Model Optimizer with --log_level=DEBUG for more information.' ) else : log . debug ( 'Node "{}" attributes: {}' . format ( node . soft_get ( 'name' ) , node . graph . node [ node . id ] ) ) raise Error ( 'Stopped shape/value propagation at "{}" node. ' . format ( node . soft_get ( 'name' ) ) + refer_to_faq_msg ( 38 ) ) from err control_flow_infer ( graph , n )