Skip to content

Commit

Permalink
Raw ops xdiv xlog (#6578)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeCD authored Nov 5, 2022
1 parent 3249416 commit 63f879e
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 3 deletions.
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],
)

0 comments on commit 63f879e

Please sign in to comment.