Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
9bea834e
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看板
未验证
提交
9bea834e
编写于
9月 17, 2020
作者:
G
guofei
提交者:
GitHub
9月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine the unittest to support py38 (#27208)
* Refine the unittest to support py38 test=develop
上级
a7fadce8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
4 deletion
+18
-4
python/paddle/fluid/tests/unittests/test_device_guard.py
python/paddle/fluid/tests/unittests/test_device_guard.py
+16
-2
python/paddle/fluid/tests/unittests/test_gather_op.py
python/paddle/fluid/tests/unittests/test_gather_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_save_model_without_var.py
...ddle/fluid/tests/unittests/test_save_model_without_var.py
+1
-1
未找到文件。
python/paddle/fluid/tests/unittests/test_device_guard.py
浏览文件 @
9bea834e
...
@@ -33,6 +33,14 @@ def execute(main_program, startup_program):
...
@@ -33,6 +33,14 @@ def execute(main_program, startup_program):
exe
.
run
(
main_program
)
exe
.
run
(
main_program
)
def
get_vaild_warning_num
(
warning
,
w
):
num
=
0
for
i
in
range
(
len
(
w
)):
if
warning
in
str
(
w
[
i
].
message
):
num
+=
1
return
num
class
TestDeviceGuard
(
unittest
.
TestCase
):
class
TestDeviceGuard
(
unittest
.
TestCase
):
def
test_device_guard
(
self
):
def
test_device_guard
(
self
):
main_program
=
fluid
.
Program
()
main_program
=
fluid
.
Program
()
...
@@ -133,7 +141,10 @@ class TestDeviceGuard(unittest.TestCase):
...
@@ -133,7 +141,10 @@ class TestDeviceGuard(unittest.TestCase):
i
=
fluid
.
layers
.
increment
(
x
=
i
,
value
=
1
,
in_place
=
True
)
i
=
fluid
.
layers
.
increment
(
x
=
i
,
value
=
1
,
in_place
=
True
)
fluid
.
layers
.
less_than
(
x
=
i
,
y
=
loop_len
,
cond
=
cond
)
fluid
.
layers
.
less_than
(
x
=
i
,
y
=
loop_len
,
cond
=
cond
)
assert
len
(
w
)
==
1
warning
=
"The Op(while) is not support to set device."
warning_num
=
get_vaild_warning_num
(
warning
,
w
)
assert
warning_num
==
1
all_ops
=
main_program
.
global_block
().
ops
all_ops
=
main_program
.
global_block
().
ops
device_attr_name
=
core
.
op_proto_and_checker_maker
.
kOpDeviceAttrName
()
device_attr_name
=
core
.
op_proto_and_checker_maker
.
kOpDeviceAttrName
()
for
op
in
all_ops
:
for
op
in
all_ops
:
...
@@ -169,7 +180,10 @@ class TestDeviceGuard(unittest.TestCase):
...
@@ -169,7 +180,10 @@ class TestDeviceGuard(unittest.TestCase):
shape
=
[
1
],
value
=
4.0
,
dtype
=
'float32'
)
shape
=
[
1
],
value
=
4.0
,
dtype
=
'float32'
)
result
=
fluid
.
layers
.
less_than
(
x
=
x
,
y
=
y
,
force_cpu
=
False
)
result
=
fluid
.
layers
.
less_than
(
x
=
x
,
y
=
y
,
force_cpu
=
False
)
assert
len
(
w
)
==
2
warning
=
"
\'
device_guard
\'
has higher priority when they are used at the same time."
warning_num
=
get_vaild_warning_num
(
warning
,
w
)
assert
warning_num
==
2
all_ops
=
main_program
.
global_block
().
ops
all_ops
=
main_program
.
global_block
().
ops
device_attr_name
=
core
.
op_proto_and_checker_maker
.
kOpDeviceAttrName
()
device_attr_name
=
core
.
op_proto_and_checker_maker
.
kOpDeviceAttrName
()
for
op
in
all_ops
:
for
op
in
all_ops
:
...
...
python/paddle/fluid/tests/unittests/test_gather_op.py
浏览文件 @
9bea834e
...
@@ -216,7 +216,7 @@ class API_TestGather(unittest.TestCase):
...
@@ -216,7 +216,7 @@ class API_TestGather(unittest.TestCase):
"index"
:
index_np
,
"index"
:
index_np
,
'axis'
:
axis_np
},
'axis'
:
axis_np
},
fetch_list
=
[
out
])
fetch_list
=
[
out
])
expected_output
=
gather_numpy
(
x_np
,
index_np
,
axis_np
)
expected_output
=
gather_numpy
(
x_np
,
index_np
,
axis_np
[
0
]
)
self
.
assertTrue
(
np
.
allclose
(
result
,
expected_output
))
self
.
assertTrue
(
np
.
allclose
(
result
,
expected_output
))
...
...
python/paddle/fluid/tests/unittests/test_save_model_without_var.py
浏览文件 @
9bea834e
...
@@ -50,7 +50,7 @@ class TestSaveModelWithoutVar(unittest.TestCase):
...
@@ -50,7 +50,7 @@ class TestSaveModelWithoutVar(unittest.TestCase):
params_filename
=
'params'
)
params_filename
=
'params'
)
expected_warn
=
"no variable in your model, please ensure there are any variables in your model to save"
expected_warn
=
"no variable in your model, please ensure there are any variables in your model to save"
self
.
assertTrue
(
len
(
w
)
>
0
)
self
.
assertTrue
(
len
(
w
)
>
0
)
self
.
assertTrue
(
expected_warn
==
str
(
w
[
0
].
message
))
self
.
assertTrue
(
expected_warn
==
str
(
w
[
-
1
].
message
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录