Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f14e579c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f14e579c
编写于
5月 30, 2018
作者:
X
Xin Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up
上级
cb01c594
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
2 deletion
+29
-2
paddle/fluid/platform/profiler.cc
paddle/fluid/platform/profiler.cc
+2
-2
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+1
-0
python/paddle/fluid/profiler.py
python/paddle/fluid/profiler.py
+26
-0
未找到文件。
paddle/fluid/platform/profiler.cc
浏览文件 @
f14e579c
...
@@ -235,7 +235,7 @@ void EnableProfiler(ProfilerState state) {
...
@@ -235,7 +235,7 @@ void EnableProfiler(ProfilerState state) {
return
;
return
;
}
}
g_state
=
state
;
g_state
=
state
;
{
should_send_profile_state
=
true
;
}
should_send_profile_state
=
true
;
GetDeviceTracer
()
->
Enable
();
GetDeviceTracer
()
->
Enable
();
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
if
(
g_state
==
ProfilerState
::
kCUDA
)
{
if
(
g_state
==
ProfilerState
::
kCUDA
)
{
...
@@ -460,7 +460,7 @@ void DisableProfiler(EventSortingKey sorted_key,
...
@@ -460,7 +460,7 @@ void DisableProfiler(EventSortingKey sorted_key,
tracer
->
GenProfile
(
profile_path
);
tracer
->
GenProfile
(
profile_path
);
}
}
g_state
=
ProfilerState
::
kDisabled
;
g_state
=
ProfilerState
::
kDisabled
;
{
should_send_profile_state
=
true
;
}
should_send_profile_state
=
true
;
}
}
bool
IsProfileEnabled
()
{
return
g_state
!=
ProfilerState
::
kDisabled
;
}
bool
IsProfileEnabled
()
{
return
g_state
!=
ProfilerState
::
kDisabled
;
}
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
f14e579c
...
@@ -492,6 +492,7 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -492,6 +492,7 @@ All parameter, weight, gradient are variables in Paddle.
m
.
def
(
"enable_profiler"
,
platform
::
EnableProfiler
);
m
.
def
(
"enable_profiler"
,
platform
::
EnableProfiler
);
m
.
def
(
"disable_profiler"
,
platform
::
DisableProfiler
);
m
.
def
(
"disable_profiler"
,
platform
::
DisableProfiler
);
m
.
def
(
"is_profiler_enabled"
,
platform
::
IsProfileEnabled
);
m
.
def
(
"reset_profiler"
,
platform
::
ResetProfiler
);
m
.
def
(
"reset_profiler"
,
platform
::
ResetProfiler
);
// -- python binds for parallel executor.
// -- python binds for parallel executor.
...
...
python/paddle/fluid/profiler.py
浏览文件 @
f14e579c
...
@@ -76,6 +76,15 @@ def reset_profiler():
...
@@ -76,6 +76,15 @@ def reset_profiler():
def
start_profiler
(
state
):
def
start_profiler
(
state
):
"""Enable the profiler.
Args:
state (string) : The profiling state, which should be 'CPU', 'GPU'
or 'All'. 'CPU' means only profile CPU. 'GPU' means profiling
GPU as well. 'All' also generates timeline.
"""
if
core
.
is_profiler_enabled
():
return
if
state
not
in
[
'CPU'
,
'GPU'
,
"All"
]:
if
state
not
in
[
'CPU'
,
'GPU'
,
"All"
]:
raise
ValueError
(
"The state must be 'CPU' or 'GPU' or 'All'."
)
raise
ValueError
(
"The state must be 'CPU' or 'GPU' or 'All'."
)
if
state
==
"GPU"
:
if
state
==
"GPU"
:
...
@@ -88,6 +97,23 @@ def start_profiler(state):
...
@@ -88,6 +97,23 @@ def start_profiler(state):
def
stop_profiler
(
sorted_key
=
None
,
profile_path
=
'/tmp/profile'
):
def
stop_profiler
(
sorted_key
=
None
,
profile_path
=
'/tmp/profile'
):
"""Stop the profiler.
Args:
sorted_key (string) : If None, the profiling results will be printed
in the order of first end time of events. Otherwise, the profiling
results will be sorted by the this flag. This flag should be one
of 'calls', 'total', 'max', 'min' or 'ave'.
The `calls` means sorting by the number of calls.
The `total` means sorting by the total execution time.
The `max` means sorting by the maximum execution time.
The `min` means sorting by the minimum execution time.
The `ave` means sorting by the average execution time.
profile_path (string) : If state == 'All', it will write a profile
proto output file.
"""
if
not
core
.
is_profiler_enabled
():
return
sorted_key
=
'default'
if
sorted_key
is
None
else
sorted_key
sorted_key
=
'default'
if
sorted_key
is
None
else
sorted_key
if
sorted_key
not
in
[
'default'
,
'calls'
,
'total'
,
'max'
,
'min'
,
'ave'
]:
if
sorted_key
not
in
[
'default'
,
'calls'
,
'total'
,
'max'
,
'min'
,
'ave'
]:
raise
ValueError
(
"The sorted_key must be None or in 'calls', 'total', "
raise
ValueError
(
"The sorted_key must be None or in 'calls', 'total', "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录