Skip to content

Commit

Permalink
added func and test
Browse files Browse the repository at this point in the history
  • Loading branch information
NiteshK84 committed Aug 31, 2023
1 parent bdb1862 commit 5e88598
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,29 @@ def index_fill(self, dim, index, value):
arr = torch_frontend.moveaxis(self, 0, dim)
return arr

@with_unsupported_dtypes(
{
"2.0.1 and below": (
"bfloat16",
"int8",
"uint8",
"uint32",
"uint16",
"uint64",
"int16",
"float16",
"complex128",
"complex64",
"bool",
)
},
"torch",
)
def unique_consecutive(self, return_inverse, return_counts, dim):
return torch_frontend.unique_consecutive(
self, return_inverse, return_counts, dim
)

@with_unsupported_dtypes(
{
"2.0.1 and below": (
Expand Down
44 changes: 44 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12616,3 +12616,47 @@ def test_torch_triu_(
frontend=frontend,
on_device=on_device,
)


# unique_consecutive
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="unique_consecutive",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("valid"),
valid_axis=True,
force_int_axis=True,
min_num_dims=1,
),
return_inverse=st.booleans(),
return_counts=st.booleans(),
)
def test_torch_unique_consecutive(
dtype_x_axis,
return_inverse,
return_counts,
frontend,
frontend_method_data,
init_flags,
method_flags,
on_device,
backend_fw,
):
input_dtype, x, axis = dtype_x_axis
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={"data": x[0]},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={
"return_inverse": return_inverse,
"return_counts": return_counts,
"dim": axis,
},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)

0 comments on commit 5e88598

Please sign in to comment.