Skip to content

Commit aad548c

Browse files
tarun292facebook-github-bot
authored andcommitted
Fix delegate debug handle generation (#5953)
Summary: Pull Request resolved: #5953 Improve the logic used to generate a debug handle for delegate nodes. The existing logic is causing conflicts with other nodes debug handles. Reviewed By: Olivia-liu Differential Revision: D63779522 fbshipit-source-id: ff1583ee21bf05748c91a1c8b8e489996f80d7d9
1 parent 0424eef commit aad548c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

exir/backend/backend_api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ def _partition_and_lower_one_graph_module(
261261
call_delegate_args.append(inp_node)
262262
break
263263

264+
def generate_debug_handle(ep: ExportedProgram) -> int:
265+
"""
266+
Generate a debug handle for the given ExportedProgram.
267+
"""
268+
debug_handle = 0
269+
for node in ep.graph_module.graph.nodes:
270+
debug_handle = max(debug_handle, node.meta.get("debug_handle", 0))
271+
return debug_handle + 1
272+
264273
# Replace the partitioned submodule with a lowered submodule
265274
# Add call_method node with function "forward"
266275
with tagged_graph_module.graph.inserting_before(call_module_node):
@@ -273,8 +282,8 @@ def _partition_and_lower_one_graph_module(
273282
(lowered_node,) + tuple(call_delegate_args),
274283
call_module_node.kwargs,
275284
)
276-
call_delegate_node.meta["debug_handle"] = len(
277-
tagged_graph_module.graph.nodes
285+
call_delegate_node.meta["debug_handle"] = generate_debug_handle(
286+
owning_program
278287
)
279288
call_delegate_node.meta["val"] = submodule_output_node.meta["val"]
280289
call_module_node.replace_all_uses_with(call_delegate_node)

0 commit comments

Comments
 (0)