提交 f087880c 编写于 作者: H hysunflower 提交者: Jinhua Liang

Add profiler and maxiter for detection models (#3919)

* add max_iters and profiler for detection models

* update for detection models
上级 88285989
......@@ -36,6 +36,7 @@ set_paddle_flags(
)
from paddle import fluid
from paddle.fluid import profiler
from ppdet.experimental import mixed_precision_context
from ppdet.core.workspace import load_config, merge_config, create
......@@ -258,6 +259,13 @@ def main():
it, np.mean(outs[-1]), logs, time_cost, eta)
logger.info(strs)
# profiler tools, used for benchmark
if FLAGS.is_profiler and it == 5:
profiler.start_profiler("All")
elif FLAGS.is_profiler and it == 10:
profiler.stop_profiler("total", FLAGS.profiler_path)
return
if (it > 0 and it % cfg.snapshot_iter == 0 or it == cfg.max_iters - 1) \
and (not FLAGS.dist or trainer_id == 0):
save_name = str(it) if it != cfg.max_iters - 1 else "model_final"
......@@ -334,5 +342,17 @@ if __name__ == '__main__':
type=str,
default="tb_log_dir/scalar",
help='Tensorboard logging directory for scalar.')
#NOTE:args for profiler tools, used for benchmark
parser.add_argument(
'--is_profiler',
type=int,
default=0,
help='The switch of profiler tools. (used for benchmark)')
parser.add_argument(
'--profiler_path',
type=str,
default="./",
help='The profiler output file path. (used for benchmark)')
FLAGS = parser.parse_args()
main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册