未验证 提交 b25c6b01 编写于 作者: H hysunflower 提交者: GitHub

add profiler for models (#204)

* add profiler for models
上级 3ce0777a
...@@ -31,6 +31,7 @@ import functools ...@@ -31,6 +31,7 @@ import functools
import paddle import paddle
import numpy as np import numpy as np
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid import profiler
from utils.config import cfg from utils.config import cfg
from utils.timer import Timer, calculate_eta from utils.timer import Timer, calculate_eta
...@@ -102,6 +103,18 @@ def parse_args(): ...@@ -102,6 +103,18 @@ def parse_args():
help='If set True, enable continuous evaluation job.' help='If set True, enable continuous evaluation job.'
'This flag is only used for internal test.', 'This flag is only used for internal test.',
action='store_true') action='store_true')
# NOTE: This for benchmark
parser.add_argument(
'--is_profiler',
help='the profiler switch.(used for benchmark)',
default=0,
type=int)
parser.add_argument(
'--profiler_path',
help='the profiler output file path.(used for benchmark)',
default='./seg.profiler',
type=str)
return parser.parse_args() return parser.parse_args()
...@@ -442,6 +455,13 @@ def train(cfg): ...@@ -442,6 +455,13 @@ def train(cfg):
avg_loss = 0.0 avg_loss = 0.0
timer.restart() timer.restart()
# NOTE : used for benchmark, profiler tools
if args.is_profiler and epoch == 1 and global_step == args.log_steps:
profiler.start_profiler("All")
elif args.is_profiler and epoch == 1 and global_step == args.log_steps + 5:
profiler.stop_profiler("total", args.profiler_path)
return
except fluid.core.EOFException: except fluid.core.EOFException:
py_reader.reset() py_reader.reset()
break break
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册