mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Make cast_to a nop if weight is already good.
This commit is contained in:
parent
1b3eee672c
commit
538cb068bc
@ -21,6 +21,8 @@ import comfy.model_management
|
||||
|
||||
|
||||
def cast_to(weight, dtype=None, device=None, non_blocking=False):
|
||||
if (dtype is None or weight.dtype == dtype) and (device is None or weight.device == device):
|
||||
return weight
|
||||
r = torch.empty_like(weight, dtype=dtype, device=device)
|
||||
r.copy_(weight, non_blocking=non_blocking)
|
||||
return r
|
||||
|
Loading…
Reference in New Issue
Block a user