From ee64fe4e9f25d690da851c5888edc5d96e82c00d Mon Sep 17 00:00:00 2001 From: anzr299 Date: Thu, 31 Oct 2024 10:56:09 +0400 Subject: [PATCH] update transformations for impure nodes. --- nncf/experimental/torch/fx/transformations.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nncf/experimental/torch/fx/transformations.py b/nncf/experimental/torch/fx/transformations.py index e80a20dd6b..445f2a3166 100644 --- a/nncf/experimental/torch/fx/transformations.py +++ b/nncf/experimental/torch/fx/transformations.py @@ -996,5 +996,10 @@ def _merge_node_and_bias(model: torch.fx.GraphModule, is_target_node: Callable[[ # Remove nodes which are not connected to output. This removes dead nodes and dead subgraphs in the model graph. nodes_connected_to_output = _get_connected_nodes(model.graph) is_impure = lambda node: node in nodes_connected_to_output - model.graph.eliminate_dead_code(is_impure) + + for node in reversed(model.graph.nodes): + if not is_impure(node) and len(node.users) == 0: + model.graph.erase_node(node) + + model.graph.eliminate_dead_code() model.recompile()