Skip to content

Commit

Permalink
Paddle qr (ivy-llc#20893)
Browse files Browse the repository at this point in the history
Co-authored-by: Rishab Mallick <[email protected]>
  • Loading branch information
2 people authored and druvdub committed Oct 14, 2023
1 parent 25686af commit d180c68
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ivy/functional/frontends/paddle/tensor/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ def pinv(x, rcond=1e-15, hermitian=False, name=None):
return ivy.pinv(x, rtol=rcond)


# qr
@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def qr(x, mode="reduced", name=None):
return ivy.qr(x, mode=mode)


# solve
@with_unsupported_dtypes({"2.5.1 and below": ("float16", "bfloat16")}, "paddle")
@to_ivy_arrays_and_back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import ivy_tests.test_ivy.helpers as helpers
from ivy_tests.test_ivy.helpers import assert_all_close
from ivy_tests.test_ivy.helpers import handle_frontend_test, matrix_is_stable
from ivy_tests.test_ivy.test_functional.test_core.test_linalg import (
_get_dtype_and_matrix,
)

from ivy_tests.test_ivy.test_frontends.test_tensorflow.test_linalg import (
_get_second_matrix,
_get_cholesky_matrix,
Expand Down Expand Up @@ -835,6 +839,37 @@ def test_paddle_pinv(
)


# qr
@handle_frontend_test(
fn_tree="paddle.tensor.linalg.qr",
dtype_and_x=_get_dtype_and_matrix(),
mode=st.sampled_from(("reduced", "complete")),
test_with_out=st.just(False),
)
def test_paddle_qr(
dtype_and_x,
mode,
frontend,
test_flags,
fn_tree,
backend_fw,
on_device,
):
dtype, x = dtype_and_x
assume(matrix_is_stable(x[0]))
helpers.test_frontend_function(
input_dtypes=dtype,
frontend=frontend,
test_flags=test_flags,
backend_to_test=backend_fw,
fn_tree=fn_tree,
on_device=on_device,
rtol=1e-01,
x=x[0],
mode=mode,
)


# solve
@handle_frontend_test(
fn_tree="paddle.solve",
Expand Down

0 comments on commit d180c68

Please sign in to comment.