Skip to content

Commit

Permalink
【PIR API adaptor No.221】 Migrate paddle.nn.Swish/LeakyReLU into pir (P…
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRyanHuang authored and zeroRains committed Nov 8, 2023
1 parent 478ec36 commit 327c4e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/paddle/nn/functional/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ def swish(x, name=None):
Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
[-0.23840584, 0. , 0.73105860])
"""
if in_dynamic_mode():
if in_dynamic_or_pir_mode():
return _C_ops.swish(x)
else:
check_variable_and_dtype(
Expand Down
3 changes: 3 additions & 0 deletions test/legacy_test/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -4433,6 +4433,7 @@ def test_check_grad(self):
self.check_grad(
['X'],
'Out',
check_pir=True,
)


Expand All @@ -4452,6 +4453,7 @@ def setUp(self):
else paddle.CPUPlace()
)

@test_with_pir_api
def test_static_api(self):
with static_guard():
with paddle.static.program_guard(paddle.static.Program()):
Expand All @@ -4475,6 +4477,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_base_api(self):
with static_guard():
with base.program_guard(base.Program()):
Expand Down

0 comments on commit 327c4e6

Please sign in to comment.