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

added lu factor to torch frontend and tested #18969

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions ivy/functional/frontends/torch/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,7 @@ def solve_ex(A, B, *, left=True, check_errors=False, out=None):
info = ivy.ones(A.shape[:-2], dtype=ivy.int32)

return result, info

@to_ivy_arrays_and_back
def lu(a, *, pivot=True, out=None):
return ivy.lu_factor(a, pivot=pivot, out=out)
26 changes: 26 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,3 +1355,29 @@ def test_torch_solve_ex(
B=other,
check_errors=check,
)

@handle_frontend_test(
fn_tree="torch.linalg.lu_factor", input_dtype_and_input=_lu_factor_helper()
Copy link
Contributor

Choose a reason for hiding this comment

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

_lu_factor_helper() is not defined

)
def test_torch_lu(*, input_dtype_and_input, on_device, fn_tree, frontend, test_flags):
dtype, input = input_dtype_and_input
ret, frontend_ret = helpers.test_frontend_function(
input_dtypes=dtype,
test_flags=test_flags,
frontend=frontend,
fn_tree=fn_tree,
on_device=on_device,
test_values=False,
A=input,
)
ret = [ivy.to_numpy(x) for x in ret]
frontend_ret = [np.asarray(x) for x in frontend_ret]

LU, pivot = ret
frontend_LU, frontend_pivot = frontend_ret

assert_all_close(
ret_np=[LU, pivot],
ret_from_gt_np=[frontend_LU, frontend_pivot],
ground_truth_backend=frontend,
)