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

Only copy non-writeable image when CPU upscaling #2860

Merged
merged 3 commits into from
May 18, 2024
Merged
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
6 changes: 5 additions & 1 deletion backend/src/nodes/impl/pytorch/auto_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ def upscale(img: np.ndarray, _: object):
try:
# convert to tensor
img = np.ascontiguousarray(img)
if not img.flags.writeable:
if not img.flags.writeable and device == torch.device("cpu"):
img = np.copy(img)
else:
# since we are going to copy the image to the GPU, we can skip the copy here
img.flags.writeable = True
input_tensor = torch.from_numpy(img).to(device, dtype)
img.flags.writeable = False
input_tensor = _rgb_to_bgr(input_tensor)
input_tensor = _into_batched_form(input_tensor)

Expand Down
Loading