Skip to content

[Profiling] Add python scripts to generate per-op profiling from etdumps #13302

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pip-out/
# Any exported models and profiling outputs
*.bin
*.model
*.etdump
tokenizer.json
*.pte
*.ptd
Expand Down Expand Up @@ -58,6 +59,7 @@ xcuserdata/
/include/
/share/
/version.py
*.csv

# Android
*.aar
47 changes: 47 additions & 0 deletions devtools/scripts/generate_profiling_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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):

inspector = Inspector(etdump_path)
df = inspector.to_dataframe()
df.to_csv(output)


def main():
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()
Loading