Skip to content

Commit f7fc54e

Browse files
briancoutinhoBrian Coutinho
andauthored
add torch output directory option in performance scripts (#15032)
* add torch output directory Signed-off-by: Brian Coutinho <[email protected]> * Apply isort and black reformatting Signed-off-by: briancoutinho <[email protected]> --------- Signed-off-by: Brian Coutinho <[email protected]> Signed-off-by: briancoutinho <[email protected]> Co-authored-by: Brian Coutinho <[email protected]> Co-authored-by: briancoutinho <[email protected]>
1 parent 55e43ed commit f7fc54e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

scripts/performance/argument_parser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ def parse_cli_args():
174174
help="Enable torch profiler. Disabled by default",
175175
action="store_true",
176176
)
177+
parser.add_argument(
178+
"-tpo",
179+
"--torch_profile_out_path",
180+
type=str,
181+
help="Path to the output file of torch profiling",
182+
required=False,
183+
default=None,
184+
)
177185
parser.add_argument(
178186
"-tb",
179187
"--tensorboard",

scripts/performance/helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,9 @@ def build_torch_profiler_plugin(args):
637637
return PyTorchProfilerPlugin(
638638
start_step=start_iter,
639639
end_step=end_iter,
640-
output_path=args.log_dir, # a subdir torch_profiles will be created here.
640+
output_path=os.environ.get(
641+
'TORCH_PROFILES_DIR', args.torch_profile_out_path
642+
), # a subdir torch_profiles will be created here.
641643
profiler_kwargs={
642644
"with_stack": os.environ.get('TORCH_PROFILER_WITH_STACK', '0') == '1',
643645
},

0 commit comments

Comments
 (0)