nncf/experimental/torch/nas/bootstrapNAS/elasticity/elastic_width.py
def find_pairs_of_nodes_with_different_width(self, pairs_of_nodes: List[Tuple[str, str]]) -> List[int]:
        """
        Find pairs of nodes that have different output shapes. It's need to resolve conflict between elastic width and
        elastic depth. The conflicting situation happens when layers are trimmed and skipped independently.
        There might be a situation when channels are trimmed for the layers in the beginning of skipped block, and
        not trimmed in the end, thus violating the necessary condition for skipping a block - output shapes on
        block boundaries should be the same.

        :param pairs_of_nodes: list of pairs of node names
        :return: index of nodes pair in the given list that have different output shapes.
        """
        pair_indexes = []
        for idx, (start_node_name, end_node_name) in enumerate(pairs_of_nodes):
            start_node = self._propagation_graph.get_node_by_name(start_node_name)
            start_mask = start_node.data['output_mask']
            end_node = self._propagation_graph.get_node_by_name(end_node_name)
            end_mask = end_node.data['output_mask']

            all_start_output_shapes = self._propagation_graph.get_output_shapes_for_node(start_node_name)
            start_output_shape = list(OrderedDict.fromkeys(all_start_output_shapes))
            all_end_output_shape = self._propagation_graph.get_output_shapes_for_node(end_node_name)
            end_output_shape = list(OrderedDict.fromkeys(all_end_output_shape))

            start_width = ElasticWidthHandler.mask_to_width(start_mask)
            end_width = ElasticWidthHandler.mask_to_width(end_mask)

            if start_width is None and end_width is None and start_output_shape != end_output_shape:
                reason = f'it has a different shapes on boundaries: {start_output_shape} != {end_output_shape}'
            elif start_width is not None and end_width is not None and start_width != end_width:
                reason = f'it has a different width on boundaries: {start_width} != {end_width}'
            elif (start_width is None or end_width is None) and not (start_width is None and end_width is None):
                reason = f'it has empty width on one of the boundaries. ' \
                         f'Width: {start_width} vs {end_width}. Shapes: {start_output_shape} vs {end_output_shape}'
            else:
                continue
            nncf_logger.warning('The block [\n\t{},\n\t{}\n]\n can`t be skipped, because {}'.format(
                start_node_name, end_node_name, reason))
            pair_indexes.append(idx)
        return pair_indexes

        Find pairs of nodes that have different output shapes. It's need to resolve conflict between elastic width and
        elastic depth. The conflicting situation happens when layers are trimmed and skipped independently.
        There might be a situation when channels are trimmed for the layers in the beginning of skipped block, and
        not trimmed in the end, thus violating the necessary condition for skipping a block - output shapes on
        block boundaries should be the same.

        :param pairs_of_nodes: list of pairs of node names
        :return: index of nodes pair in the given list that have different output shapes.
        
Find pairs of nodes that have different output shapes. It's need to resolve conflict between elastic width and
elastic depth. The conflicting situation happens when layers are trimmed and skipped independently.
There might be a situation when channels are trimmed for the layers in the beginning of skipped block, and
not trimmed in the end, thus violating the necessary condition for skipping a block - output shapes on
block boundaries should be the same.
Find pairs of nodes that have different output shapes . It ' s need to resolve conflict between elastic width and elastic depth . The conflicting situation happens when layers are trimmed and skipped independently . There might be a situation when channels are trimmed for the layers in the beginning of skipped block and not trimmed in the end thus violating the necessary condition for skipping a block - output shapes on block boundaries should be the same .
def find_pairs_of_nodes_with_different_width(self, pairs_of_nodes: List[Tuple[str, str]]) -> List[int]:
        pair_indexes = []
        for idx, (start_node_name, end_node_name) in enumerate(pairs_of_nodes):
            start_node = self._propagation_graph.get_node_by_name(start_node_name)
            start_mask = start_node.data['output_mask']
            end_node = self._propagation_graph.get_node_by_name(end_node_name)
            end_mask = end_node.data['output_mask']
            all_start_output_shapes = self._propagation_graph.get_output_shapes_for_node(start_node_name)
            start_output_shape = list(OrderedDict.fromkeys(all_start_output_shapes))
            all_end_output_shape = self._propagation_graph.get_output_shapes_for_node(end_node_name)
            end_output_shape = list(OrderedDict.fromkeys(all_end_output_shape))
            start_width = ElasticWidthHandler.mask_to_width(start_mask)
            end_width = ElasticWidthHandler.mask_to_width(end_mask)
            if start_width is None and end_width is None and start_output_shape != end_output_shape:
                reason = f'it has a different shapes on boundaries: {start_output_shape} != {end_output_shape}'
            elif start_width is not None and end_width is not None and start_width != end_width:
                reason = f'it has a different width on boundaries: {start_width} != {end_width}'
            elif (start_width is None or end_width is None) and not (start_width is None and end_width is None):
                reason = f'it has empty width on one of the boundaries. ' \
                         f'Width: {start_width} vs {end_width}. Shapes: {start_output_shape} vs {end_output_shape}'
            else:
                continue
            nncf_logger.warning('The block [\n\t{},\n\t{}\n]\n can`t be skipped, because {}'.format(
                start_node_name, end_node_name, reason))
            pair_indexes.append(idx)
        return pair_indexes
def find_pairs_of_nodes_with_different_width ( self , pairs_of_nodes : List [ Tuple [ str , str ] ] ) -> List [ int ] : pair_indexes = [ ] for idx , ( start_node_name , end_node_name ) in enumerate ( pairs_of_nodes ) : start_node = self . _propagation_graph . get_node_by_name ( start_node_name ) start_mask = start_node . data [ 'output_mask' ] end_node = self . _propagation_graph . get_node_by_name ( end_node_name ) end_mask = end_node . data [ 'output_mask' ] all_start_output_shapes = self . _propagation_graph . get_output_shapes_for_node ( start_node_name ) start_output_shape = list ( OrderedDict . fromkeys ( all_start_output_shapes ) ) all_end_output_shape = self . _propagation_graph . get_output_shapes_for_node ( end_node_name ) end_output_shape = list ( OrderedDict . fromkeys ( all_end_output_shape ) ) start_width = ElasticWidthHandler . mask_to_width ( start_mask ) end_width = ElasticWidthHandler . mask_to_width ( end_mask ) if start_width is None and end_width is None and start_output_shape != end_output_shape : reason = f'it has a different shapes on boundaries: {start_output_shape} != {end_output_shape}' elif start_width is not None and end_width is not None and start_width != end_width : reason = f'it has a different width on boundaries: {start_width} != {end_width}' elif ( start_width is None or end_width is None ) and not ( start_width is None and end_width is None ) : reason = f'it has empty width on one of the boundaries. ' f'Width: {start_width} vs {end_width}. Shapes: {start_output_shape} vs {end_output_shape}' else : continue nncf_logger . warning ( 'The block [\n\t{},\n\t{}\n]\n can`t be skipped, because {}' . format ( start_node_name , end_node_name , reason ) ) pair_indexes . append ( idx ) return pair_indexes
Find pairs of nodes that have different output shapes.
Find pairs of nodes that have different output shapes .
"""
        Find pairs of nodes that have different output shapes. It's need to resolve conflict between elastic width and
        elastic depth. The conflicting situation happens when layers are trimmed and skipped independently.
        There might be a situation when channels are trimmed for the layers in the beginning of skipped block, and
        not trimmed in the end, thus violating the necessary condition for skipping a block - output shapes on
        block boundaries should be the same.

        :param pairs_of_nodes: list of pairs of node names
        :return: index of nodes pair in the given list that have different output shapes.
        """
index of nodes pair in the given list that have different output shapes.
index of nodes pair in the given list that have different output shapes .
self
pairs_of_nodes
List[Tuple[str, str]]
list of pairs of node names
list of pairs of node names