Skip to content

Commit

Permalink
feat(paddle): Addmm paddle tensor method. Closes #25985
Browse files Browse the repository at this point in the history
  • Loading branch information
asuzukosi authored Oct 2, 2023
1 parent 553407b commit 890def4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ivy/functional/frontends/paddle/tensor/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ def add_(self, y, name=None):
self.ivy_array = paddle_frontend.add(self, y).ivy_array
return self

@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
def addmm(self, x, y, beta=1.0, alpha=1.0, name=None):
return paddle_frontend.addmm(self, x, y, beta, alpha)

@with_supported_dtypes(
{"2.5.1 and below": ("float16", "float32", "float64", "int32", "int64")},
"paddle",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from ivy_tests.test_ivy.test_functional.test_core.test_statistical import (
_statistical_dtype_values,
)
from ivy_tests.test_ivy.test_frontends.test_torch.test_blas_and_lapack_ops import (
_get_dtype_and_3dbatch_matrices,
)

CLASS_TREE = "ivy.functional.frontends.paddle.Tensor"

Expand Down Expand Up @@ -514,6 +517,56 @@ def test_paddle_tensor_add_n(
)


# addmm
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="addmm",
dtype_input_xy=_get_dtype_and_3dbatch_matrices(with_input=True, input_3d=True),
beta=st.floats(
min_value=-5,
max_value=5,
allow_nan=False,
allow_subnormal=False,
allow_infinity=False,
),
alpha=st.floats(
min_value=-5,
max_value=5,
allow_nan=False,
allow_subnormal=False,
allow_infinity=False,
),
)
def test_paddle_tensor_addmm(
*,
dtype_input_xy,
beta,
alpha,
frontend_method_data,
init_flags,
method_flags,
frontend,
on_device,
backend_fw,
):
input_dtype, input, x, y = dtype_input_xy
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={
"data": input[0],
},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={"x": x[0], "y": y[0], "beta": beta, "alpha": alpha},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)


# all
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 890def4

Please sign in to comment.