diff --git a/.gitignore b/.gitignore index 08d14e13582..fbf5b4f5d40 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ pip-out/ # Any exported models and profiling outputs *.bin *.model +*.etdump tokenizer.json *.pte *.ptd @@ -58,6 +59,7 @@ xcuserdata/ /include/ /share/ /version.py +*.csv # Android *.aar diff --git a/devtools/scripts/generate_profiling_csv.py b/devtools/scripts/generate_profiling_csv.py new file mode 100644 index 00000000000..a61d3ece69d --- /dev/null +++ b/devtools/scripts/generate_profiling_csv.py @@ -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()