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: Add broadcast_tensors method to paddle.tensor.Tensor #26216

Closed
wants to merge 6 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
34 changes: 34 additions & 0 deletions ivy/functional/frontends/paddle/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,40 @@ def logical_or(self, y, out=None, name=None):
def bitwise_xor(self, y, out=None, name=None):
return paddle_frontend.bitwise_xor(self, y)

@with_supported_dtypes(
{
"2.5.1 and below": (
"bool",
"int8",
"int16",
"int32",
"int64",
"float32",
"float64",
)
},
"paddle",
)
def logical_xor(self, y, out=None, name=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have you implemented logical_xor when the PR is about broadcast_tensors ?

return paddle_frontend.logical_xor(self, y, out=out)

@with_supported_dtypes(
{
"2.5.1 and below": (
"float16",
"float32",
"float64",
"int8",
"int16",
"int32",
"int64",
)
},
"paddle",
)
def broadcast_tensors(self, name=None):
return paddle_frontend.Tensor(ivy.broadcast_arrays(self._ivy_array))

@with_supported_dtypes({"2.5.1 and below": ("float16", "bfloat16")}, "paddle")
def any(self, axis=None, keepdim=False, name=None):
return paddle_frontend.any(self, axis=axis, keepdim=keepdim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,46 @@ def test_paddle_tensor_bitwise_xor(
)


# broadcast_tensors
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="broadcast_tensors",
dtype_x_axis=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("float"),
# valid_axis=True,
# force_int_axis=True,
# min_num_dims=1,
# min_value=-5,
# max_value=5,
),
)
def test_paddle_tensor_broadcast_tensors(
dtype_x_axis,
frontend_method_data,
init_flags,
method_flags,
frontend,
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],
},
method_input_dtypes=input_dtype,
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,
)


# cast
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down
Loading