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

Raw ops xdiv xlog #6578

Merged
merged 3 commits into from
Nov 5, 2022
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
24 changes: 22 additions & 2 deletions ivy/functional/frontends/tensorflow/raw_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

@to_ivy_arrays_and_back
def AddN(*, inputs, name="AddN"):
inputs = ivy.array(inputs)
return ivy.sum(inputs, axis=0, dtype=inputs.dtype)
return ivy.sum(inputs, dtype=inputs.dtype)


@to_ivy_arrays_and_back
Expand Down Expand Up @@ -427,3 +426,24 @@ def Relu6(features, name="Relu6"):
@to_ivy_arrays_and_back
def Softplus(features, name="Softplus"):
return ivy.softplus(features)


@to_ivy_arrays_and_back
def Xdivy(*, x, y, name="Xdivy"):
if (x == 0).all():
return 0.0
return ivy.divide(x, y)


@to_ivy_arrays_and_back
def Xlog1py(*, x, y, name="Xlog1py"):
if (x == 0).all():
return 0.0
return ivy.multiply(x, ivy.log1p(y))


@to_ivy_arrays_and_back
def Xlogy(*, x, y, name="Xlogy"):
if (x == 0).all():
return 0.0
return ivy.multiply(x, ivy.log(y))
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ def test_tensorflow_AddN(dtype_and_x, as_variable, num_positional_args, native_a
native_array_flags=native_array,
frontend="tensorflow",
fn_tree="raw_ops.AddN",
inputs=x,
inputs=x[0],
)


Expand Down Expand Up @@ -2275,3 +2275,84 @@ def test_tensorflow_Softplus(dtype_and_x, as_variable, native_array):
fn_tree="raw_ops.Softplus",
features=x[0],
)

@handle_cmd_line_args
@given(
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=2,
shared_dtype=True,
),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.tensorflow.raw_ops.Xdivy"
),
)
def test_tensorflow_Xdivy(
dtype_and_x, as_variable, num_positional_args, native_array
):
input_dtype, xs = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
as_variable_flags=as_variable,
with_out=False,
num_positional_args=num_positional_args,
native_array_flags=native_array,
frontend="tensorflow",
fn_tree="raw_ops.Xdivy",
x=xs[0],
y=xs[1],
)


@handle_cmd_line_args
@given(
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=2,
shared_dtype=True,
),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.tensorflow.raw_ops.Xlog1py"
),
)
def test_tensorflow_Xlog1py(
dtype_and_x, as_variable, num_positional_args, native_array
):
input_dtype, xs = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
as_variable_flags=as_variable,
with_out=False,
num_positional_args=num_positional_args,
native_array_flags=native_array,
frontend="tensorflow",
fn_tree="raw_ops.Xlog1py",
x=xs[0],
y=xs[1],
)


@handle_cmd_line_args
@given(
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=2,
shared_dtype=True,
),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.tensorflow.raw_ops.Xlogy"
),
)
def test_tensorflow_Xlogy(dtype_and_x, as_variable, num_positional_args, native_array):
input_dtype, xs = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
as_variable_flags=as_variable,
with_out=False,
num_positional_args=num_positional_args,
native_array_flags=native_array,
frontend="tensorflow",
fn_tree="raw_ops.Xlogy",
x=xs[0],
y=xs[1],
)