From 5b068e775e622375d86c4e261ab911f71ef7b983 Mon Sep 17 00:00:00 2001 From: Affifboudaoud Date: Sun, 23 Nov 2025 22:50:46 +0100 Subject: [PATCH] Add visited set to avoid visiting same node multiple times --- dace/transformation/dataflow/map_fusion_vertical.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dace/transformation/dataflow/map_fusion_vertical.py b/dace/transformation/dataflow/map_fusion_vertical.py index c9c1e418c4..546bff3d6a 100644 --- a/dace/transformation/dataflow/map_fusion_vertical.py +++ b/dace/transformation/dataflow/map_fusion_vertical.py @@ -1541,11 +1541,15 @@ def _is_data_accessed_downstream( def next_nodes(node: nodes.Node) -> Iterable[nodes.Node]: return (edge.dst for edge in graph.out_edges(node)) - # Dataflow graph is acyclic, so we do not need to keep a list of - # what we have visited. + # Track visited nodes to avoid exponential blowup from visiting + # the same node multiple times via different paths in the DAG. to_visit: List[nodes.Node] = list(next_nodes(begin)) + visited: Set[nodes.Node] = set() while len(to_visit) > 0: node = to_visit.pop() + if node in visited: + continue + visited.add(node) if isinstance(node, nodes.AccessNode) and node.data == data: return True to_visit.extend(next_nodes(node))