nncf/experimental/torch/search_building_blocks/search_blocks.py
def check_graph_has_no_duplicate_edges_after_block_removal(sgraph: SearchGraph,
                                                           start_node: SearchGraphNode,
                                                           end_node: SearchGraphNode) -> bool:
    """
    This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
    """
    #         A              A
    #        / \            / \
    #       /   \          /   \
    #    block   |  =>     \   /
    #       \   /           \ /
    #        \ /             D
    #         D          forbidden

    # pylint: disable=protected-access
    if start_node.is_dummy:
        next_end_node = sgraph.get_next_nodes(end_node.node_key)
        if len(next_end_node) != 0:
            attr = sgraph._nx_graph.get_edge_data(start_node.node_key, next_end_node[0].node_key)
        else:
            attr = None
    else:
        pred_start_node = sgraph.get_prev_nodes(start_node.node_key)
        next_end_node = sgraph.get_next_nodes(end_node.node_key)
        if len(pred_start_node) != 0 and len(next_end_node) != 0:
            attr = sgraph._nx_graph.get_edge_data(pred_start_node[0].node_key, next_end_node[0].node_key)
        else:
            attr = None
    return attr is None

    This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
    
This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
This rule ensures that no duplicate edges will be created in the graph after a block is deleted .
def check_graph_has_no_duplicate_edges_after_block_removal(sgraph: SearchGraph,
                                                           start_node: SearchGraphNode,
                                                           end_node: SearchGraphNode) -> bool:
    if start_node.is_dummy:
        next_end_node = sgraph.get_next_nodes(end_node.node_key)
        if len(next_end_node) != 0:
            attr = sgraph._nx_graph.get_edge_data(start_node.node_key, next_end_node[0].node_key)
        else:
            attr = None
    else:
        pred_start_node = sgraph.get_prev_nodes(start_node.node_key)
        next_end_node = sgraph.get_next_nodes(end_node.node_key)
        if len(pred_start_node) != 0 and len(next_end_node) != 0:
            attr = sgraph._nx_graph.get_edge_data(pred_start_node[0].node_key, next_end_node[0].node_key)
        else:
            attr = None
    return attr is None
def check_graph_has_no_duplicate_edges_after_block_removal ( sgraph : SearchGraph , start_node : SearchGraphNode , end_node : SearchGraphNode ) -> bool : if start_node . is_dummy : next_end_node = sgraph . get_next_nodes ( end_node . node_key ) if len ( next_end_node ) != 0 : attr = sgraph . _nx_graph . get_edge_data ( start_node . node_key , next_end_node [ 0 ] . node_key ) else : attr = None else : pred_start_node = sgraph . get_prev_nodes ( start_node . node_key ) next_end_node = sgraph . get_next_nodes ( end_node . node_key ) if len ( pred_start_node ) != 0 and len ( next_end_node ) != 0 : attr = sgraph . _nx_graph . get_edge_data ( pred_start_node [ 0 ] . node_key , next_end_node [ 0 ] . node_key ) else : attr = None return attr is None
This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
This rule ensures that no duplicate edges will be created in the graph after a block is deleted .
"""
    This rule ensures that no duplicate edges will be created in the graph after a block is deleted.
    """ #         A              A #        / \            / \ #       /   \          /   \ #    block   |  =>     \   / #       \   /           \ / #        \ /             D #         D          forbidden # pylint: disable=protected-access
sgraph
SearchGraph
start_node
SearchGraphNode
end_node
SearchGraphNode