Skip to content

Commit

Permalink
Only do .to if necessary (#2859)
Browse files Browse the repository at this point in the history
only do .to if necessary
  • Loading branch information
joeyballentine authored May 17, 2024
1 parent a52151a commit 268e683
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/src/nodes/impl/pytorch/auto_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def pytorch_auto_split(
progress: Progress,
) -> np.ndarray:
dtype = torch.float16 if use_fp16 else torch.float32
model = model.to(device, dtype)
if model.dtype != dtype or model.device != device:
model = model.to(device, dtype)

def upscale(img: np.ndarray, _: object):
progress.check_aborted()
Expand Down

0 comments on commit 268e683

Please sign in to comment.