Skip to content

Commit

Permalink
Added swish activation in Paddle frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
arshPratap committed Sep 4, 2023
1 parent 49fd2cd commit 2917876
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ivy/functional/frontends/paddle/nn/functional/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ def softsign(
return ivy.divide(x, ivy.add(1, ivy.abs(x)))


@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def swish(x, name=None):
return ivy.multiply(x, ivy.sigmoid(x))


@with_supported_dtypes({"2.4.2 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def tanh_(x, name=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,34 @@ def test_paddle_softsign(
)


# swish
@handle_frontend_test(
fn_tree="paddle.nn.functional.swish",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
),
)
def test_paddle_swish(
*,
dtype_and_x,
on_device,
fn_tree,
frontend,
test_flags,
backend_fw,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
backend_to_test=backend_fw,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
x=x[0],
)


# tanh_
@handle_frontend_test(
fn_tree="paddle.nn.functional.tanh_",
Expand Down

0 comments on commit 2917876

Please sign in to comment.