parameters: (self, model, topo)
docstring: Rebuild topology of the given model.
  
      1. Skiping Identity module.
      Some sub modules of the model may be replaced by nn.Identity in
      transform and these Identity modules can cause patterns to fail to be
      matched.
  
      For eaxmple, the original topology is Conv2d -> BatchNorm2d -> Add,
      after being transformed by fusing Conv and Bn, the topology would be like
      ConvBatchNorm2d -> Identity -> Add. In this case, the pattern
      NodePattern("Add", inputs=["ConvBatchNorm2d", "ConvBatchNorm2d"]) can not
      be matched.
  
      2. Updating node's module. The node's corresponding module may change
      after the transformation. Assign the actual module to the node.
  
      Call this function before doing pattern matching
      to make sure no matches are missed.
docstring_summary: Rebuild topology of the given model.
docstring_tokens: Rebuild topology of the given model .
function: def _rebuild_topo(self, model, topo):
      """Rebuild topology of the given model.
  
      1. Skiping Identity module.
      Some sub modules of the model may be replaced by nn.Identity in
      transform and these Identity modules can cause patterns to fail to be
      matched.
  
      For eaxmple, the original topology is Conv2d -> BatchNorm2d -> Add,
      after being transformed by fusing Conv and Bn, the topology would be like
      ConvBatchNorm2d -> Identity -> Add. In this case, the pattern
      NodePattern("Add", inputs=["ConvBatchNorm2d", "ConvBatchNorm2d"]) can not
      be matched.
  
      2. Updating node's module. The node's corresponding module may change
      after the transformation. Assign the actual module to the node.
  
      Call this function before doing pattern matching
      to make sure no matches are missed.
      """
  
      node_to_inputs = {}
      for node in topo.nodes:
        node_to_inputs[node.name] = node.inputs
  
      for node in topo.nodes:
        for i, inp in enumerate(node.inputs):
          input_node = topo.node(inp)
          while type(input_node.module) == nn.Identity:
            input_node = topo.node(node_to_inputs[inp][0])
          node.inputs[i] = input_node.name
          #print('Skip identity: {} <- {}'.format(node.name, input_node.name))
  
      # Update node's module.
      for node in topo.nodes:
        try:
          node.module = mod_util.get_module(model, node.name)
        except AttributeError:
          pass
function_tokens: def _rebuild_topo ( self , model , topo ) : node_to_inputs = { } for node in topo . nodes : node_to_inputs [ node . name ] = node . inputs for node in topo . nodes : for i , inp in enumerate ( node . inputs ) : input_node = topo . node ( inp ) while type ( input_node . module ) == nn . Identity : input_node = topo . node ( node_to_inputs [ inp ] [ 0 ] ) node . inputs [ i ] = input_node . name #print('Skip identity: {} <- {}'.format(node.name, input_node.name)) # Update node's module. for node in topo . nodes : try : node . module = mod_util . get_module ( model , node . name ) except AttributeError : pass