diff --git a/sinabs/backend/dynapcnn/mapping.py b/sinabs/backend/dynapcnn/mapping.py index 5fefaa0b..36c38ad4 100644 --- a/sinabs/backend/dynapcnn/mapping.py +++ b/sinabs/backend/dynapcnn/mapping.py @@ -88,6 +88,7 @@ def __repr__(self): # graph is list of list of edges. Each edge is def edmonds(graph, source, sink, verbose: bool = False): + """Use Edmonds-Karp-Algorithm to match software layers to chip layers""" graph = deepcopy(graph) flow = 0 while True: @@ -95,8 +96,8 @@ def edmonds(graph, source, sink, verbose: bool = False): q.append(source) pred = [None for _ in range(len(graph))] while len(q) != 0: - cur = q.popleft() - for edge in graph[cur]: + cur = q.popleft() # current node index + for edge in graph[cur]: # edges to/from current node if pred[edge.t] is None and edge.t != source and edge.cap > edge.flow: pred[edge.t] = edge q.append(edge.t) @@ -123,9 +124,12 @@ def edmonds(graph, source, sink, verbose: bool = False): def make_flow_graph( layer_mapping: List[List[int]], num_layers: int = 9 ) -> List[List[Edge]]: - """Make a flow graph given all possible chip layers for each DynapcnnCompatibleLayer layer. - Note that the flows are not computed yet. The flow for the graph generated here needs to be - populated by calling the method `edmonds` + """ + Make a bipartite flow graph (flow network) given all possible chip layers + for each DynapcnnLayer layer. The goal is to formulate the mapping from + software layer to chip layer as a bipartite matching problem. Note that the + flows are not computed yet. The flow for the graph generated here needs to + be populated by calling the method `edmonds` Parameters ----------