Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0213a19c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
0213a19c
编写于
9月 01, 2023
作者:
Y
yangguohao
提交者:
GitHub
9月 01, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【NewIR】enable dy2st new IR test (#56631)
* enable dy2st newIR test * fix 2023-08-29 * fix_2
上级
17e4be21
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
48 addition
and
15 deletion
+48
-15
test/dygraph_to_static/dygraph_to_static_util.py
test/dygraph_to_static/dygraph_to_static_util.py
+12
-13
test/dygraph_to_static/test_assert.py
test/dygraph_to_static/test_assert.py
+1
-0
test/dygraph_to_static/test_ast_util.py
test/dygraph_to_static/test_ast_util.py
+2
-0
test/dygraph_to_static/test_backward_without_params.py
test/dygraph_to_static/test_backward_without_params.py
+3
-0
test/dygraph_to_static/test_basic_api_transformation.py
test/dygraph_to_static/test_basic_api_transformation.py
+8
-0
test/dygraph_to_static/test_cinn.py
test/dygraph_to_static/test_cinn.py
+2
-0
test/dygraph_to_static/test_cinn_prim.py
test/dygraph_to_static/test_cinn_prim.py
+6
-1
test/dygraph_to_static/test_closure_analysis.py
test/dygraph_to_static/test_closure_analysis.py
+6
-0
test/dygraph_to_static/test_convert_call_generator.py
test/dygraph_to_static/test_convert_call_generator.py
+2
-1
test/dygraph_to_static/test_cpu_cuda_to_tensor.py
test/dygraph_to_static/test_cpu_cuda_to_tensor.py
+6
-0
未找到文件。
test/dygraph_to_static/dygraph_to_static_util.py
浏览文件 @
0213a19c
...
...
@@ -153,19 +153,18 @@ def test_and_compare_with_new_ir(need_check_output: bool = True):
ir_outs
=
test_with_new_ir
(
func
)(
*
args
,
**
kwargs
)
if
not
need_check_output
:
return
outs
for
i
in
range
(
len
(
outs
)):
np
.
testing
.
assert_array_equal
(
outs
[
i
],
ir_outs
[
i
],
err_msg
=
'Dy2St Unittest Check ('
+
func
.
__name__
+
') has diff '
+
'
\n
Expect '
+
str
(
outs
[
i
])
+
'
\n
'
+
'But Got'
+
str
(
ir_outs
[
i
]),
)
np
.
testing
.
assert_array_equal
(
outs
,
ir_outs
,
err_msg
=
'Dy2St Unittest Check ('
+
func
.
__name__
+
') has diff '
+
'
\n
Expect '
+
str
(
outs
)
+
'
\n
'
+
'But Got'
+
str
(
ir_outs
),
)
return
outs
return
impl
...
...
test/dygraph_to_static/test_assert.py
浏览文件 @
0213a19c
...
...
@@ -66,6 +66,7 @@ class TestAssertVariable(unittest.TestCase):
dyfunc_assert_variable
,
x
=
numpy
.
array
([
True
]),
with_exception
=
False
)
@
test_and_compare_with_new_ir
(
False
)
def
test_int_variable
(
self
):
self
.
_run_dy_static
(
dyfunc_assert_variable
,
x
=
numpy
.
array
([
0
]),
with_exception
=
True
...
...
test/dygraph_to_static/test_ast_util.py
浏览文件 @
0213a19c
...
...
@@ -17,6 +17,7 @@ import textwrap
import
unittest
import
numpy
as
np
from
dygraph_to_static_util
import
test_and_compare_with_new_ir
from
ifelse_simple_func
import
(
dyfunc_with_if_else
,
dyfunc_with_if_else2
,
...
...
@@ -60,6 +61,7 @@ class TestAST2Func(unittest.TestCase):
test_ret
=
self
.
_ast2func
(
func
)(
x_v
).
numpy
()
self
.
assertTrue
((
true_ret
==
test_ret
).
all
())
@
test_and_compare_with_new_ir
(
False
)
def
test_ast2func_static
(
self
):
paddle
.
enable_static
()
...
...
test/dygraph_to_static/test_backward_without_params.py
浏览文件 @
0213a19c
...
...
@@ -15,6 +15,7 @@
import
unittest
import
numpy
as
np
from
dygraph_to_static_util
import
test_and_compare_with_new_ir
import
paddle
...
...
@@ -30,6 +31,7 @@ class Net(paddle.nn.Layer):
class
TestBackwardWithoutParams
(
unittest
.
TestCase
):
@
test_and_compare_with_new_ir
(
False
)
def
test_run
(
self
):
net
=
Net
()
...
...
@@ -54,6 +56,7 @@ class ZeroSizeNet(paddle.nn.Layer):
class
TestZeroSizeNet
(
unittest
.
TestCase
):
@
test_and_compare_with_new_ir
(
False
)
def
test_run
(
self
):
net
=
ZeroSizeNet
()
x
=
paddle
.
ones
([
2
,
2
])
...
...
test/dygraph_to_static/test_basic_api_transformation.py
浏览文件 @
0213a19c
...
...
@@ -16,6 +16,7 @@ import inspect
import
unittest
import
numpy
as
np
from
dygraph_to_static_util
import
test_and_compare_with_new_ir
import
paddle
from
paddle
import
fluid
,
to_tensor
...
...
@@ -91,6 +92,7 @@ class TestDygraphBasicApi_ToVariable(unittest.TestCase):
res
=
self
.
dygraph_func
(
self
.
input
).
numpy
()
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
main_program
=
fluid
.
Program
()
main_program
.
random_seed
=
SEED
...
...
@@ -245,6 +247,7 @@ class TestDygraphBasicApi(unittest.TestCase):
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
startup_program
=
fluid
.
Program
()
startup_program
.
random_seed
=
SEED
...
...
@@ -278,6 +281,7 @@ class TestDygraphBasicApi_BilinearTensorProduct(TestDygraphBasicApi):
res
=
self
.
dygraph_func
(
self
.
input1
,
self
.
input2
).
numpy
()
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
startup_program
=
fluid
.
Program
()
startup_program
.
random_seed
=
SEED
...
...
@@ -403,6 +407,7 @@ class TestDygraphBasicApi_CosineDecay(unittest.TestCase):
res
=
self
.
dygraph_func
().
numpy
()
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
startup_program
=
fluid
.
Program
()
startup_program
.
random_seed
=
SEED
...
...
@@ -433,6 +438,7 @@ class TestDygraphBasicApi_ExponentialDecay(TestDygraphBasicApi_CosineDecay):
res
=
self
.
dygraph_func
()
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
startup_program
=
fluid
.
Program
()
startup_program
.
random_seed
=
SEED
...
...
@@ -459,6 +465,7 @@ class TestDygraphBasicApi_InverseTimeDecay(TestDygraphBasicApi_CosineDecay):
res
=
self
.
dygraph_func
()
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
startup_program
=
fluid
.
Program
()
startup_program
.
random_seed
=
SEED
...
...
@@ -485,6 +492,7 @@ class TestDygraphBasicApi_NaturalExpDecay(TestDygraphBasicApi_CosineDecay):
res
=
self
.
dygraph_func
()
return
res
@
test_and_compare_with_new_ir
(
True
)
def
get_static_output
(
self
):
startup_program
=
fluid
.
Program
()
startup_program
.
random_seed
=
SEED
...
...
test/dygraph_to_static/test_cinn.py
浏览文件 @
0213a19c
...
...
@@ -15,6 +15,7 @@
import
unittest
import
numpy
as
np
from
dygraph_to_static_util
import
test_and_compare_with_new_ir
import
paddle
...
...
@@ -78,6 +79,7 @@ class TestCINN(unittest.TestCase):
return
res
@
test_and_compare_with_new_ir
(
False
)
def
test_cinn
(
self
):
dy_res
=
self
.
train
(
use_cinn
=
False
)
cinn_res
=
self
.
train
(
use_cinn
=
True
)
...
...
test/dygraph_to_static/test_cinn_prim.py
浏览文件 @
0213a19c
...
...
@@ -15,7 +15,11 @@
import
unittest
import
numpy
as
np
from
dygraph_to_static_util
import
ast_only_test
,
dy2static_unittest
from
dygraph_to_static_util
import
(
ast_only_test
,
dy2static_unittest
,
test_and_compare_with_new_ir
,
)
import
paddle
import
paddle.nn.functional
as
F
...
...
@@ -169,6 +173,7 @@ class TestPrimForwardAndBackward(unittest.TestCase):
class
TestBackend
(
unittest
.
TestCase
):
@
test_and_compare_with_new_ir
(
False
)
def
test_backend
(
self
):
x
=
paddle
.
randn
([
2
,
4
])
out1
=
self
.
forward
(
x
,
'CINN'
)
...
...
test/dygraph_to_static/test_closure_analysis.py
浏览文件 @
0213a19c
...
...
@@ -16,6 +16,7 @@ import inspect
import
os
import
unittest
from
dygraph_to_static_util
import
test_and_compare_with_new_ir
from
numpy
import
append
import
paddle
...
...
@@ -260,6 +261,7 @@ class TestClosureAnalysis_PushPop(TestClosureAnalysis):
class
TestPushPopTrans
(
unittest
.
TestCase
):
@
test_and_compare_with_new_ir
(
False
)
def
test
(
self
):
def
vlist_of_dict
(
x
):
ma
=
{
'a'
:
[]}
...
...
@@ -271,6 +273,7 @@ class TestPushPopTrans(unittest.TestCase):
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
).
code
)
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
@
test_and_compare_with_new_ir
(
False
)
def
test2
(
self
):
import
numpy
as
np
...
...
@@ -284,6 +287,7 @@ class TestPushPopTrans(unittest.TestCase):
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
).
code
)
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
@
test_and_compare_with_new_ir
(
False
)
def
test3
(
self
):
import
numpy
as
np
...
...
@@ -297,6 +301,7 @@ class TestPushPopTrans(unittest.TestCase):
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
).
code
)
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
@
test_and_compare_with_new_ir
(
False
)
def
test4
(
self
):
import
numpy
as
np
...
...
@@ -310,6 +315,7 @@ class TestPushPopTrans(unittest.TestCase):
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
).
code
)
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
@
test_and_compare_with_new_ir
(
False
)
def
test5
(
self
):
import
numpy
as
np
...
...
test/dygraph_to_static/test_convert_call_generator.py
浏览文件 @
0213a19c
...
...
@@ -14,7 +14,7 @@
import
unittest
from
dygraph_to_static_util
import
ast_only_test
from
dygraph_to_static_util
import
ast_only_test
,
test_and_compare_with_new_ir
import
paddle
from
paddle.jit
import
to_static
...
...
@@ -35,6 +35,7 @@ def main_func():
class
TestConvertGenerator
(
unittest
.
TestCase
):
# fallback will ok.
@
ast_only_test
@
test_and_compare_with_new_ir
(
False
)
def
test_raise_error
(
self
):
translator_logger
.
verbosity_level
=
1
with
self
.
assertLogs
(
...
...
test/dygraph_to_static/test_cpu_cuda_to_tensor.py
浏览文件 @
0213a19c
...
...
@@ -19,6 +19,7 @@ from dygraph_to_static_util import (
ast_only_test
,
dy2static_unittest
,
sot_only_test
,
test_and_compare_with_new_ir
,
)
import
paddle
...
...
@@ -38,6 +39,7 @@ class TestCpuCuda(unittest.TestCase):
class
TestToTensor
(
unittest
.
TestCase
):
@
test_and_compare_with_new_ir
(
False
)
def
test_to_tensor_with_variable_list
(
self
):
def
func
(
x
):
ones
=
paddle
.
to_tensor
(
1
)
...
...
@@ -57,6 +59,7 @@ class TestToTensor(unittest.TestCase):
@
dy2static_unittest
class
TestToTensor1
(
unittest
.
TestCase
):
@
ast_only_test
@
test_and_compare_with_new_ir
(
False
)
def
test_to_tensor_with_variable_list
(
self
):
def
func
(
x
):
ones
=
paddle
.
to_tensor
([
1
])
...
...
@@ -75,6 +78,7 @@ class TestToTensor1(unittest.TestCase):
)
@
sot_only_test
@
test_and_compare_with_new_ir
(
False
)
def
test_to_tensor_with_variable_list_sot
(
self
):
def
func
(
x
):
ones
=
paddle
.
to_tensor
([
1
])
...
...
@@ -96,6 +100,7 @@ class TestToTensor1(unittest.TestCase):
@
dy2static_unittest
class
TestToTensor2
(
unittest
.
TestCase
):
@
ast_only_test
@
test_and_compare_with_new_ir
(
False
)
def
test_to_tensor_with_variable_list
(
self
):
def
func
(
x
):
x
=
paddle
.
to_tensor
([[
1
],
[
2
],
[
3
],
[
4
]])
...
...
@@ -109,6 +114,7 @@ class TestToTensor2(unittest.TestCase):
)
@
sot_only_test
@
test_and_compare_with_new_ir
(
False
)
def
test_to_tensor_with_variable_list_sot
(
self
):
def
func
(
x
):
x
=
paddle
.
to_tensor
([[
1
],
[
2
],
[
3
],
[
4
]])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录