forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_profiling_csv.py
More file actions
62 lines (49 loc) · 1.63 KB
/
Copy pathgenerate_profiling_csv.py
File metadata and controls
62 lines (49 loc) · 1.63 KB
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
53
54
55
56
57
58
59
60
61
62
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright 2024-25 Arm Limited and/or its affiliates.
# 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 generate_csv(etdump_path, output):
"""
Generate a CSV file from ETDump profiling data.
Args:
etdump_path (str): Path to the ETDump file generated by executor_runner
output (str): Path for the output CSV file
"""
inspector = Inspector(etdump_path)
df = inspector.to_dataframe()
df.to_csv(output)
def main():
"""
Main function to parse command line arguments and generate profiling CSV.
Usage:
python generate_profiling_csv.py --etdump_path="my_etdump" --output="profiling.csv"
Example:
python generate_profiling_csv.py --etdump_path="llama3_etdump" --output="op_profiling.csv"
"""
parser = argparse.ArgumentParser(
description="Generate profiling CSV from a model's etdump"
)
parser.add_argument(
"--etdump_path",
type=str,
default="./model.etdump",
help="Path to the etdump file",
required=False,
)
parser.add_argument(
"--output",
type=str,
default="./model_profiling.csv",
help="Path to the output CSV file",
required=False,
)
args = parser.parse_args()
print(f"Generating CSV from {args.etdump_path}")
generate_csv(args.etdump_path, args.output)
print(f"Saved CSV to {args.output}")
if __name__ == "__main__":
main()