Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code #2789

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading