mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-29 19:05:05 +08:00
use empty_like to reduce model loading time
This commit is contained in:
parent
5865da28d1
commit
62da1aaf28
@ -188,7 +188,7 @@ class LoadStateDictOnMeta(ReplaceHelper):
|
|||||||
|
|
||||||
if param.is_meta:
|
if param.is_meta:
|
||||||
dtype = sd_param.dtype if sd_param is not None else param.dtype
|
dtype = sd_param.dtype if sd_param is not None else param.dtype
|
||||||
module._parameters[name] = torch.nn.parameter.Parameter(torch.zeros_like(param, device=device, dtype=dtype), requires_grad=param.requires_grad)
|
module._parameters[name] = torch.nn.parameter.Parameter(torch.empty_like(param, device=device, dtype=dtype), requires_grad=param.requires_grad)
|
||||||
|
|
||||||
for name in module._buffers:
|
for name in module._buffers:
|
||||||
key = prefix + name
|
key = prefix + name
|
||||||
|
Loading…
Reference in New Issue
Block a user