Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated partitioning function for PartitionFromDict #113

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/qonnx/transformation/create_generic_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ def __init__(self, partitioning={}, partition_dir=None):
def apply(self, model):
# prepare node -> int assignment fct.
def partitioning_func(node):
partition_id = -1
for key in self.partitioning:
if node in list(model.graph.node) and list(model.graph.node).index(node) in list(self.partitioning[key]):
assert partition_id == -1, """single node assigned to multiple partitions"""
partition_id = key

return partition_id
if node not in model.graph.node:
return -1
node_index = list(model.graph.node).index(node)
candidates = list(filter(lambda key_value: node_index in key_value[1], self.partitioning.items()))
if len(candidates) == 0:
return -1
assert len(candidates) == 1, f"single node assigned to multiple partitions: {candidates}"
return candidates[0][0] # partition_id

# apply partitioning
model = model.transform(PartitionFromLambda(partitioning_func, self.partition_dir))
Expand Down
Loading