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

fixed tesorflow.keras.activations.get #28637

Merged
merged 1 commit into from
Mar 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
except ImportError:
tf = SimpleNamespace()

# Activation functions for testing
ACTIVATION_FUNCTIONS = [
"gelu",
"leaky_relu",
"log_softmax",
"relu",
"sigmoid",
"silu",
"softmax",
"softplus",
]


# Helper function for deserialize.
def get_callable_functions(
Expand All @@ -39,6 +51,7 @@ def simple_test_two_function(
atol_: float = 1e-06,
ivy_submodules: list = [],
framework_submodules: list = [],
backend: str,
):
ivy.set_backend(frontend)
fn_ivy = ivy.functional.frontends.__dict__[frontend]
Expand All @@ -58,14 +71,15 @@ def simple_test_two_function(
ret_ivy = ivy.array(ret_ivy, dtype=dtype_data)
ret = ivy.array(ret, dtype=dtype_data)

ret_np_flat = helpers.flatten_and_to_np(ret=ret)
frontend_ret_np_flat = helpers.flatten_and_to_np(ret=ret_ivy)
ret_np_flat = helpers.flatten_and_to_np(backend=backend, ret=ret)
frontend_ret_np_flat = helpers.flatten_and_to_np(backend=backend, ret=ret_ivy)

helpers.value_test(
ret_np_flat=ret_np_flat,
ret_np_from_gt_flat=frontend_ret_np_flat,
rtol=rtol_,
atol=atol_,
backend=backend,
ground_truth_backend=frontend,
)
ivy.previous_backend()
Expand Down Expand Up @@ -190,17 +204,7 @@ def test_tensorflow_gelu(
@handle_frontend_test(
fn_tree="tensorflow.keras.activations.get",
fn_name=st.sampled_from(get_callable_functions("keras.activations")).filter(
lambda x: not x[0].isupper()
and x
not in [
"deserialize",
"get",
"keras_export",
"serialize",
"deserialize_keras_object",
"serialize_keras_object",
"get_globals",
]
lambda x: not x[0].isupper() and x in ACTIVATION_FUNCTIONS
),
dtype_and_data=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
Expand All @@ -209,12 +213,13 @@ def test_tensorflow_gelu(
shape=helpers.ints(min_value=2, max_value=5).map(lambda x: (x, x)),
),
)
def test_tensorflow_get(fn_name, dtype_and_data):
def test_tensorflow_get(fn_name, dtype_and_data, backend_fw):
dtype_data, data = dtype_and_data
simple_test_two_function(
fn_name=fn_name,
x=data[0],
frontend="tensorflow",
backend=backend_fw,
fn_str="get",
dtype_data=dtype_data[0],
rtol_=1e-01,
Expand Down
Loading