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

Changed factories.array to DNDarray #1323

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
20 changes: 18 additions & 2 deletions heat/core/linalg/qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,24 @@ def qr(
except AttributeError:
q, r = a.larray.qr(some=False)

q = factories.array(q, device=a.device, comm=a.comm)
r = factories.array(r, device=a.device, comm=a.comm)
q = DNDarray(
q,
gshape=q.shape,
dtype=a.dtype,
split=a.split,
device=a.device,
comm=a.comm,
balanced=True,
)
r = DNDarray(
r,
gshape=r.shape,
dtype=a.dtype,
split=a.split,
device=a.device,
comm=a.comm,
balanced=True,
)
ret = QR(q if calc_q else None, r)
return ret
# =============================== Prep work ====================================================
Expand Down
22 changes: 20 additions & 2 deletions heat/core/linalg/svdtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,27 @@ def hsvd(
A.comm.Bcast(U_loc, root=0)
# separate U_loc and err_squared_loc again
err_squared_loc = U_loc[-1, 0]
U = factories.array(U_loc[:-1], device=A.device, split=None, comm=A.comm)
U_shape = U_loc[:-1].shape
U = DNDarray(
U_loc[:-1],
gshape=U_shape,
dtype=A.dtype,
device=A.device,
split=None,
comm=A.comm,
balanced=True,
)
rel_error_estimate = (
factories.array(err_squared_loc**0.5, device=A.device, split=None, comm=A.comm) / Anorm
DNDarray(
err_squared_loc**0.5,
gshape=err_squared_loc.shape,
dtype=A.dtype,
device=A.device,
split=None,
comm=A.comm,
balanced=True,
)
/ Anorm
)

# Postprocessing:
Expand Down
Loading