diff --git a/ivy/functional/frontends/tensorflow/raw_ops.py b/ivy/functional/frontends/tensorflow/raw_ops.py index 0dd7551d6c3b1..7e6a3488fe9a4 100644 --- a/ivy/functional/frontends/tensorflow/raw_ops.py +++ b/ivy/functional/frontends/tensorflow/raw_ops.py @@ -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 @@ -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)) diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py index fb22d528c2279..7ea897d41fa0d 100644 --- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py +++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py @@ -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], ) @@ -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], + )