Skip to content

Commit

Permalink
Fix delegate debug handle generation (#6134)
Browse files Browse the repository at this point in the history
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
(cherry picked from commit aad548c)

Co-authored-by: Tarun Karuturi <[email protected]>
  • Loading branch information
pytorchbot and tarun292 authored Oct 11, 2024
1 parent edb43d8 commit eca44f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions exir/backend/backend_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ def _partition_and_lower_one_graph_module(
call_delegate_args.append(inp_node)
break

def generate_debug_handle(ep: ExportedProgram) -> int:
"""
Generate a debug handle for the given ExportedProgram.
"""
debug_handle = 0
for node in ep.graph_module.graph.nodes:
debug_handle = max(debug_handle, node.meta.get("debug_handle", 0))
return debug_handle + 1

# Replace the partitioned submodule with a lowered submodule
# Add call_method node with function "forward"
with tagged_graph_module.graph.inserting_before(call_module_node):
Expand All @@ -273,8 +282,8 @@ def _partition_and_lower_one_graph_module(
(lowered_node,) + tuple(call_delegate_args),
call_module_node.kwargs,
)
call_delegate_node.meta["debug_handle"] = len(
tagged_graph_module.graph.nodes
call_delegate_node.meta["debug_handle"] = generate_debug_handle(
owning_program
)
call_delegate_node.meta["val"] = submodule_output_node.meta["val"]
call_module_node.replace_all_uses_with(call_delegate_node)
Expand Down

0 comments on commit eca44f0

Please sign in to comment.