forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qnn_intermediate_output_inspector.py
52 lines (44 loc) · 1.71 KB
/
qnn_intermediate_output_inspector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 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 argparse
from executorch.devtools import Inspector
def main(args):
# Create an Inspector instance with etdump and the debug buffer.
inspector = Inspector(
etdump_path=args.etdump_path,
etrecord=args.etrecord_path,
debug_buffer_path=args.debug_buffer_path,
)
# Accessing intermediate outputs from each event (an event here is essentially an instruction that executed in the runtime).
for event_block in inspector.event_blocks:
if event_block.name == "Execute":
for event in event_block.events:
# If user enables profiling and dump intermediate outputs the same time, we need to skip the profiling event
if event.perf_data is not None and event.is_delegated_op:
continue
print("Event Name: ", event.name)
print(event.debug_data)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--etdump_path",
required=True,
help="Provide an ETDump file path. File extension should be .etdp",
)
parser.add_argument(
"--etrecord_path",
required=False,
default=None,
help="Provide an optional ETRecord file path. File extension should be .bin",
)
parser.add_argument(
"--debug_buffer_path",
required=False,
default=None,
help="Provide an optional debug buffer file path. File extension should be .bin",
)
args = parser.parse_args()
main(args)