Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/dygraph_to_static/test_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_bool_variable(self):
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
Expand Down
2 changes: 2 additions & 0 deletions test/dygraph_to_static/test_ast_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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,
Expand Down Expand Up @@ -60,6 +61,7 @@ def test_ast2func_dygraph(self):
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()

Expand Down
3 changes: 3 additions & 0 deletions test/dygraph_to_static/test_backward_without_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import test_and_compare_with_new_ir

import paddle

Expand All @@ -30,6 +31,7 @@ def forward(self, x):


class TestBackwardWithoutParams(unittest.TestCase):
@test_and_compare_with_new_ir(False)
def test_run(self):
net = Net()

Expand All @@ -54,6 +56,7 @@ def forward(self, x):


class TestZeroSizeNet(unittest.TestCase):
@test_and_compare_with_new_ir(False)
def test_run(self):
net = ZeroSizeNet()
x = paddle.ones([2, 2])
Expand Down
5 changes: 5 additions & 0 deletions test/dygraph_to_static/test_basic_api_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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
Expand Down Expand Up @@ -102,6 +103,7 @@ def get_static_output(self):

return static_res[0]

@test_and_compare_with_new_ir(False)
def test_transformed_static_result(self):
for func in self.test_funcs:
self.dygraph_func = func
Expand Down Expand Up @@ -259,6 +261,7 @@ def get_static_output(self):
static_res = exe.run(main_program, fetch_list=static_out)
return static_res[0]

@test_and_compare_with_new_ir(False)
def test_transformed_static_result(self):
dygraph_res = self.get_dygraph_output()
static_res = self.get_static_output()
Expand Down Expand Up @@ -416,6 +419,7 @@ def get_static_output(self):
static_res = exe.run(main_program, fetch_list=static_out)
return static_res[0]

@test_and_compare_with_new_ir(False)
def test_transformed_static_result(self):
dygraph_res = self.get_dygraph_output()
static_res = self.get_static_output()
Expand Down Expand Up @@ -542,6 +546,7 @@ def _get_dygraph_ast_node(self):
def _get_static_ast_node(self):
return self.root.body[0].body[2].body[1].value

@test_and_compare_with_new_ir(False)
def test_dygraph_api(self):
self.assertTrue(is_dygraph_api(self._get_dygraph_ast_node()) is True)
self.assertTrue(is_dygraph_api(self._get_static_ast_node()) is False)
Expand Down
2 changes: 2 additions & 0 deletions test/dygraph_to_static/test_cinn.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import test_and_compare_with_new_ir

import paddle

Expand Down Expand Up @@ -78,6 +79,7 @@ def train(self, use_cinn):

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)
Expand Down
9 changes: 8 additions & 1 deletion test/dygraph_to_static/test_cinn_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +95,7 @@ def check_prim(self, net, use_prim):
self.assertTrue('softmax' not in fwd_ops)

@ast_only_test
@test_and_compare_with_new_ir(False)
def test_cinn_prim_forward(self):
dy_res = self.train(use_prim=False)
cinn_res = self.train(use_prim=True)
Expand Down Expand Up @@ -158,6 +163,7 @@ def check_prim(self, net, use_prim):
self.assertTrue("_grad" not in op)

@ast_only_test
@test_and_compare_with_new_ir(False)
def test_cinn_prim(self):
dy_res = self.train(use_prim=False)
cinn_res = self.train(use_prim=True)
Expand All @@ -169,6 +175,7 @@ def test_cinn_prim(self):


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')
Expand Down
7 changes: 6 additions & 1 deletion test/dygraph_to_static/test_cinn_prim_gelu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -107,6 +111,7 @@ def check_prim(self, net, use_prim):
self.assertTrue('gelu' not in fwd_ops)

@ast_only_test
@test_and_compare_with_new_ir(False)
def test_cinn_prim(self):
for shape in self.shapes:
for dtype in self.dtypes:
Expand Down
7 changes: 7 additions & 0 deletions test/dygraph_to_static/test_closure_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import unittest

from dygraph_to_static_util import test_and_compare_with_new_ir
from numpy import append

import paddle
Expand Down Expand Up @@ -194,6 +195,7 @@ def init_dygraph_func(self):
{'func': set('i'), 'test_normal_argument': set('x')},
]

@test_and_compare_with_new_ir(False)
def test_main(self):
if self.judge_type == 'push_pop_vars':
for push_pop_vars, func in zip(
Expand Down Expand Up @@ -260,6 +262,7 @@ def init_dygraph_func(self):


class TestPushPopTrans(unittest.TestCase):
@test_and_compare_with_new_ir(False)
def test(self):
def vlist_of_dict(x):
ma = {'a': []}
Expand All @@ -271,6 +274,7 @@ def vlist_of_dict(x):
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

Expand All @@ -284,6 +288,7 @@ def vlist_of_dict(x):
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

Expand All @@ -297,6 +302,7 @@ def vlist_of_dict(x):
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

Expand All @@ -310,6 +316,7 @@ def vlist_of_dict(x):
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

Expand Down
3 changes: 2 additions & 1 deletion test/dygraph_to_static/test_convert_call_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions test/dygraph_to_static/test_cpu_cuda_to_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ast_only_test,
dy2static_unittest,
sot_only_test,
test_and_compare_with_new_ir,
)

import paddle
Expand All @@ -38,6 +39,7 @@ def func(x):


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)
Expand All @@ -57,6 +59,7 @@ def func(x):
@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])
Expand All @@ -75,6 +78,7 @@ def func(x):
)

@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])
Expand All @@ -96,6 +100,7 @@ def func(x):
@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]])
Expand All @@ -109,6 +114,7 @@ def func(x):
)

@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]])
Expand Down