original_docstring:  Infers the connectors of a node and updates `inferred` accordingly. 
docstring: Infers the connectors of a node and updates `inferred` accordingly.
docstring_tokens: Infers the connectors of a node and updates ` inferred ` accordingly .
code: def infer_node_connectors(sdfg: SDFG, state: SDFGState, node: nodes.Node, inferred: TypeInferenceDict):
      """ Infers the connectors of a node and updates `inferred` accordingly. """
  
      # Try to infer input connector type from node type or previous edges
      for e in state.in_edges(node):
          cname = e.dst_conn
          if cname is None:
              continue
  
          scalar = (e.data.subset and e.data.subset.num_elements() == 1)
          if e.data.data is not None:
              allocated_as_scalar = (sdfg.arrays[e.data.data].storage is not dtypes.StorageType.GPU_Global)
          else:
              allocated_as_scalar = True
  
          if inferred[(node, cname, True)].type is None:
              # If nested SDFG, try to use internal array type
              if isinstance(node, nodes.NestedSDFG):
                  scalar = (isinstance(node.sdfg.arrays[cname], data.Scalar) and allocated_as_scalar)
                  dtype = node.sdfg.arrays[cname].dtype
                  ctype = (dtype if scalar else dtypes.pointer(dtype))
              elif e.data.data is not None:  # Obtain type from memlet
                  scalar |= isinstance(sdfg.arrays[e.data.data], data.Scalar)
                  if isinstance(node, nodes.LibraryNode):
                      scalar &= allocated_as_scalar
                  dtype = sdfg.arrays[e.data.data].dtype
                  ctype = (dtype if scalar else dtypes.pointer(dtype))
              else:  # Code->Code
                  src_edge = state.memlet_path(e)[0]
                  sconn = src_edge.src.out_connectors[src_edge.src_conn]
                  if sconn.type is None:
                      raise TypeError('Ambiguous or uninferable type in'
                                      ' connector "%s" of node "%s"' % (sconn, src_edge.src))
                  ctype = sconn
              inferred[(node, cname, True)] = ctype
  
      # Try to infer outputs from output edges
      for e in state.out_edges(node):
          cname = e.src_conn
          if cname is None:
              continue
  
          scalar = (e.data.subset and e.data.subset.num_elements() == 1
                    and (not e.data.dynamic or (e.data.dynamic and e.data.wcr is not None)))
          if e.data.data is not None:
              allocated_as_scalar = (sdfg.arrays[e.data.data].storage is not dtypes.StorageType.GPU_Global)
          else:
              allocated_as_scalar = True
  
          if inferred[(node, cname, False)].type is None:
              # If nested SDFG, try to use internal array type
              if isinstance(node, nodes.NestedSDFG):
                  scalar = (isinstance(node.sdfg.arrays[cname], data.Scalar) and allocated_as_scalar)
                  dtype = node.sdfg.arrays[cname].dtype
                  ctype = (dtype if scalar else dtypes.pointer(dtype))
              elif e.data.data is not None:  # Obtain type from memlet
                  scalar |= isinstance(sdfg.arrays[e.data.data], data.Scalar)
                  if isinstance(node, nodes.LibraryNode):
                      scalar &= allocated_as_scalar
                  dtype = sdfg.arrays[e.data.data].dtype
                  ctype = (dtype if scalar else dtypes.pointer(dtype))
              else:
                  continue
              inferred[(node, cname, False)] = ctype
  
      # Let the node infer other output types on its own
      if isinstance(node, nodes.Tasklet):
          infer_tasklet_connectors(sdfg, state, node, inferred)
      elif isinstance(node, nodes.NestedSDFG):
          infer_connector_types(node.sdfg, inferred=inferred)
  
      # If there are any remaining uninferable connectors, fail
      for e in state.out_edges(node):
          cname = e.src_conn
          if cname and inferred[(node, cname, False)].type is None:
              raise TypeError('Ambiguous or uninferable type in' ' connector "%s" of node "%s"' % (cname, node))
code_tokens: def infer_node_connectors ( sdfg : SDFG , state : SDFGState , node : nodes . Node , inferred : TypeInferenceDict ) : for e in state . in_edges ( node ) : cname = e . dst_conn if cname is None : continue scalar = ( e . data . subset and e . data . subset . num_elements ( ) == 1 ) if e . data . data is not None : allocated_as_scalar = ( sdfg . arrays [ e . data . data ] . storage is not dtypes . StorageType . GPU_Global ) else : allocated_as_scalar = True if inferred [ ( node , cname , True ) ] . type is None : if isinstance ( node , nodes . NestedSDFG ) : scalar = ( isinstance ( node . sdfg . arrays [ cname ] , data . Scalar ) and allocated_as_scalar ) dtype = node . sdfg . arrays [ cname ] . dtype ctype = ( dtype if scalar else dtypes . pointer ( dtype ) ) elif e . data . data is not None : scalar |= isinstance ( sdfg . arrays [ e . data . data ] , data . Scalar ) if isinstance ( node , nodes . LibraryNode ) : scalar &= allocated_as_scalar dtype = sdfg . arrays [ e . data . data ] . dtype ctype = ( dtype if scalar else dtypes . pointer ( dtype ) ) else : src_edge = state . memlet_path ( e ) [ 0 ] sconn = src_edge . src . out_connectors [ src_edge . src_conn ] if sconn . type is None : raise TypeError ( 'Ambiguous or uninferable type in' ' connector "%s" of node "%s"' % ( sconn , src_edge . src ) ) ctype = sconn inferred [ ( node , cname , True ) ] = ctype for e in state . out_edges ( node ) : cname = e . src_conn if cname is None : continue scalar = ( e . data . subset and e . data . subset . num_elements ( ) == 1 and ( not e . data . dynamic or ( e . data . dynamic and e . data . wcr is not None ) ) ) if e . data . data is not None : allocated_as_scalar = ( sdfg . arrays [ e . data . data ] . storage is not dtypes . StorageType . GPU_Global ) else : allocated_as_scalar = True if inferred [ ( node , cname , False ) ] . type is None : if isinstance ( node , nodes . NestedSDFG ) : scalar = ( isinstance ( node . sdfg . arrays [ cname ] , data . Scalar ) and allocated_as_scalar ) dtype = node . sdfg . arrays [ cname ] . dtype ctype = ( dtype if scalar else dtypes . pointer ( dtype ) ) elif e . data . data is not None : scalar |= isinstance ( sdfg . arrays [ e . data . data ] , data . Scalar ) if isinstance ( node , nodes . LibraryNode ) : scalar &= allocated_as_scalar dtype = sdfg . arrays [ e . data . data ] . dtype ctype = ( dtype if scalar else dtypes . pointer ( dtype ) ) else : continue inferred [ ( node , cname , False ) ] = ctype if isinstance ( node , nodes . Tasklet ) : infer_tasklet_connectors ( sdfg , state , node , inferred ) elif isinstance ( node , nodes . NestedSDFG ) : infer_connector_types ( node . sdfg , inferred = inferred ) for e in state . out_edges ( node ) : cname = e . src_conn if cname and inferred [ ( node , cname , False ) ] . type is None : raise TypeError ( 'Ambiguous or uninferable type in' ' connector "%s" of node "%s"' % ( cname , node ) )
short_docstring: Infers the connectors of a node and updates `inferred` accordingly.
short_docstring_tokens: Infers the connectors of a node and updates ` inferred ` accordingly .
comment: """ Infers the connectors of a node and updates `inferred` accordingly. """$SEP$# Try to infer input connector type from node type or previous edges$SEP$# If nested SDFG, try to use internal array type$SEP$# Obtain type from memlet$SEP$# Code->Code$SEP$# Try to infer outputs from output edges$SEP$# If nested SDFG, try to use internal array type$SEP$# Obtain type from memlet$SEP$# Let the node infer other output types on its own$SEP$# If there are any remaining uninferable connectors, fail