Skip to content

Commit

Permalink
Merge pull request #127 from lstasytis/fix/avoid-mp-pool-with-one-worker
Browse files Browse the repository at this point in the history
Avoiding mp.Pool in case of using only 1 worker for easier pdb debugging
  • Loading branch information
maltanar authored Aug 13, 2024
2 parents c4c16f7 + 3835a37 commit 2281a77
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/qonnx/transformation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ def apply(self, model):
old_nodes.append(model.graph.node.pop())

# Execute transformation in parallel
with mp.Pool(self._num_workers) as p:
new_nodes_and_bool = p.map(self.applyNodeLocal, old_nodes, chunksize=1)
if self._num_workers > 1:
with mp.Pool(self._num_workers) as p:
new_nodes_and_bool = p.map(self.applyNodeLocal, old_nodes, chunksize=1)
# execute without mp.Pool in case of 1 worker to simplify debugging
else:
new_nodes_and_bool = [self.applyNodeLocal(node) for node in old_nodes]

# extract nodes and check if the transformation needs to run again
# Note: .pop() had initially reversed the node order
Expand Down

0 comments on commit 2281a77

Please sign in to comment.