Skip to content

Commit

Permalink
feat: added unstack function to paddle tensor class
Browse files Browse the repository at this point in the history
  • Loading branch information
arshPratap committed Oct 24, 2023
1 parent bb0b201 commit facf567
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ivy/functional/frontends/paddle/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,3 +945,6 @@ def gather_(self, y, name=None):
)
def tile(self, repeat_times):
return paddle_frontend.Tensor(ivy.tile(self._ivy_array, repeats=repeat_times))

def unstack(self, axis=0, num=None):
return paddle_frontend.unstack(self._ivy_array, axis=axis)
Original file line number Diff line number Diff line change
Expand Up @@ -4888,6 +4888,52 @@ def test_paddle_unsqueeze_(
)


# unstack
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="unstack",
dtype_value=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("numeric"),
min_num_dims=2,
max_num_dims=2,
max_dim_size=1,
),
axis=helpers.get_axis(
shape=st.shared(helpers.get_shape(), key="shape"),
allow_neg=True,
force_int=True,
),
)
def test_paddle_tensor_unstack(
dtype_value,
axis,
frontend_method_data,
init_flags,
method_flags,
frontend,
on_device,
backend_fw,
):
input_dtype, x = dtype_value
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={
"axis": axis,
},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)


# var
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit facf567

Please sign in to comment.