From dc58c0f19a2a6d83f9df8267d33ef94ad3bcdbe8 Mon Sep 17 00:00:00 2001 From: Joyesh Mishra Date: Thu, 29 Sep 2022 15:17:57 -0700 Subject: [PATCH] Fixes a bug in network compilation and multiple port polling --- src/lava/magma/compiler/compiler_graphs.py | 8 ++++++-- .../runtime_services/channel_broker/channel_broker.py | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lava/magma/compiler/compiler_graphs.py b/src/lava/magma/compiler/compiler_graphs.py index c9148bf4d..15ab39efa 100644 --- a/src/lava/magma/compiler/compiler_graphs.py +++ b/src/lava/magma/compiler/compiler_graphs.py @@ -232,8 +232,7 @@ def is_dag(self, graph: 'DiGraphBase' = None) -> ty.Tuple[bool, graph.annotate_digraph_by_degree() leaves = [node for node, nodeattr in graph.nodes.items() if - nodeattr['degdef'] == NodeAnnotation.PUREOUT or nodeattr[ - 'degdef'] == NodeAnnotation.PUREIN] + nodeattr['degdef'] == NodeAnnotation.PUREIN] num_leaves = len(leaves) if num_leaves > 0: @@ -242,6 +241,11 @@ def is_dag(self, graph: 'DiGraphBase' = None) -> ty.Tuple[bool, _, graph = self.is_dag(graph) if len(list(graph.nodes)) > 1: + isolated_nodes = \ + [node for node, nodeattr in graph.nodes.items() if nodeattr[ + 'degdef'] == NodeAnnotation.ISOLATED] + if len(list(graph.nodes)) == len(isolated_nodes): + return True, graph return False, graph else: return True, graph diff --git a/src/lava/magma/runtime/runtime_services/channel_broker/channel_broker.py b/src/lava/magma/runtime/runtime_services/channel_broker/channel_broker.py index f00616f35..70223a306 100644 --- a/src/lava/magma/runtime/runtime_services/channel_broker/channel_broker.py +++ b/src/lava/magma/runtime/runtime_services/channel_broker/channel_broker.py @@ -147,7 +147,8 @@ def poll_c_inports(self): channel_actions = [] for cport, channel in self.c_inports_to_poll.items(): result = (cport, channel) - channel_actions.append((cport.csp_ports[0], lambda: result)) + channel_actions.append((cport.csp_ports[0], + (lambda y: (lambda: y))(result))) channel_actions.append((self.mgmt_channel.dst_port, lambda: ('stop', None)))