TrainingExtensions/torch/src/python/aimet_torch/meta/connectedgraph.py
def _handle_passthrough_ir_node(ir_node: IrNode, connections_to_ir_nodes_dict: ConnectionsToIrDictType):
    """
    Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the
    passthrough ir_node.
    :param ir_node: Tuple or list construct ir_node
    :param connections_to_ir_nodes_dict: Dictionary mapping connections to input ir_node and output ir_nodes

    """
    if not ir_node.inputs:
        # This will be the case when input to passthrough node is an input to ignore. In this case, the input connection
        # will have been removed earlier. Treat this node as an input to ignore as well.
        _handle_input_ir_node_to_ignore(ir_node, connections_to_ir_nodes_dict)
    else:
        # For passthrough ops, simply set the input of the consumer ir_nodes of the op's output to be the input of the
        # passthrough op itself.
        # Also clear the inputs and outputs of the passthrough Op to disconnect it from the graph.
        # Below check is not strictly necessary but current logic assumes so. Easy to change in the future if so.
        assert len(ir_node.inputs) == 1
        assert len(ir_node.outputs) == 1
        input_connection = ir_node.inputs[0]
        output_connection = ir_node.outputs[0]
        consumers = connections_to_ir_nodes_dict[output_connection][1]
        for consumer in consumers:
            connection_index = consumer.inputs.index(output_connection)
            consumer.inputs[connection_index] = input_connection
        ir_node.inputs = []
        ir_node.outputs = []
        del connections_to_ir_nodes_dict[output_connection]

    Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the
    passthrough ir_node.
    :param ir_node: Tuple or list construct ir_node
    :param connections_to_ir_nodes_dict: Dictionary mapping connections to input ir_node and output ir_nodes

    
Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the
passthrough ir_node.
Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the passthrough ir_node .
def _handle_passthrough_ir_node(ir_node: IrNode, connections_to_ir_nodes_dict: ConnectionsToIrDictType):
    if not ir_node.inputs:
        _handle_input_ir_node_to_ignore(ir_node, connections_to_ir_nodes_dict)
    else:
        assert len(ir_node.inputs) == 1
        assert len(ir_node.outputs) == 1
        input_connection = ir_node.inputs[0]
        output_connection = ir_node.outputs[0]
        consumers = connections_to_ir_nodes_dict[output_connection][1]
        for consumer in consumers:
            connection_index = consumer.inputs.index(output_connection)
            consumer.inputs[connection_index] = input_connection
        ir_node.inputs = []
        ir_node.outputs = []
        del connections_to_ir_nodes_dict[output_connection]
def _handle_passthrough_ir_node ( ir_node : IrNode , connections_to_ir_nodes_dict : ConnectionsToIrDictType ) : if not ir_node . inputs : _handle_input_ir_node_to_ignore ( ir_node , connections_to_ir_nodes_dict ) else : assert len ( ir_node . inputs ) == 1 assert len ( ir_node . outputs ) == 1 input_connection = ir_node . inputs [ 0 ] output_connection = ir_node . outputs [ 0 ] consumers = connections_to_ir_nodes_dict [ output_connection ] [ 1 ] for consumer in consumers : connection_index = consumer . inputs . index ( output_connection ) consumer . inputs [ connection_index ] = input_connection ir_node . inputs = [ ] ir_node . outputs = [ ] del connections_to_ir_nodes_dict [ output_connection ]
Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the
passthrough ir_node.
Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the passthrough ir_node .
"""
    Update connections of ir_nodes feeding into and following the passthrough ir_node to effectively skip the
    passthrough ir_node.
    :param ir_node: Tuple or list construct ir_node
    :param connections_to_ir_nodes_dict: Dictionary mapping connections to input ir_node and output ir_nodes

    """ # This will be the case when input to passthrough node is an input to ignore. In this case, the input connection # will have been removed earlier. Treat this node as an input to ignore as well. # For passthrough ops, simply set the input of the consumer ir_nodes of the op's output to be the input of the # passthrough op itself. # Also clear the inputs and outputs of the passthrough Op to disconnect it from the graph. # Below check is not strictly necessary but current logic assumes so. Easy to change in the future if so.
ir_node
IrNode
Tuple or list construct ir_node
Tuple or list construct ir_node
connections_to_ir_nodes_dict
ConnectionsToIrDictType
Dictionary mapping connections to input ir_node and output ir_nodes
Dictionary mapping connections to input ir_node and output ir_nodes