Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
9ba585f5
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9ba585f5
编写于
6月 22, 2020
作者:
T
Tao Luo
提交者:
GitHub
6月 22, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix PE in test_profiler.py (#25144)
上级
19c4db1b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
9 addition
and
15 deletion
+9
-15
python/paddle/fluid/tests/unittests/test_profiler.py
python/paddle/fluid/tests/unittests/test_profiler.py
+9
-15
未找到文件。
python/paddle/fluid/tests/unittests/test_profiler.py
浏览文件 @
9ba585f5
...
...
@@ -94,17 +94,13 @@ class TestProfiler(unittest.TestCase):
event
.
name
.
startswith
(
"Runtime API"
)):
print
(
"Warning: unregister"
,
event
.
name
)
def
run_iter
(
self
,
exe
,
main_program
,
fetch_list
,
pass_acc_calculator
):
def
run_iter
(
self
,
exe
,
main_program
,
fetch_list
):
x
=
np
.
random
.
random
((
32
,
784
)).
astype
(
"float32"
)
y
=
np
.
random
.
randint
(
0
,
10
,
(
32
,
1
)).
astype
(
"int64"
)
outs
=
exe
.
run
(
main_program
,
feed
=
{
'x'
:
x
,
'y'
:
y
},
fetch_list
=
fetch_list
)
acc
=
np
.
array
(
outs
[
1
])
b_size
=
np
.
array
(
outs
[
2
])
pass_acc_calculator
.
add
(
value
=
acc
,
weight
=
b_size
)
pass_acc
=
pass_acc_calculator
.
eval
()
def
net_profiler
(
self
,
exe
,
...
...
@@ -120,13 +116,11 @@ class TestProfiler(unittest.TestCase):
profile_path
=
self
.
get_profile_path
()
if
not
use_new_api
:
with
profiler
.
profiler
(
state
,
'total'
,
profile_path
,
tracer_option
):
pass_acc_calculator
=
fluid
.
average
.
WeightedAverage
()
for
iter
in
range
(
10
):
if
iter
==
2
:
profiler
.
reset_profiler
()
self
.
run_iter
(
exe
,
main_program
,
[
avg_cost
,
batch_acc
,
batch_size
],
pass_acc_calculator
)
[
avg_cost
,
batch_acc
,
batch_size
])
else
:
options
=
utils
.
ProfilerOptions
(
options
=
{
'state'
:
state
,
...
...
@@ -136,11 +130,9 @@ class TestProfiler(unittest.TestCase):
'profile_path'
:
profile_path
})
with
utils
.
Profiler
(
enabled
=
True
,
options
=
options
)
as
prof
:
pass_acc_calculator
=
fluid
.
average
.
WeightedAverage
()
for
iter
in
range
(
10
):
self
.
run_iter
(
exe
,
main_program
,
[
avg_cost
,
batch_acc
,
batch_size
],
pass_acc_calculator
)
[
avg_cost
,
batch_acc
,
batch_size
])
utils
.
get_profiler
().
record_step
()
if
batch_range
is
None
and
iter
==
2
:
utils
.
get_profiler
().
reset
()
...
...
@@ -156,7 +148,7 @@ class TestProfiler(unittest.TestCase):
"Default"
,
batch_range
=
[
5
,
10
],
use_new_api
=
use_new_api
)
#self.net_profiler(
'CPU', "Default", use_parallel_executor=True)
self
.
net_profiler
(
exe
,
'CPU'
,
"Default"
,
use_parallel_executor
=
True
)
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
(),
"profiler is enabled only with GPU"
)
...
...
@@ -167,9 +159,10 @@ class TestProfiler(unittest.TestCase):
exe
,
'GPU'
,
"OpDetail"
,
batch_range
=
[
0
,
10
0
],
batch_range
=
[
0
,
10
],
use_new_api
=
use_new_api
)
#self.net_profiler('GPU', "OpDetail", use_parallel_executor=True)
self
.
net_profiler
(
exe
,
'GPU'
,
"OpDetail"
,
use_parallel_executor
=
True
)
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
(),
"profiler is enabled only with GPU"
)
...
...
@@ -182,7 +175,8 @@ class TestProfiler(unittest.TestCase):
"AllOpDetail"
,
batch_range
=
None
,
use_new_api
=
use_new_api
)
#self.net_profiler('All', "AllOpDetail", use_parallel_executor=True)
self
.
net_profiler
(
exe
,
'All'
,
"AllOpDetail"
,
use_parallel_executor
=
True
)
class
TestProfilerAPIError
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录