Skip to content

Commit

Permalink
rearrange if-statements for cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
KohakuBlueleaf committed Jan 9, 2024
1 parent 58d5b04 commit ca671e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ def autocast(disable=False):
if fp8 and device==cpu:
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:
return manual_cast(dtype)

if dtype == torch.float32 or dtype_inference == torch.float32:
return contextlib.nullcontext()

if has_xpu() or has_mps() or cuda_no_autocast():
return manual_cast(dtype)

return torch.autocast("cuda")


Expand Down

0 comments on commit ca671e5

Please sign in to comment.