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 24, 2023
1 parent bb0b201 commit a61a372
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 @@ -945,3 +945,7 @@ def gather_(self, y, name=None):
)
def tile(self, repeat_times):
return paddle_frontend.Tensor(ivy.tile(self._ivy_array, repeats=repeat_times))

@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 @@ -22,6 +22,10 @@
from ivy_tests.test_ivy.test_frontends.test_paddle.test_manipulation import (
_tile_helper,
)
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 @@ -1400,6 +1404,47 @@ def test_paddle_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 a61a372

Please sign in to comment.