TrainingExtensions/torch/src/python/aimet_torch/meta/connectedgraph.py
def _create_connections_to_ir_nodes_dict(self, ir_nodes_list: List[IrNode]) -> ConnectionsToIrDictType:
        """
        Create a mapping from connections found in torch graph to input and output IrNodes. Each connection will have one
        input and zero or more outputs IrNodes.
        :param ir_nodes_list: List of IrNodes to extract connections information from
        :return: Dictionary mapping connections to input ir_node and output ir_nodes
        """
        connections_to_ir_nodes_dict = {}
        for ir_node in ir_nodes_list:
            node_inputs = _flatten_lists(ir_node.inputs)
            node_outputs = _flatten_lists(ir_node.outputs)
            for inp in node_inputs:
                if inp in connections_to_ir_nodes_dict:
                    connections_to_ir_nodes_dict[inp][1].append(ir_node)
                else:
                    connections_to_ir_nodes_dict[inp] = [None, [ir_node]]
            for output in node_outputs:
                if output in connections_to_ir_nodes_dict:
                    if connections_to_ir_nodes_dict[output][0] is not None:
                        inp_op_name = None
                        if connections_to_ir_nodes_dict[output][0].module is not None:
                            inp_op_name = self._module_to_name[connections_to_ir_nodes_dict[output][0].module]
                        logger.error('Input of %s with name %s already exists. Ensure that no modules are being reused '
                                     'in the model.', output, inp_op_name)
                        raise AssertionError
                    connections_to_ir_nodes_dict[output][0] = ir_node
                else:
                    connections_to_ir_nodes_dict[output] = [ir_node, []]
        return connections_to_ir_nodes_dict

        Create a mapping from connections found in torch graph to input and output IrNodes. Each connection will have one
        input and zero or more outputs IrNodes.
        :param ir_nodes_list: List of IrNodes to extract connections information from
        :return: Dictionary mapping connections to input ir_node and output ir_nodes
        
Create a mapping from connections found in torch graph to input and output IrNodes. Each connection will have one
input and zero or more outputs IrNodes.
Create a mapping from connections found in torch graph to input and output IrNodes . Each connection will have one input and zero or more outputs IrNodes .
def _create_connections_to_ir_nodes_dict(self, ir_nodes_list: List[IrNode]) -> ConnectionsToIrDictType:
        connections_to_ir_nodes_dict = {}
        for ir_node in ir_nodes_list:
            node_inputs = _flatten_lists(ir_node.inputs)
            node_outputs = _flatten_lists(ir_node.outputs)
            for inp in node_inputs:
                if inp in connections_to_ir_nodes_dict:
                    connections_to_ir_nodes_dict[inp][1].append(ir_node)
                else:
                    connections_to_ir_nodes_dict[inp] = [None, [ir_node]]
            for output in node_outputs:
                if output in connections_to_ir_nodes_dict:
                    if connections_to_ir_nodes_dict[output][0] is not None:
                        inp_op_name = None
                        if connections_to_ir_nodes_dict[output][0].module is not None:
                            inp_op_name = self._module_to_name[connections_to_ir_nodes_dict[output][0].module]
                        logger.error('Input of %s with name %s already exists. Ensure that no modules are being reused '
                                     'in the model.', output, inp_op_name)
                        raise AssertionError
                    connections_to_ir_nodes_dict[output][0] = ir_node
                else:
                    connections_to_ir_nodes_dict[output] = [ir_node, []]
        return connections_to_ir_nodes_dict
def _create_connections_to_ir_nodes_dict ( self , ir_nodes_list : List [ IrNode ] ) -> ConnectionsToIrDictType : connections_to_ir_nodes_dict = { } for ir_node in ir_nodes_list : node_inputs = _flatten_lists ( ir_node . inputs ) node_outputs = _flatten_lists ( ir_node . outputs ) for inp in node_inputs : if inp in connections_to_ir_nodes_dict : connections_to_ir_nodes_dict [ inp ] [ 1 ] . append ( ir_node ) else : connections_to_ir_nodes_dict [ inp ] = [ None , [ ir_node ] ] for output in node_outputs : if output in connections_to_ir_nodes_dict : if connections_to_ir_nodes_dict [ output ] [ 0 ] is not None : inp_op_name = None if connections_to_ir_nodes_dict [ output ] [ 0 ] . module is not None : inp_op_name = self . _module_to_name [ connections_to_ir_nodes_dict [ output ] [ 0 ] . module ] logger . error ( 'Input of %s with name %s already exists. Ensure that no modules are being reused ' 'in the model.' , output , inp_op_name ) raise AssertionError connections_to_ir_nodes_dict [ output ] [ 0 ] = ir_node else : connections_to_ir_nodes_dict [ output ] = [ ir_node , [ ] ] return connections_to_ir_nodes_dict
Create a mapping from connections found in torch graph to input and output IrNodes.
Create a mapping from connections found in torch graph to input and output IrNodes .
"""
        Create a mapping from connections found in torch graph to input and output IrNodes. Each connection will have one
        input and zero or more outputs IrNodes.
        :param ir_nodes_list: List of IrNodes to extract connections information from
        :return: Dictionary mapping connections to input ir_node and output ir_nodes
        """
Dictionary mapping connections to input ir_node and output ir_nodes
Dictionary mapping connections to input ir_node and output ir_nodes
self
ir_nodes_list
List[IrNode]
List of IrNodes to extract connections information from
List of IrNodes to extract connections information from