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

feat(paddle Bucketize):adding test function for bucketize #26665

Closed
wants to merge 17 commits into from
Closed
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
15 changes: 15 additions & 0 deletions ivy/functional/frontends/paddle/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ def argsort(x, /, *, axis=-1, descending=False, name=None):
return ivy.argsort(x, axis=axis, descending=descending)


# bucketize
@with_supported_dtypes(
{"2.5.1 and below": ("float32", "float64", "int32", "int64")},
"paddle",
)
@to_ivy_arrays_and_back
def bucketize(x, sorted_sequence, out_int32=False, right=False, name=None):
if ivy.get_num_dims(sorted_sequence) != 1:
raise ValueError(
"sorted_sequence tensor must be 1 dimension, but got dim"
f" {ivy.get_num_dims(sorted_sequence)}"
)
return searchsorted(sorted_sequence, x, out_int32=out_int32, right=right, name=name)


@with_supported_dtypes(
{"2.5.1 and below": ("int32", "int64", "float32", "float64")},
"paddle",
Expand Down
38 changes: 38 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_paddle/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,44 @@ def test_paddle_argsort(
)


# bucketize
@handle_frontend_test(
fn_tree="paddle.bucketize",
dtype_and_values=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
shared_dtype=True,
min_num_dims=1,
num_arrays=2,
),
out_int32=st.booleans(),
right=st.booleans(),
)
def test_paddle_bucketize(
*,
dtype_and_values,
out_int32,
right,
on_device,
fn_tree,
frontend,
backend_fw,
test_flags,
):
dtype, input = dtype_and_values
helpers.test_frontend_function(
input_dtypes=dtype,
frontend=frontend,
backend_to_test=backend_fw,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
x=input[0],
sorted_sequence=input[1],
out_int32=out_int32,
right=right,
)


@handle_frontend_test(
fn_tree="paddle.index_sample",
array_indices_axis=helpers.array_indices_axis(
Expand Down
Loading