mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-01 12:25:06 +08:00
Fix nested manual cast
This commit is contained in:
parent
cb5b335acd
commit
0181c1f76b
@ -165,6 +165,8 @@ def manual_cast_forward(target_dtype):
|
||||
@contextlib.contextmanager
|
||||
def manual_cast(target_dtype):
|
||||
for module_type in patch_module_list:
|
||||
if hasattr(module_type, "org_forward"):
|
||||
continue
|
||||
org_forward = module_type.forward
|
||||
if module_type == torch.nn.MultiheadAttention and has_xpu():
|
||||
module_type.forward = manual_cast_forward(torch.float32)
|
||||
@ -175,7 +177,9 @@ def manual_cast(target_dtype):
|
||||
yield None
|
||||
finally:
|
||||
for module_type in patch_module_list:
|
||||
module_type.forward = module_type.org_forward
|
||||
if hasattr(module_type, "org_forward"):
|
||||
module_type.forward = module_type.org_forward
|
||||
delattr(module_type, "org_forward")
|
||||
|
||||
|
||||
def autocast(disable=False):
|
||||
|
Loading…
Reference in New Issue
Block a user