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
39 changes: 24 additions & 15 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ def dynamic_guard():


class TestSqrtOpError(unittest.TestCase):
@test_with_pir_api
def test_errors(self):
with static_guard():
with program_guard(Program(), Program()):
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
# The input type of sqrt op must be Variable or numpy.ndarray.
in1 = 1
self.assertRaises(TypeError, paddle.sqrt, in1)
Expand Down Expand Up @@ -643,6 +646,7 @@ def test_dygraph_api(self):
np.testing.assert_allclose(out_ref, r.numpy(), rtol=1e-05)
paddle.enable_static()

@test_with_pir_api
def test_errors(self):
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
Expand Down Expand Up @@ -890,6 +894,7 @@ def test_dygraph_api(self):
for r in [out1, out2, out3]:
np.testing.assert_allclose(out_ref, r.numpy(), rtol=1e-05)

@test_with_pir_api
def test_errors(self):
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
Expand Down Expand Up @@ -2702,22 +2707,24 @@ def test_dygraph_api(self):
for r in [out1, out2]:
np.testing.assert_allclose(out_ref, r.numpy(), rtol=1e-05)

@test_with_pir_api
def test_errors(self):
with static_guard():
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
# The input type must be Variable.
self.assertRaises(TypeError, self.relu, 1)
# The input dtype must be float16, float32, float64.
x_int32 = paddle.static.data(
name='x_int32', shape=[10, 12], dtype='int32'
)
self.assertRaises(TypeError, self.relu, x_int32)
# support the input dtype is float16
x_fp16 = paddle.static.data(
name='x_fp16', shape=[10, 12], dtype='float16'
)
self.relu(x_fp16)
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
# The input type must be Variable.
self.assertRaises(TypeError, self.relu, 1)
# The input dtype must be float16, float32, float64.
x_int32 = paddle.static.data(
name='x_int32', shape=[10, 12], dtype='int32'
)
self.assertRaises(TypeError, self.relu, x_int32)
# support the input dtype is float16
x_fp16 = paddle.static.data(
name='x_fp16', shape=[10, 12], dtype='float16'
)
self.relu(x_fp16)


class TestReluInplaceAPI(TestReluAPI):
Expand Down Expand Up @@ -2846,6 +2853,7 @@ def test_dygraph_api(self):
for r in [out1, out2]:
np.testing.assert_allclose(out_ref, r.numpy(), rtol=1e-05)

@test_with_pir_api
def test_errors(self):
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
Expand Down Expand Up @@ -3029,6 +3037,7 @@ def test_dygraph_api(self):
for r in [out1, out2]:
np.testing.assert_allclose(out_ref, r.numpy(), rtol=1e-05)

@test_with_pir_api
def test_errors(self):
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
Expand Down
6 changes: 4 additions & 2 deletions test/legacy_test/test_full_like_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from paddle.base.framework import convert_np_dtype_to_dtype_
from paddle.framework import in_pir_mode
from paddle.pir_utils import test_with_pir_api
from paddle.static import Program, program_guard


def fill_any_like_wrapper(x, value, out_dtype=None, name=None):
Expand Down Expand Up @@ -98,8 +97,11 @@ def test_full_like_fill_inf(self):


class TestFullOpError(unittest.TestCase):
@test_with_pir_api
def test_errors(self):
with program_guard(Program(), Program()):
with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
# for ci coverage

input_data = paddle.static.data(
Expand Down