Skip to content

Commit f6bfa21

Browse files
authored
error in per-op mode
Differential Revision: D66836605 Pull Request resolved: #7209
1 parent 63870b0 commit f6bfa21

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

backends/xnnpack/partition/xnnpack_partitioner.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,30 @@ def generate_per_op_partitions(self, ep: ExportedProgram) -> List[Partition]:
8585
partitions = []
8686
matched_nodes = self.get_matched_nodes_from_configs(ep)
8787
partition_id = itertools.count()
88-
nodes_seen = set()
88+
nodes_seen = {}
8989
for match in matched_nodes:
90-
match_set = set(match)
90+
# for debug information we map the node to the string form
91+
# of the partition it belongs to
92+
match_map = dict.fromkeys(match, str(match))
9193
# We only create partitions from the first PartitionerConfig match
9294
# if a subsequent partitioner match contains the same node, we do
9395
# not create a partition for it
94-
if match_set.isdisjoint(nodes_seen):
96+
overlap = match_map.keys() & nodes_seen.keys()
97+
if len(overlap) == 0:
9598
partitions.append(
9699
Partition(
97100
id=next(partition_id),
98-
nodes=match_set,
101+
nodes=match_map.keys(),
99102
)
100103
)
101-
nodes_seen.update(match_set)
104+
nodes_seen.update(match_map)
105+
else:
106+
error_str = f"per_op mode expects no overlaps between partitions but the partition {match_map.keys()} overlaps with the following partitions:\n"
107+
for overlap_node in overlap:
108+
error_str += f"{nodes_seen[overlap_node]}\n"
109+
110+
raise RuntimeError(error_str)
111+
102112
return partitions
103113

104114

0 commit comments

Comments
 (0)