Skip to content

Commit

Permalink
Merge pull request #60 from the-database/dev
Browse files Browse the repository at this point in the history
fix cpu upscale pin memory error
  • Loading branch information
the-database authored Dec 19, 2024
2 parents ec34d58 + 69505bc commit 5744bff
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ def _into_tensor(
except Exception:
# Some arrays cannot be made writeable, and we need to copy them
img = np.copy(img)
input_tensor = (
torch.from_numpy(img).pin_memory().to(device, dtype, non_blocking=True)
)
if device == torch.device("cpu"):
input_tensor = (
torch.from_numpy(img).to(device, dtype, non_blocking=True)
)
else:
input_tensor = (
torch.from_numpy(img).pin_memory().to(device, dtype, non_blocking=True)
)
return input_tensor
finally:
img.flags.writeable = writeable
Expand Down

0 comments on commit 5744bff

Please sign in to comment.