Skip to content

Commit

Permalink
fix cpu upscale pin memory error
Browse files Browse the repository at this point in the history
  • Loading branch information
the-database committed Dec 19, 2024
1 parent c5df27c commit 69505bc
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 69505bc

Please sign in to comment.