mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-17 20:00:12 +08:00
rearrange if-statements for cpu
This commit is contained in:
parent
58d5b042cd
commit
ca671e5d7b
@ -185,15 +185,15 @@ def autocast(disable=False):
|
|||||||
if fp8 and device==cpu:
|
if fp8 and device==cpu:
|
||||||
return torch.autocast("cpu", dtype=torch.bfloat16, enabled=True)
|
return torch.autocast("cpu", dtype=torch.bfloat16, enabled=True)
|
||||||
|
|
||||||
if has_xpu() or has_mps() or cuda_no_autocast():
|
|
||||||
return manual_cast(dtype)
|
|
||||||
|
|
||||||
if fp8 and dtype_inference == torch.float32:
|
if fp8 and dtype_inference == torch.float32:
|
||||||
return manual_cast(dtype)
|
return manual_cast(dtype)
|
||||||
|
|
||||||
if dtype == torch.float32 or dtype_inference == torch.float32:
|
if dtype == torch.float32 or dtype_inference == torch.float32:
|
||||||
return contextlib.nullcontext()
|
return contextlib.nullcontext()
|
||||||
|
|
||||||
|
if has_xpu() or has_mps() or cuda_no_autocast():
|
||||||
|
return manual_cast(dtype)
|
||||||
|
|
||||||
return torch.autocast("cuda")
|
return torch.autocast("cuda")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user