Skip to content

Commit

Permalink
feat: added cholesky_solve function to paddle tensor class
Browse files Browse the repository at this point in the history
  • Loading branch information
arshPratap committed Oct 1, 2023
1 parent d0e94ee commit 344cfc1
Show file tree
Hide file tree
Showing 2 changed files with 49 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 @@ -855,3 +855,7 @@ def unbind(self, axis=0):
def cpu(self):
self.ivy_array = ivy.to_device(self.ivy_array, ivy.as_ivy_dev("cpu"))
return self

@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
def cholesky_solve(self, y, upper=False, name=None):
return paddle_frontend.cholesky_solve(self._ivy_array, y, upper=upper)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
from ivy_tests.test_ivy.test_functional.test_core.test_statistical import (
_statistical_dtype_values,
)
from ivy_tests.test_ivy.test_frontends.test_tensorflow.test_linalg import (
_get_second_matrix,
_get_cholesky_matrix,
)

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

Expand Down Expand Up @@ -1311,6 +1315,47 @@ def test_paddle_tensor_cholesky(
)


# cholesky_solve
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
method_name="cholesky_solve",
dtype_and_x=_get_second_matrix(),
dtype_and_y=_get_cholesky_matrix(),
)
def test_paddle_tensor_cholesky_solve(
dtype_and_x,
dtype_and_y,
frontend_method_data,
init_flags,
method_flags,
frontend,
on_device,
backend_fw,
):
input_dtype1, x = dtype_and_x
input_dtype2, y = dtype_and_y
helpers.test_frontend_method(
init_input_dtypes=[input_dtype1, input_dtype2],
backend_to_test=backend_fw,
init_all_as_kwargs_np={
"data": x,
},
method_input_dtypes=[input_dtype1, input_dtype2],
method_all_as_kwargs_np={
"y": y,
"upper": np.array_equal(y, np.triu(y)),
},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
rtol_=1e-3,
atol_=1e-3,
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="paddle.to_tensor",
Expand Down

0 comments on commit 344cfc1

Please sign in to comment.