nncf/experimental/torch/nas/bootstrapNAS/elasticity/elastic_width.py
def reorganize_weights(self) -> None:
        """
        Reorder output filters in descending order of their importance.
        """
        for node in self._propagation_graph.get_all_nodes():
            node.data.pop('output_mask', None)

        # 1. Calculate filter importance for all groups of prunable layers
        for group in self._pruned_module_groups_info.get_all_clusters():
            filters_num = torch.tensor([get_filters_num(minfo.module) for minfo in group.elements])
            assert torch.all(filters_num == filters_num[0])
            device = group.elements[0].module.weight.device

            cumulative_filters_importance = torch.zeros(filters_num[0]).to(device)
            # 1.1 Calculate cumulative importance for all filters in this group
            for minfo in group.elements:
                weight = minfo.module.weight
                if self._weights_normalizer_fn:
                    weight = self._weights_normalizer_fn(minfo.module.weight)
                filters_importance = self._filter_importance_fn(weight,
                                                                minfo.module.target_weight_dim_for_compression)
                cumulative_filters_importance += filters_importance

            _, reorder_indexes = torch.sort(cumulative_filters_importance, dim=0, descending=True)
            device = get_model_device(self._target_model)
            reorder_indexes.to(device)
            # 1.2 Setup reorder indexes as output mask to reorganize filters
            for minfo in group.elements:
                node = self._propagation_graph.get_node_by_id(minfo.nncf_node_id)
                node.data['output_mask'] = PTNNCFTensor(reorder_indexes)

        # 2. Propagating masks across the graph
        reorder_algo = FilterReorderingAlgorithm(self._target_model,
                                                 self._propagation_graph,
                                                 PT_PRUNING_OPERATOR_METATYPES,
                                                 PTNNCFPruningTensorProcessor)
        reorder_algo.reorder_filters()

        Reorder output filters in descending order of their importance.
        
Reorder output filters in descending order of their importance.
Reorder output filters in descending order of their importance .
def reorganize_weights(self) -> None:
        for node in self._propagation_graph.get_all_nodes():
            node.data.pop('output_mask', None)
        for group in self._pruned_module_groups_info.get_all_clusters():
            filters_num = torch.tensor([get_filters_num(minfo.module) for minfo in group.elements])
            assert torch.all(filters_num == filters_num[0])
            device = group.elements[0].module.weight.device
            cumulative_filters_importance = torch.zeros(filters_num[0]).to(device)
            for minfo in group.elements:
                weight = minfo.module.weight
                if self._weights_normalizer_fn:
                    weight = self._weights_normalizer_fn(minfo.module.weight)
                filters_importance = self._filter_importance_fn(weight,
                                                                minfo.module.target_weight_dim_for_compression)
                cumulative_filters_importance += filters_importance
            _, reorder_indexes = torch.sort(cumulative_filters_importance, dim=0, descending=True)
            device = get_model_device(self._target_model)
            reorder_indexes.to(device)
            for minfo in group.elements:
                node = self._propagation_graph.get_node_by_id(minfo.nncf_node_id)
                node.data['output_mask'] = PTNNCFTensor(reorder_indexes)
        reorder_algo = FilterReorderingAlgorithm(self._target_model,
                                                 self._propagation_graph,
                                                 PT_PRUNING_OPERATOR_METATYPES,
                                                 PTNNCFPruningTensorProcessor)
        reorder_algo.reorder_filters()
def reorganize_weights ( self ) -> None : for node in self . _propagation_graph . get_all_nodes ( ) : node . data . pop ( 'output_mask' , None ) for group in self . _pruned_module_groups_info . get_all_clusters ( ) : filters_num = torch . tensor ( [ get_filters_num ( minfo . module ) for minfo in group . elements ] ) assert torch . all ( filters_num == filters_num [ 0 ] ) device = group . elements [ 0 ] . module . weight . device cumulative_filters_importance = torch . zeros ( filters_num [ 0 ] ) . to ( device ) for minfo in group . elements : weight = minfo . module . weight if self . _weights_normalizer_fn : weight = self . _weights_normalizer_fn ( minfo . module . weight ) filters_importance = self . _filter_importance_fn ( weight , minfo . module . target_weight_dim_for_compression ) cumulative_filters_importance += filters_importance _ , reorder_indexes = torch . sort ( cumulative_filters_importance , dim = 0 , descending = True ) device = get_model_device ( self . _target_model ) reorder_indexes . to ( device ) for minfo in group . elements : node = self . _propagation_graph . get_node_by_id ( minfo . nncf_node_id ) node . data [ 'output_mask' ] = PTNNCFTensor ( reorder_indexes ) reorder_algo = FilterReorderingAlgorithm ( self . _target_model , self . _propagation_graph , PT_PRUNING_OPERATOR_METATYPES , PTNNCFPruningTensorProcessor ) reorder_algo . reorder_filters ( )
Reorder output filters in descending order of their importance.
Reorder output filters in descending order of their importance .
"""
        Reorder output filters in descending order of their importance.
        """ # 1. Calculate filter importance for all groups of prunable layers # 1.1 Calculate cumulative importance for all filters in this group # 1.2 Setup reorder indexes as output mask to reorganize filters # 2. Propagating masks across the graph
self