Unverified Commit 0092699f authored by GPhilo's avatar GPhilo Committed by GitHub
Browse files

[Enhancement] Improve ProfilerHook beaviour when using a relative (or empty) dir_name (#2119)

* Add default dir_name and make non-absolute dir_name relative to runner.work_dir

* Add log message and change default dir name
parent b58c84c6
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import warnings
from typing import Callable, List, Optional, Union
......@@ -131,6 +132,15 @@ class ProfilerHook(Hook):
raise ImportError('please run "pip install '
'torch-tb-profiler" to install '
'torch_tb_profiler')
if 'dir_name' not in trace_cfg:
trace_cfg['dir_name'] = osp.join(runner.work_dir,
'tf_tracing_logs')
elif not osp.isabs(trace_cfg['dir_name']):
trace_cfg['dir_name'] = osp.join(runner.work_dir,
trace_cfg['dir_name'])
runner.logger.info(
'tracing files of ProfilerHook will be saved to '
f"{trace_cfg['dir_name']}.")
_on_trace_ready = torch.profiler.tensorboard_trace_handler(
**trace_cfg)
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment