-
Notifications
You must be signed in to change notification settings - Fork 788
Qualcomm AI Engine Direct - Support Debug Handle and Integrate IntermediateOutputCapturer #16316
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright (c) Qualcomm Innovation Center, Inc. | ||
| # All rights reserved | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| import operator | ||
|
|
||
| import torch | ||
| from executorch.exir.debug_handle_utils import DEBUG_HANDLE_KEY | ||
| from executorch.exir.pass_base import ExportPass, PassResult | ||
|
|
||
|
|
||
| class ResolveDebugHandle(ExportPass): | ||
| """ | ||
| Caution: This pass is executed as the last of the edge_passes. | ||
| For any passes executed during qnn_preprocess, users will need to handle debug_handle ID themselves. | ||
|
|
||
| Description: During passes transformation, some passes might be copying some node's meta when creating a new node, | ||
| which means multiple nodes might be sharing the same debug_handle ID while it shouldn't. | ||
| This is critical as Intermediate Debugger uses debug handle as key. | ||
| debug_handle ID must be resolved so each op gets its own set of debug_handle ID and intermediate output. | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| super(ResolveDebugHandle, self).__init__() | ||
|
|
||
| def call(self, graph_module: torch.fx.GraphModule): | ||
| handle_counter = 1 | ||
| visited = set() | ||
| for node in graph_module.graph.nodes: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if Qualcomm can handle conditional graph. If so i think the way you are adding debug handle might not able to equip debug handle to all branches. You can follow what i'm doing here:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to confirm on definition of conditional graph. Initially, I thought we can't have conditional graph (e.g., |
||
| # Assume node is traversed in topological order, adding a check here to be safe. | ||
| if node.target == operator.getitem: | ||
| source_node = node.args[0] | ||
| assert ( | ||
| source_node.name in visited | ||
| ), "Graph is not traversed in topological order, unexpected behavior." | ||
| node.meta[DEBUG_HANDLE_KEY] = source_node.meta[DEBUG_HANDLE_KEY] | ||
| elif node.op == "call_function": | ||
| node.meta[DEBUG_HANDLE_KEY] = handle_counter | ||
| handle_counter += 1 | ||
| visited.add(node.name) | ||
|
|
||
| graph_module.recompile() | ||
| return PassResult(graph_module, True) | ||
Uh oh!
There was an error while loading. Please reload this page.