nncf/common/pruning/node_selector.py
def _should_prune_groups_analysis(self, graph: NNCFGraph, pruned_nodes_clusterization: Clusterization,
                                      can_prune: Dict[int, PruningAnalysisDecision]) \
            -> Dict[int, PruningAnalysisDecision]:
        """
        Check whether all nodes in group can be pruned based on user-defined constraints and
        model analysis. Otherwise the whole group cannot be pruned.

        :param graph: Graph to work with.
        :param pruned_nodes_clusterization: Clusterization with pruning nodes groups.
        :param can_prune: Complete pruning analysis about each graph node.
        :return:
        """
        should_prune = {}
        for cluster in pruned_nodes_clusterization.get_all_clusters():
            should_prune_decisions = [self._is_module_prunable(graph, node) for node in cluster.elements]
            can_prune_decisions = [can_prune[node.node_id] for node in cluster.elements]
            decisions = [can.join(should) for can, should in zip(can_prune_decisions, should_prune_decisions)]
            if not all(decisions):
                updated_decisions = {}
                for node, decision in zip(cluster.elements, decisions):
                    if decision:
                        updated_decisions[node.node_id] = \
                            PruningAnalysisDecision(False, PruningAnalysisReason.IN_GROUP_OF_UNPRUNABLE)
                    else:
                        updated_decisions[node.node_id] = decision

                should_prune.update(updated_decisions)

        can_prune_updated = can_prune.copy()
        can_prune_updated.update(should_prune)
        return can_prune_updated

        Check whether all nodes in group can be pruned based on user-defined constraints and
        model analysis. Otherwise the whole group cannot be pruned.

        :param graph: Graph to work with.
        :param pruned_nodes_clusterization: Clusterization with pruning nodes groups.
        :param can_prune: Complete pruning analysis about each graph node.
        :return:
        
Check whether all nodes in group can be pruned based on user-defined constraints and
model analysis. Otherwise the whole group cannot be pruned.
Check whether all nodes in group can be pruned based on user - defined constraints and model analysis . Otherwise the whole group cannot be pruned .
def _should_prune_groups_analysis(self, graph: NNCFGraph, pruned_nodes_clusterization: Clusterization,
                                      can_prune: Dict[int, PruningAnalysisDecision]) \
            -> Dict[int, PruningAnalysisDecision]:
        should_prune = {}
        for cluster in pruned_nodes_clusterization.get_all_clusters():
            should_prune_decisions = [self._is_module_prunable(graph, node) for node in cluster.elements]
            can_prune_decisions = [can_prune[node.node_id] for node in cluster.elements]
            decisions = [can.join(should) for can, should in zip(can_prune_decisions, should_prune_decisions)]
            if not all(decisions):
                updated_decisions = {}
                for node, decision in zip(cluster.elements, decisions):
                    if decision:
                        updated_decisions[node.node_id] = \
                            PruningAnalysisDecision(False, PruningAnalysisReason.IN_GROUP_OF_UNPRUNABLE)
                    else:
                        updated_decisions[node.node_id] = decision
                should_prune.update(updated_decisions)
        can_prune_updated = can_prune.copy()
        can_prune_updated.update(should_prune)
        return can_prune_updated
def _should_prune_groups_analysis ( self , graph : NNCFGraph , pruned_nodes_clusterization : Clusterization , can_prune : Dict [ int , PruningAnalysisDecision ] ) -> Dict [ int , PruningAnalysisDecision ] : should_prune = { } for cluster in pruned_nodes_clusterization . get_all_clusters ( ) : should_prune_decisions = [ self . _is_module_prunable ( graph , node ) for node in cluster . elements ] can_prune_decisions = [ can_prune [ node . node_id ] for node in cluster . elements ] decisions = [ can . join ( should ) for can , should in zip ( can_prune_decisions , should_prune_decisions ) ] if not all ( decisions ) : updated_decisions = { } for node , decision in zip ( cluster . elements , decisions ) : if decision : updated_decisions [ node . node_id ] = PruningAnalysisDecision ( False , PruningAnalysisReason . IN_GROUP_OF_UNPRUNABLE ) else : updated_decisions [ node . node_id ] = decision should_prune . update ( updated_decisions ) can_prune_updated = can_prune . copy ( ) can_prune_updated . update ( should_prune ) return can_prune_updated
Check whether all nodes in group can be pruned based on user-defined constraints and
model analysis.
Check whether all nodes in group can be pruned based on user - defined constraints and model analysis .
"""
        Check whether all nodes in group can be pruned based on user-defined constraints and
        model analysis. Otherwise the whole group cannot be pruned.

        :param graph: Graph to work with.
        :param pruned_nodes_clusterization: Clusterization with pruning nodes groups.
        :param can_prune: Complete pruning analysis about each graph node.
        :return:
        """
None
self
graph
NNCFGraph
Graph to work with.
Graph to work with .
pruned_nodes_clusterization
Clusterization
Clusterization with pruning nodes groups.
Clusterization with pruning nodes groups .
can_prune
Dict[int, PruningAnalysisDecision]
Complete pruning analysis about each graph node.
Complete pruning analysis about each graph node .