aboutsummaryrefslogtreecommitdiff
path: root/modules/devices.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-10-11 11:14:36 +0300
committerAUTOMATIC <16777216c@gmail.com>2022-10-11 11:14:36 +0300
commit5de806184f6687e46cf936b92055146dc6cf2994 (patch)
treed84c2daa8798c3d2f8e99e17234a40065491182d /modules/devices.py
parent12c4d5c6b5bf9dd50d0601c36af4f99b65316d58 (diff)
parent948533950c9db5069a874d925fadd50bac00fdb5 (diff)
Merge branch 'master' into hypernetwork-training
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/devices.py b/modules/devices.py
index 0158b11f..03ef58f1 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -36,6 +36,7 @@ errors.run(enable_tf32, "Enabling TF32")
device = device_gfpgan = device_bsrgan = device_esrgan = device_scunet = device_codeformer = get_optimal_device()
dtype = torch.float16
+dtype_vae = torch.float16
def randn(seed, shape):
# Pytorch currently doesn't handle setting randomness correctly when the metal backend is used.
@@ -59,9 +60,12 @@ def randn_without_seed(shape):
return torch.randn(shape, device=device)
-def autocast():
+def autocast(disable=False):
from modules import shared
+ if disable:
+ return contextlib.nullcontext()
+
if dtype == torch.float32 or shared.cmd_opts.precision == "full":
return contextlib.nullcontext()