Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a7b13d38
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看板
未验证
提交
a7b13d38
编写于
1月 04, 2022
作者:
W
Weilong Wu
提交者:
GitHub
1月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support test_imperative container_sequential and signal_handler with eager_guard (#38614)
上级
30be9317
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
7 deletion
+39
-7
python/paddle/fluid/tests/unittests/test_imperative_container_sequential.py
...d/tests/unittests/test_imperative_container_sequential.py
+13
-2
python/paddle/fluid/tests/unittests/test_imperative_signal_handler.py
...e/fluid/tests/unittests/test_imperative_signal_handler.py
+26
-5
未找到文件。
python/paddle/fluid/tests/unittests/test_imperative_container_sequential.py
浏览文件 @
a7b13d38
...
...
@@ -17,10 +17,11 @@ from __future__ import print_function
import
unittest
import
paddle.fluid
as
fluid
import
numpy
as
np
from
paddle.fluid.framework
import
_test_eager_guard
class
TestImperativeContainerSequential
(
unittest
.
TestCase
):
def
test
_sequential
(
self
):
def
func
_sequential
(
self
):
data
=
np
.
random
.
uniform
(
-
1
,
1
,
[
5
,
10
]).
astype
(
'float32'
)
with
fluid
.
dygraph
.
guard
():
data
=
fluid
.
dygraph
.
to_variable
(
data
)
...
...
@@ -55,7 +56,12 @@ class TestImperativeContainerSequential(unittest.TestCase):
loss2
=
fluid
.
layers
.
reduce_mean
(
res2
)
loss2
.
backward
()
def
test_sequential_list_params
(
self
):
def
test_sequential
(
self
):
with
_test_eager_guard
():
self
.
func_sequential
()
self
.
func_sequential
()
def
func_sequential_list_params
(
self
):
data
=
np
.
random
.
uniform
(
-
1
,
1
,
[
5
,
10
]).
astype
(
'float32'
)
with
fluid
.
dygraph
.
guard
():
data
=
fluid
.
dygraph
.
to_variable
(
data
)
...
...
@@ -90,6 +96,11 @@ class TestImperativeContainerSequential(unittest.TestCase):
loss2
=
fluid
.
layers
.
reduce_mean
(
res2
)
loss2
.
backward
()
def
test_sequential_list_params
(
self
):
with
_test_eager_guard
():
self
.
func_sequential_list_params
()
self
.
func_sequential_list_params
()
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_imperative_signal_handler.py
浏览文件 @
a7b13d38
...
...
@@ -21,6 +21,7 @@ import time
import
paddle.compat
as
cpt
from
paddle.fluid
import
core
from
paddle.fluid.framework
import
_test_eager_guard
def
set_child_signal_handler
(
self
,
child_pid
):
...
...
@@ -37,8 +38,8 @@ def set_child_signal_handler(self, child_pid):
signal
.
signal
(
signal
.
SIGCHLD
,
__handler__
)
class
Test
DygraphDataLoaderSingalHandler
(
unittest
.
TestCase
):
def
test
_child_process_exit_with_error
(
self
):
class
DygraphDataLoaderSingalHandler
(
unittest
.
TestCase
):
def
func
_child_process_exit_with_error
(
self
):
def
__test_process__
():
core
.
_set_process_signal_handler
()
sys
.
exit
(
1
)
...
...
@@ -65,7 +66,12 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
self
.
assertIsNotNone
(
exception
)
def
test_child_process_killed_by_sigsegv
(
self
):
def
test_child_process_exit_with_error
(
self
):
with
_test_eager_guard
():
self
.
func_child_process_exit_with_error
()
self
.
func_child_process_exit_with_error
()
def
func_child_process_killed_by_sigsegv
(
self
):
def
__test_process__
():
core
.
_set_process_signal_handler
()
os
.
kill
(
os
.
getpid
(),
signal
.
SIGSEGV
)
...
...
@@ -93,7 +99,12 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
self
.
assertIsNotNone
(
exception
)
def
test_child_process_killed_by_sigbus
(
self
):
def
test_child_process_killed_by_sigsegv
(
self
):
with
_test_eager_guard
():
self
.
func_child_process_killed_by_sigsegv
()
self
.
func_child_process_killed_by_sigsegv
()
def
func_child_process_killed_by_sigbus
(
self
):
def
__test_process__
():
core
.
_set_process_signal_handler
()
os
.
kill
(
os
.
getpid
(),
signal
.
SIGBUS
)
...
...
@@ -120,7 +131,12 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
self
.
assertIsNotNone
(
exception
)
def
test_child_process_killed_by_sigterm
(
self
):
def
test_child_process_killed_by_sigbus
(
self
):
with
_test_eager_guard
():
self
.
func_child_process_killed_by_sigbus
()
self
.
func_child_process_killed_by_sigbus
()
def
func_child_process_killed_by_sigterm
(
self
):
def
__test_process__
():
core
.
_set_process_signal_handler
()
time
.
sleep
(
10
)
...
...
@@ -132,6 +148,11 @@ class TestDygraphDataLoaderSingalHandler(unittest.TestCase):
set_child_signal_handler
(
id
(
self
),
test_process
.
pid
)
time
.
sleep
(
1
)
def
test_child_process_killed_by_sigterm
(
self
):
with
_test_eager_guard
():
self
.
func_child_process_killed_by_sigterm
()
self
.
func_child_process_killed_by_sigterm
()
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录