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

Add paddle.tensor.tensor.Tensor.squeeze function #22455

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 @@ -617,3 +617,19 @@ def std(self, axis=None, unbiased=True, keepdim=False, name=None):
return paddle_frontend.Tensor(
ivy.std(self._ivy_array, axis=axis, keepdims=keepdim)
)

@with_supported_dtypes(
{
"2.5.1 and below": (
"float32",
"float64",
"bool",
"int8",
"int32",
"int64"
)
},
"paddle",
)
def squeeze(self, axis=None, name=None):
return paddle_frontend.Tensor(ivy.squeeze(self._ivy_array, axis=axis))
Original file line number Diff line number Diff line change
Expand Up @@ -2795,3 +2795,38 @@ def test_paddle_tensor_numel(
frontend=frontend,
on_device=on_device,
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="squeeze",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
min_num_dims=1,
),
)
def test_paddle_tensor_squeeze(
dtype_and_x,
frontend_method_data,
init_flags,
method_flags,
frontend,
backend_fw,
on_device,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
init_all_as_kwargs_np={
"data": x[0],
},
method_input_dtypes=input_dtype,
backend_to_test=backend_fw,
method_all_as_kwargs_np={},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)
Loading