Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIR]Open uts for Softshrink and Softsign #60716

Merged
merged 1 commit into from
Jan 11, 2024
Merged
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
20 changes: 12 additions & 8 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,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 All @@ -1507,10 +1508,11 @@ def test_errors(self):
)
self.assertRaises(ValueError, F.softshrink, x_fp32, -1.0)
# support the input dtype is float16
x_fp16 = paddle.static.data(
name='x_fp16', shape=[12, 10], dtype='float16'
)
F.softshrink(x_fp16)
if core.is_compiled_with_cuda():
x_fp16 = paddle.static.data(
name='x_fp16', shape=[12, 10], dtype='float16'
)
F.softshrink(x_fp16)


class TestSqrt(TestActivation, TestParameter):
Expand Down Expand Up @@ -4307,6 +4309,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 All @@ -4318,10 +4321,11 @@ def test_errors(self):
)
self.assertRaises(TypeError, F.softsign, x_int32)
# support the input dtype is float16
x_fp16 = paddle.static.data(
name='x_fp16', shape=[12, 10], dtype='float16'
)
F.softsign(x_fp16)
if core.is_compiled_with_cuda():
x_fp16 = paddle.static.data(
name='x_fp16', shape=[12, 10], dtype='float16'
)
F.softsign(x_fp16)


def ref_thresholded_relu(x, threshold=1.0):
Expand Down