Skip to content

Commit

Permalink
feat: added unbind function to paddle tensor class
Browse files Browse the repository at this point in the history
  • Loading branch information
arshPratap committed Sep 27, 2023
1 parent dfe5ea0 commit 30b1b2a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ivy/functional/frontends/paddle/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,3 +798,19 @@ def real(self, name=None):
)
def cast(self, dtype):
return paddle_frontend.cast(self, dtype)

@with_supported_dtypes(
{
"2.5.1 and below": (
"bool",
"int32",
"int64",
"float16",
"float32",
"float64",
)
},
"paddle",
)
def unbind(self, axis=0):
return paddle_frontend.unbind(self._ivy_array, axis=axis)
Original file line number Diff line number Diff line change
Expand Up @@ -4160,6 +4160,49 @@ def test_paddle_tensor_trunc(
)


# unbind
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="unbind",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("valid"),
min_num_dims=2,
max_num_dims=2,
max_dim_size=1,
force_int_axis=True,
min_axis=-1,
max_axis=0,
),
)
def test_paddle_tensor_unbind(
dtype_x_axis,
frontend_method_data,
init_flags,
method_flags,
frontend,
on_device,
backend_fw,
):
input_dtypes, x, axis = dtype_x_axis
helpers.test_frontend_method(
init_input_dtypes=input_dtypes,
backend_to_test=backend_fw,
init_all_as_kwargs_np={
"data": x[0],
},
method_input_dtypes=input_dtypes,
method_all_as_kwargs_np={
"axis": axis,
},
frontend=frontend,
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
on_device=on_device,
)


# unsqueeze
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 30b1b2a

Please sign in to comment.