nncf/experimental/torch/search_building_blocks/search_blocks.py
def remove_linear_combination(sorted_building_blocks: List[PotentialBuildingBlock]) -> List[PotentialBuildingBlock]:
    """
    Search and remove of block which is a combination of other blocks following each other.
    """
    result_blocks = []
    start_to_idx = {}
    last_node = None
    for block in sorted_building_blocks:
        if last_node == block.end_node:
            if block.start_node.main_id in start_to_idx:
                if not search_lin_combination(block, result_blocks[start_to_idx[block.start_node.main_id]:]):
                    result_blocks.append(block)
                    last_node = block.end_node
        else:
            result_blocks.append(block)
            last_node = block.end_node
            if block.start_node.main_id not in start_to_idx:
                start_to_idx[block.start_node.main_id] = len(result_blocks) - 1

    return result_blocks

    Search and remove of block which is a combination of other blocks following each other.
    
Search and remove of block which is a combination of other blocks following each other.
Search and remove of block which is a combination of other blocks following each other .
def remove_linear_combination(sorted_building_blocks: List[PotentialBuildingBlock]) -> List[PotentialBuildingBlock]:
    result_blocks = []
    start_to_idx = {}
    last_node = None
    for block in sorted_building_blocks:
        if last_node == block.end_node:
            if block.start_node.main_id in start_to_idx:
                if not search_lin_combination(block, result_blocks[start_to_idx[block.start_node.main_id]:]):
                    result_blocks.append(block)
                    last_node = block.end_node
        else:
            result_blocks.append(block)
            last_node = block.end_node
            if block.start_node.main_id not in start_to_idx:
                start_to_idx[block.start_node.main_id] = len(result_blocks) - 1
    return result_blocks
def remove_linear_combination ( sorted_building_blocks : List [ PotentialBuildingBlock ] ) -> List [ PotentialBuildingBlock ] : result_blocks = [ ] start_to_idx = { } last_node = None for block in sorted_building_blocks : if last_node == block . end_node : if block . start_node . main_id in start_to_idx : if not search_lin_combination ( block , result_blocks [ start_to_idx [ block . start_node . main_id ] : ] ) : result_blocks . append ( block ) last_node = block . end_node else : result_blocks . append ( block ) last_node = block . end_node if block . start_node . main_id not in start_to_idx : start_to_idx [ block . start_node . main_id ] = len ( result_blocks ) - 1 return result_blocks
Search and remove of block which is a combination of other blocks following each other.
Search and remove of block which is a combination of other blocks following each other .
"""
    Search and remove of block which is a combination of other blocks following each other.
    """
sorted_building_blocks
List[PotentialBuildingBlock]