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

Added Gather to TensorFlow frontend raw_ops #5876

Merged
merged 5 commits into from
Oct 19, 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
11 changes: 11 additions & 0 deletions ivy/functional/frontends/tensorflow/raw_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ def FloorDiv(*, x, y, name="FloorDiv"):
return ivy.floor_divide(x, y)


@to_ivy_arrays_and_back
def Gather(
*,
params,
indices,
validate_indices=None,
name="Gather"
):
return ivy.gather(params, indices, axis=0, batch_dims=0)


@to_ivy_arrays_and_back
def Greater(*, x, y, name="Greater"):
x, y = promote_types_of_tensorflow_inputs(x, y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def array_indices_axis(
array_dtypes,
indices_dtypes=ivy_np.valid_int_dtypes,
disable_random_axis=False,
axis_zero=False,
allow_inf=False,
min_num_dims=1,
max_num_dims=5,
Expand Down Expand Up @@ -464,7 +465,10 @@ def array_indices_axis(
x_dtype = x_dtype[0]
x = x[0]
if disable_random_axis:
axis = -1
if axis_zero:
axis = 0
else:
axis = -1
batch_dims = 0
batch_shape = x_shape[0:0]
else:
Expand Down
38 changes: 38 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 @@ -1378,6 +1378,44 @@ def test_tensorflow_Cumprod(
)


# Gather
@handle_cmd_line_args
@given(
params_indices_others=helpers.array_indices_axis(
array_dtypes=helpers.get_dtypes("numeric"),
indices_dtypes=["int32", "int64"],
disable_random_axis=True,
axis_zero=True,
min_num_dims=1,
max_num_dims=5,
min_dim_size=1,
max_dim_size=10,
),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.tensorflow.raw_ops.Gather"
),
)
def test_tensorflow_Gather(
params_indices_others,
num_positional_args,
as_variable,
native_array
):
dtypes, params, indices = params_indices_others
helpers.test_frontend_function(
input_dtypes=dtypes,
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.Gather",
params=params,
indices=indices,
validate_indices=True
)


# Greater
@handle_cmd_line_args
@given(
Expand Down