Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
259c0ca9
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
259c0ca9
编写于
6月 01, 2023
作者:
M
mmglove
提交者:
cuicheng01
6月 05, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix profiler
上级
b795b674
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
23 addition
and
9 deletion
+23
-9
ppcls/utils/profiler.py
ppcls/utils/profiler.py
+23
-9
未找到文件。
ppcls/utils/profiler.py
浏览文件 @
259c0ca9
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
import
sys
import
sys
import
paddle
import
paddle
import
paddle.profiler
as
profiler
# A global variable to record the number of calling times for profiler
# A global variable to record the number of calling times for profiler
# functions. It is used to specify the tracing range of training steps.
# functions. It is used to specify the tracing range of training steps.
...
@@ -21,7 +22,7 @@ _profiler_step_id = 0
...
@@ -21,7 +22,7 @@ _profiler_step_id = 0
# A global variable to avoid parsing from string every time.
# A global variable to avoid parsing from string every time.
_profiler_options
=
None
_profiler_options
=
None
_prof
=
None
class
ProfilerOptions
(
object
):
class
ProfilerOptions
(
object
):
'''
'''
...
@@ -85,7 +86,6 @@ def add_profiler_step(options_str=None):
...
@@ -85,7 +86,6 @@ def add_profiler_step(options_str=None):
Enable the operator-level timing using PaddlePaddle's profiler.
Enable the operator-level timing using PaddlePaddle's profiler.
The profiler uses a independent variable to count the profiler steps.
The profiler uses a independent variable to count the profiler steps.
One call of this function is treated as a profiler step.
One call of this function is treated as a profiler step.
Args:
Args:
profiler_options - a string to initialize the ProfilerOptions.
profiler_options - a string to initialize the ProfilerOptions.
Default is None, and the profiler is disabled.
Default is None, and the profiler is disabled.
...
@@ -93,18 +93,32 @@ def add_profiler_step(options_str=None):
...
@@ -93,18 +93,32 @@ def add_profiler_step(options_str=None):
if
options_str
is
None
:
if
options_str
is
None
:
return
return
global
_prof
global
_profiler_step_id
global
_profiler_step_id
global
_profiler_options
global
_profiler_options
if
_profiler_options
is
None
:
if
_profiler_options
is
None
:
_profiler_options
=
ProfilerOptions
(
options_str
)
_profiler_options
=
ProfilerOptions
(
options_str
)
# profile 3个纬度打印性能数据 https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/performance_improving/profiling_model.html#chakanxingnengshujudetongjibiaodan
if
_profiler_step_id
==
_profiler_options
[
'batch_range'
][
0
]:
# timer_only = True 仅展示模型的吞吐量以及时间开销
paddle
.
utils
.
profiler
.
start_profiler
(
# timer_only = False 调用 summary 能够打印统计表单,通过不同角度的表单呈现性能数据
_profiler_options
[
'state'
],
_profiler_options
[
'tracer_option'
])
# timer_only = False 同时产出Timeline 信息在 profiler_log目录下
elif
_profiler_step_id
==
_profiler_options
[
'batch_range'
][
1
]:
if
_prof
is
None
:
paddle
.
utils
.
profiler
.
stop_profiler
(
_profiler_options
[
'sorted_key'
],
_prof
=
profiler
.
Profiler
(
_profiler_options
[
'profile_path'
])
scheduler
=
(
_profiler_options
[
'batch_range'
][
0
],
_profiler_options
[
'batch_range'
][
1
]),
on_trace_ready
=
profiler
.
export_chrome_tracing
(
'./profiler_log'
),
timer_only
=
True
)
_prof
.
start
()
else
:
_prof
.
step
()
if
_profiler_step_id
==
_profiler_options
[
'batch_range'
][
1
]:
_prof
.
stop
()
_prof
.
summary
(
op_detail
=
True
,
thread_sep
=
False
,
time_unit
=
'ms'
)
_prof
=
None
if
_profiler_options
[
'exit_on_finished'
]:
if
_profiler_options
[
'exit_on_finished'
]:
sys
.
exit
(
0
)
sys
.
exit
(
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录