Skip to content

Commit

Permalink
Remove unused code (#2789)
Browse files Browse the repository at this point in the history
### Changes

- Unused code was removed

### Reason for changes

- Improve quality

### Related tickets

N/A

### Tests

pre-commit scope
  • Loading branch information
andrey-churkin authored Jul 10, 2024
1 parent e9ae8f5 commit 73b044a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 301 deletions.
34 changes: 1 addition & 33 deletions nncf/common/insertion_point_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import defaultdict
from copy import deepcopy
from enum import Enum
from typing import Dict, List, Optional, Set
from typing import Dict, List, Set

import networkx as nx

Expand All @@ -23,7 +23,6 @@
from nncf.common.graph.layer_attributes import Dtype
from nncf.common.graph.operator_metatypes import INPUT_NOOP_METATYPES
from nncf.common.graph.patterns import GraphPattern
from nncf.common.logging import nncf_logger


class InsertionPointGraphNodeType(Enum):
Expand Down Expand Up @@ -393,34 +392,3 @@ def get_pre_hook_node_key(node_key: str, input_port_id: int = 0) -> str:
@staticmethod
def get_post_hook_node_key(node_key: str) -> str:
return InsertionPointGraph.POST_HOOK_ID_PREFIX + node_key


class ConstantNodesFilter:
@staticmethod
def filter(ip_graph: InsertionPointGraph, start_traversing_node_keys: Optional[List[str]]) -> InsertionPointGraph:
"""
Removes all Constant nodes from InsertionPointGraph, making it inference graph.
The traversing starts from the input nodes and nodes with weights.
:param ip_graph: The original InsertionPointGraph.
:param start_traversing_node_keys: Keys of the nodes from which the traversing will be start.
:return: InsertionPointGraph without Constant nodes.
"""
input_nodes = ip_graph.get_input_nodes()
if not input_nodes:
nncf_logger.debug("Skipped filtering - no input nodes found")
return ip_graph
weight_nodes = []
if start_traversing_node_keys is not None:
weight_nodes = [
ip_graph.get_merged_node_from_single_node_key(weight_node) for weight_node in start_traversing_node_keys
]
visited_nodes = set()
start_nodes = input_nodes + weight_nodes
for node in start_nodes:
for node_from, node_to in nx.bfs_edges(ip_graph, source=node):
visited_nodes.add(node_from)
visited_nodes.add(node_to)
constant_nodes = [node for node in ip_graph.nodes if node not in visited_nodes]
ip_graph.remove_nodes_from(constant_nodes)
return ip_graph
264 changes: 0 additions & 264 deletions tests/common/quantization/test_filter_constant_nodes.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/common/test_ignored_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from tests.common.quantization.metatypes import Conv2dTestMetatype
from tests.common.quantization.metatypes import LinearTestMetatype
from tests.common.quantization.mock_graphs import NodeWithType
from tests.common.quantization.test_filter_constant_nodes import create_mock_graph
from tests.common.quantization.test_filter_constant_nodes import get_nncf_graph_from_mock_nx_graph
from tests.common.quantization.mock_graphs import create_mock_graph
from tests.common.quantization.mock_graphs import get_nncf_graph_from_mock_nx_graph

LINEAR_TYPE = "linear"
CONV_TYPE = "conv"
Expand Down
4 changes: 2 additions & 2 deletions tests/post_training/test_templates/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from nncf.common.graph.operator_metatypes import OutputNoopMetatype
from tests.common.quantization.metatypes import ConstantTestMetatype
from tests.common.quantization.mock_graphs import NodeWithType
from tests.common.quantization.test_filter_constant_nodes import create_mock_graph
from tests.common.quantization.test_filter_constant_nodes import get_nncf_graph_from_mock_nx_graph
from tests.common.quantization.mock_graphs import create_mock_graph
from tests.common.quantization.mock_graphs import get_nncf_graph_from_mock_nx_graph


class NNCFGraphToTest:
Expand Down

0 comments on commit 73b044a

Please sign in to comment.