nncf/experimental/torch/nas/bootstrapNAS/elasticity/elastic_width.py
def activate_subnet_for_config(self, config: ElasticWidthConfig) -> None:
        """
        Activates a Subnet that corresponds to the given elasticity configuration

        :param config: map of pruning group id to width value
        """
        for node in self._propagation_graph.get_all_nodes():
            node.data.pop('output_mask', None)

        names_of_processed_nodes = set()
        for cluster_id, width in config.items():
            cluster = self._pruned_module_groups_info.get_cluster_by_id(cluster_id)
            for elastic_width_info in cluster.elements:
                node_id = elastic_width_info.nncf_node_id
                node = self._propagation_graph.get_node_by_id(node_id)
                max_width = elastic_width_info.elastic_op.max_width
                device = get_model_device(self._target_model)
                mask = self._width_to_mask(width, max_width, device)
                node.data['output_mask'] = mask
                elastic_width_info.elastic_op.set_active_width(width)
                names_of_processed_nodes.add(node_id)

        algo = MaskPropagationAlgorithm(
            self._propagation_graph, PT_PRUNING_OPERATOR_METATYPES, PTNNCFPruningTensorProcessor)
        algo.mask_propagation()

        for node_name, dynamic_input_width_op in self._node_name_vs_dynamic_input_width_op_map.items():
            node = self._propagation_graph.get_node_by_name(node_name)
            input_masks = get_input_masks(node, self._propagation_graph)
            was_set = False
            if input_masks:
                input_mask = input_masks[0]
                input_width = self.mask_to_width(input_mask)
                if input_width:
                    dynamic_input_width_op.set_active_width(input_width)
                    was_set = True

            if not was_set and node_name not in names_of_processed_nodes:
                nncf_logger.debug('input width was not set in scope={}'.format(node.node_name))

        Activates a Subnet that corresponds to the given elasticity configuration

        :param config: map of pruning group id to width value
        
Activates a Subnet that corresponds to the given elasticity configuration
Activates a Subnet that corresponds to the given elasticity configuration
def activate_subnet_for_config(self, config: ElasticWidthConfig) -> None:
        for node in self._propagation_graph.get_all_nodes():
            node.data.pop('output_mask', None)
        names_of_processed_nodes = set()
        for cluster_id, width in config.items():
            cluster = self._pruned_module_groups_info.get_cluster_by_id(cluster_id)
            for elastic_width_info in cluster.elements:
                node_id = elastic_width_info.nncf_node_id
                node = self._propagation_graph.get_node_by_id(node_id)
                max_width = elastic_width_info.elastic_op.max_width
                device = get_model_device(self._target_model)
                mask = self._width_to_mask(width, max_width, device)
                node.data['output_mask'] = mask
                elastic_width_info.elastic_op.set_active_width(width)
                names_of_processed_nodes.add(node_id)
        algo = MaskPropagationAlgorithm(
            self._propagation_graph, PT_PRUNING_OPERATOR_METATYPES, PTNNCFPruningTensorProcessor)
        algo.mask_propagation()
        for node_name, dynamic_input_width_op in self._node_name_vs_dynamic_input_width_op_map.items():
            node = self._propagation_graph.get_node_by_name(node_name)
            input_masks = get_input_masks(node, self._propagation_graph)
            was_set = False
            if input_masks:
                input_mask = input_masks[0]
                input_width = self.mask_to_width(input_mask)
                if input_width:
                    dynamic_input_width_op.set_active_width(input_width)
                    was_set = True
            if not was_set and node_name not in names_of_processed_nodes:
                nncf_logger.debug('input width was not set in scope={}'.format(node.node_name))
def activate_subnet_for_config ( self , config : ElasticWidthConfig ) -> None : for node in self . _propagation_graph . get_all_nodes ( ) : node . data . pop ( 'output_mask' , None ) names_of_processed_nodes = set ( ) for cluster_id , width in config . items ( ) : cluster = self . _pruned_module_groups_info . get_cluster_by_id ( cluster_id ) for elastic_width_info in cluster . elements : node_id = elastic_width_info . nncf_node_id node = self . _propagation_graph . get_node_by_id ( node_id ) max_width = elastic_width_info . elastic_op . max_width device = get_model_device ( self . _target_model ) mask = self . _width_to_mask ( width , max_width , device ) node . data [ 'output_mask' ] = mask elastic_width_info . elastic_op . set_active_width ( width ) names_of_processed_nodes . add ( node_id ) algo = MaskPropagationAlgorithm ( self . _propagation_graph , PT_PRUNING_OPERATOR_METATYPES , PTNNCFPruningTensorProcessor ) algo . mask_propagation ( ) for node_name , dynamic_input_width_op in self . _node_name_vs_dynamic_input_width_op_map . items ( ) : node = self . _propagation_graph . get_node_by_name ( node_name ) input_masks = get_input_masks ( node , self . _propagation_graph ) was_set = False if input_masks : input_mask = input_masks [ 0 ] input_width = self . mask_to_width ( input_mask ) if input_width : dynamic_input_width_op . set_active_width ( input_width ) was_set = True if not was_set and node_name not in names_of_processed_nodes : nncf_logger . debug ( 'input width was not set in scope={}' . format ( node . node_name ) )
Activates a Subnet that corresponds to the given elasticity configuration
Activates a Subnet that corresponds to the given elasticity configuration
"""
        Activates a Subnet that corresponds to the given elasticity configuration

        :param config: map of pruning group id to width value
        """
self
config
ElasticWidthConfig
map of pruning group id to width value
map of pruning group id to width value