Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
110f769d
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看板
未验证
提交
110f769d
编写于
8月 10, 2023
作者:
W
WangZhen
提交者:
GitHub
8月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[SOT]Fix ast_only_test in paddle ci (#56081)
上级
0e2a4d57
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
31 addition
and
22 deletion
+31
-22
python/paddle/jit/dy2static/program_translator.py
python/paddle/jit/dy2static/program_translator.py
+2
-1
test/dygraph_to_static/CMakeLists.txt
test/dygraph_to_static/CMakeLists.txt
+1
-1
test/dygraph_to_static/dygraph_to_static_util.py
test/dygraph_to_static/dygraph_to_static_util.py
+23
-18
test/dygraph_to_static/test_eval_frame.py
test/dygraph_to_static/test_eval_frame.py
+1
-1
test/dygraph_to_static/test_rollback.py
test/dygraph_to_static/test_rollback.py
+4
-1
未找到文件。
python/paddle/jit/dy2static/program_translator.py
浏览文件 @
110f769d
...
@@ -422,7 +422,8 @@ class StaticFunction:
...
@@ -422,7 +422,8 @@ class StaticFunction:
# first encouter the bound function of layer and cache it.
# first encouter the bound function of layer and cache it.
new_static_layer
=
self
.
_clone
()
new_static_layer
=
self
.
_clone
()
if
(
if
(
self
.
_dygraph_function
.
__name__
isinstance
(
instance
,
layers
.
Layer
)
and
self
.
_dygraph_function
.
__name__
not
in
instance
.
_original_funcs
.
keys
()
not
in
instance
.
_original_funcs
.
keys
()
):
):
instance
.
_original_funcs
[
instance
.
_original_funcs
[
...
...
test/dygraph_to_static/CMakeLists.txt
浏览文件 @
110f769d
...
@@ -74,7 +74,7 @@ set_tests_properties(test_yolov3 PROPERTIES TIMEOUT 900 LABELS
...
@@ -74,7 +74,7 @@ set_tests_properties(test_yolov3 PROPERTIES TIMEOUT 900 LABELS
set_tests_properties
(
test_mobile_net PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_mobile_net PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_seq2seq PROPERTIES TIMEOUT 150
)
set_tests_properties
(
test_seq2seq PROPERTIES TIMEOUT 150
)
set_tests_properties
(
test_cycle_gan PROPERTIES TIMEOUT 150
)
set_tests_properties
(
test_cycle_gan PROPERTIES TIMEOUT 150
)
set_tests_properties
(
test_bert PROPERTIES TIMEOUT 1
2
0
)
set_tests_properties
(
test_bert PROPERTIES TIMEOUT 1
8
0
)
set_tests_properties
(
test_bert_with_stride PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_bert_with_stride PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_basic_api_transformation PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_basic_api_transformation PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_reinforcement_learning PROPERTIES TIMEOUT 120
)
set_tests_properties
(
test_reinforcement_learning PROPERTIES TIMEOUT 120
)
...
...
test/dygraph_to_static/dygraph_to_static_util.py
浏览文件 @
110f769d
...
@@ -35,7 +35,7 @@ def enable_fallback_guard(enable):
...
@@ -35,7 +35,7 @@ def enable_fallback_guard(enable):
def
to_ast
(
func
):
def
to_ast
(
func
):
"""
"""
convet run fall_back to ast
conve
r
t run fall_back to ast
"""
"""
def
impl
(
*
args
,
**
kwargs
):
def
impl
(
*
args
,
**
kwargs
):
...
@@ -47,7 +47,7 @@ def to_ast(func):
...
@@ -47,7 +47,7 @@ def to_ast(func):
def
to_sot
(
func
):
def
to_sot
(
func
):
"""
"""
convet run fall_back to ast
conve
r
t run fall_back to ast
"""
"""
enable_sot
=
os
.
environ
.
get
(
"ENABLE_SOT"
,
"False"
)
==
"True"
enable_sot
=
os
.
environ
.
get
(
"ENABLE_SOT"
,
"False"
)
==
"True"
...
@@ -65,11 +65,12 @@ def dy2static_unittest(cls):
...
@@ -65,11 +65,12 @@ def dy2static_unittest(cls):
"""
"""
dy2static unittest must be decorated to each Dy2static Unittests.
dy2static unittest must be decorated to each Dy2static Unittests.
run both in Fallback and Ast mode.
run both in Fallback and Ast mode.
Usage like:
@dy2static_unittest
Examples:
class TestA (unittest.TestCase):
...
>>> @dy2static_unittest
... class TestA(unittest.TestCase):
... ...
"""
"""
for
key
in
dir
(
cls
):
for
key
in
dir
(
cls
):
if
key
.
startswith
(
"test"
):
if
key
.
startswith
(
"test"
):
...
@@ -84,16 +85,18 @@ def dy2static_unittest(cls):
...
@@ -84,16 +85,18 @@ def dy2static_unittest(cls):
def
ast_only_test
(
func
):
def
ast_only_test
(
func
):
"""
"""
run this test function in ast only mode.
run this test function in ast only mode.
Usage:
class TestA (unittest.TestCase):
Examples:
@ast_only_test
def test_ast_only(self):
>>> @dy2static_unittest
pass
... class TestA(unittest.TestCase):
... @ast_only_test
... def test_ast_only(self):
... pass
"""
"""
def
impl
(
*
args
,
**
kwargs
):
def
impl
(
*
args
,
**
kwargs
):
if
os
.
environ
.
get
(
"ENABLE_FALL_BACK"
,
"
Tru
e"
)
==
"False"
:
if
os
.
environ
.
get
(
"ENABLE_FALL_BACK"
,
"
Fals
e"
)
==
"False"
:
func
(
*
args
,
**
kwargs
)
func
(
*
args
,
**
kwargs
)
return
impl
return
impl
...
@@ -102,16 +105,18 @@ def ast_only_test(func):
...
@@ -102,16 +105,18 @@ def ast_only_test(func):
def
sot_only_test
(
func
):
def
sot_only_test
(
func
):
"""
"""
run this test function in ast only mode.
run this test function in ast only mode.
Usage:
class TestA (unittest.TestCase):
Examples:
@ast_only_test
def test_ast_only(self):
>>> @dy2static_unittest
pass
... class TestA(unittest.TestCase):
... @sot_only_test
... def test_sot_only(self):
... pass
"""
"""
def
impl
(
*
args
,
**
kwargs
):
def
impl
(
*
args
,
**
kwargs
):
if
os
.
environ
.
get
(
"ENABLE_FALL_BACK"
,
"
Tru
e"
)
==
"True"
:
if
os
.
environ
.
get
(
"ENABLE_FALL_BACK"
,
"
Fals
e"
)
==
"True"
:
func
(
*
args
,
**
kwargs
)
func
(
*
args
,
**
kwargs
)
return
impl
return
impl
...
...
test/dygraph_to_static/test_eval_frame.py
浏览文件 @
110f769d
...
@@ -29,7 +29,7 @@ class TestEvalFrame(unittest.TestCase):
...
@@ -29,7 +29,7 @@ class TestEvalFrame(unittest.TestCase):
def
test_eval_frame
(
self
):
def
test_eval_frame
(
self
):
if
version_info
.
major
!=
3
or
(
if
version_info
.
major
!=
3
or
(
version_info
.
minor
<=
8
or
version_info
.
minor
>=
1
1
version_info
.
minor
<=
8
or
version_info
.
minor
>=
1
2
):
):
# print("skip test_eval_frame, current only support 3.8 - 3.10")
# print("skip test_eval_frame, current only support 3.8 - 3.10")
return
return
...
...
test/dygraph_to_static/test_rollback.py
浏览文件 @
110f769d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
from
dygraph_to_static_util
import
ast_only_test
from
dygraph_to_static_util
import
ast_only_test
,
dy2static_unittest
import
paddle
import
paddle
from
paddle.jit.dy2static.program_translator
import
StaticFunction
from
paddle.jit.dy2static.program_translator
import
StaticFunction
...
@@ -85,6 +85,7 @@ class TestRollBackPlainFunction(unittest.TestCase):
...
@@ -85,6 +85,7 @@ class TestRollBackPlainFunction(unittest.TestCase):
np
.
testing
.
assert_array_equal
(
st_out
.
numpy
(),
dy_out
.
numpy
())
np
.
testing
.
assert_array_equal
(
st_out
.
numpy
(),
dy_out
.
numpy
())
@
dy2static_unittest
class
TestRollBackNet
(
unittest
.
TestCase
):
class
TestRollBackNet
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
paddle
.
set_device
(
"cpu"
)
paddle
.
set_device
(
"cpu"
)
...
@@ -135,7 +136,9 @@ class FuncRollback(paddle.nn.Layer):
...
@@ -135,7 +136,9 @@ class FuncRollback(paddle.nn.Layer):
return
x
+
2
return
x
+
2
@
dy2static_unittest
class
TestRollBackNotForward
(
unittest
.
TestCase
):
class
TestRollBackNotForward
(
unittest
.
TestCase
):
@
ast_only_test
def
test_rollback
(
self
):
def
test_rollback
(
self
):
x
=
paddle
.
zeros
([
2
,
2
])
x
=
paddle
.
zeros
([
2
,
2
])
net
=
FuncRollback
()
net
=
FuncRollback
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录