Skip to content

Commit 786d786

Browse files
committed
[backend_api] Delete partitioner tags after lowering
There was a slight bug i found when lowering with: XnnpackDynamicallyQuantizedPartitioner --> XnnpackPartitioner. The issue arrises because the second time we partition, delegation tags from the previous partitioner still exist. Specifically they exist on the getitem node because the metadata was propagated. See: https://github.com/pytorch/pytorch/blob/main/torch/fx/passes/utils/fuser_utils.py#L235 Since the getitem nodes created in by the XnnpackDynamicallyQuantizedPartitioner still have the delegation tags, they sneak into partitions from XnnpackPartitioner. This shouldn't happen because delegation tags from previous Partitioner should not exist after the previous lowering. We update the code in to_backend here to erase all the "delegation_tags" from node.meta after we've performed all `_partition_and_lower` Differential Revision: [D71518362](https://our.internmc.facebook.com/intern/diff/D71518362/) [ghstack-poisoned]
1 parent ea43453 commit 786d786

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

exir/backend/backend_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ def to_backend(
401401
tagged_exported_program,
402402
)
403403

404+
# Partitioner added delegation tags to the graph module nodes,
405+
# we make sure to remove them after we finished partition_and_lower
406+
for node in tagged_graph_module.graph.nodes:
407+
if "delegation_tag" in node.meta:
408+
del node.meta["delegation_tag"]
409+
404410
return ExportedProgram(
405411
root=tagged_graph_module,
406412
graph=tagged_graph_module.graph,

0 commit comments

Comments
 (0)