Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions python/paddle/static/nn/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,7 @@ def _case_check_args(pred_fn_pairs, default):

if not callable(fn):
raise TypeError(
f"The fn for {pred.name} of pred_fn_pairs in Op(case) must"
" be callable."
"The fn of pred_fn_pairs in Op(case) must" " be callable."
)

if default is None:
Expand Down
27 changes: 26 additions & 1 deletion test/dygraph_to_static/test_break_continue.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
disable_test_case,
enable_to_static_guard,
test_ast_only,
test_legacy_and_pt,
test_legacy_and_pt_and_pir,
)

Expand Down Expand Up @@ -272,10 +273,22 @@ def init_dygraph_func(self):
self.dygraph_func = test_break_in_for_at_end


class TestBreakContinueInFor(TestContinueNotPirBase):
class TestBreakContinueInFor(TestContinueBase):
def init_dygraph_func(self):
self.dygraph_func = test_break_continue_in_for

@test_legacy_and_pt
def test_transformed_static_result(self):
self.init_dygraph_func()
dygraph_res = self.run_dygraph_mode()
static_res = self.run_static_mode()
np.testing.assert_allclose(
dygraph_res,
static_res,
rtol=1e-05,
err_msg=f'dygraph res is {dygraph_res}\nstatic_res is {static_res}',
)


class TestForInElse(TestContinueInFor):
def init_dygraph_func(self):
Expand Down Expand Up @@ -322,6 +335,18 @@ class TestWhileLoopClassVar(TestContinueInWhile):
def init_dygraph_func(self):
self.dygraph_func = while_loop_class_var

@test_legacy_and_pt
def test_transformed_static_result(self):
self.init_dygraph_func()
dygraph_res = self.run_dygraph_mode()
static_res = self.run_static_mode()
np.testing.assert_allclose(
dygraph_res,
static_res,
rtol=1e-05,
err_msg=f'dygraph res is {dygraph_res}\nstatic_res is {static_res}',
)


class TestOptimBreakInFor(TestDy2staticException):
def setUp(self):
Expand Down
1 change: 1 addition & 0 deletions test/legacy_test/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ def fn_3():


class TestAPICase_Error(unittest.TestCase):
@test_with_pir_api
def test_error(self):
def fn_1():
return paddle.tensor.fill_constant(
Expand Down