Skip to content

Commit

Permalink
add tensorflow squeeze raw_ops frontend (#6813)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeCD authored Nov 9, 2022
1 parent d0a435b commit 959f1ad
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/frontends/tensorflow/raw_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ def Square(*, x, name="Square"):
return ivy.square(x)


@to_ivy_arrays_and_back
def Squeeze(*, input, axis, name="Squeeze"):
return ivy.squeeze(input, axis=axis)


Sub = to_ivy_arrays_and_back(map_raw_ops_alias(tf_frontend.math.subtract))


Expand Down
40 changes: 40 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_tensorflow/test_raw_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,46 @@ def test_tensorflow_Square(dtype_and_x, as_variable, num_positional_args, native
)


@st.composite
def _squeeze_helper(draw):
shape = draw(st.shared(helpers.get_shape(), key="value_shape"))
valid_axes = []
for index, axis in enumerate(shape):
if axis == 1:
valid_axes.append(index)
valid_axes.insert(0, None)
return draw(st.sampled_from(valid_axes))


# Squeeze
@handle_cmd_line_args
@given(
dtype_value=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid", full=True),
shape=st.shared(helpers.get_shape(), key="value_shape"),
),
axis=_squeeze_helper(),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.tensorflow.raw_ops.Squeeze"
),
)
def test_tensorflow_Squeeze(
dtype_value, axis, as_variable, num_positional_args, native_array
):
dtype, xs = dtype_value
helpers.test_frontend_function(
input_dtypes=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.Squeeze",
input=xs[0],
axis=axis,
)


# Sqrt
@handle_cmd_line_args
@given(
Expand Down

0 comments on commit 959f1ad

Please sign in to comment.