Skip to content

Commit

Permalink
Merge pull request #44 from chcodes/fix-device-contexts
Browse files Browse the repository at this point in the history
Added missing device contexts
  • Loading branch information
frankong committed Apr 27, 2020
2 parents 1576270 + 4bffa1c commit cbbe549
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions sigpy/alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@ def __init__(self, proxfc, proxg, A, AH, x, u,

if self.gamma_primal > 0:
xp = self.x_device.xp
self.tau_min = xp.amin(xp.abs(tau)).item()
with self.x_device:
self.tau_min = xp.amin(xp.abs(tau)).item()

if self.gamma_dual > 0:
xp = self.u_device.xp
self.sigma_min = xp.amin(xp.abs(sigma)).item()
with self.u_device:
self.sigma_min = xp.amin(xp.abs(sigma)).item()

self.resid = np.infty

Expand Down
8 changes: 5 additions & 3 deletions sigpy/linop.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ def __init__(self, oshape, ishape):
super().__init__(oshape, ishape)

def _apply(self, input):
return input.reshape(self.oshape)
with backend.get_device(input):
return input.reshape(self.oshape)

def _adjoint_linop(self):
return Reshape(self.ishape, self.oshape)
Expand Down Expand Up @@ -1050,8 +1051,9 @@ def __init__(self, oshape, ishape, ishift=None, oshift=None):
super().__init__(oshape, ishape)

def _apply(self, input):
return util.resize(input, self.oshape,
ishift=self.ishift, oshift=self.oshift)
with backend.get_device(input):
return util.resize(input, self.oshape,
ishift=self.ishift, oshift=self.oshift)

def _adjoint_linop(self):
return Resize(self.ishape, self.oshape,
Expand Down

0 comments on commit cbbe549

Please sign in to comment.