aboutsummaryrefslogtreecommitdiff
path: root/modules/devices.py
diff options
context:
space:
mode:
authoryfszzx <yfszzx@gmail.com>2022-10-25 18:48:24 +0800
committeryfszzx <yfszzx@gmail.com>2022-10-25 18:48:24 +0800
commitf300d0f2b4487d2fb35fb741a88d747f9e751706 (patch)
tree3af4ff67c0c3a2dc8b863363f55a691ef2d2e091 /modules/devices.py
parent9ba439b53313ef78984dd8e39f25b34501188ee2 (diff)
parent5bfa2b23ca6dad7d2664bfab5dab4b1dfabf5b7f (diff)
Merge branch 'Inspiron' of https://github.com/yfszzx/stable-diffusion-webui-plus into Inspiron
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 dc1f3cdd..7511e1dc 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -45,7 +45,7 @@ def enable_tf32():
errors.run(enable_tf32, "Enabling TF32")
-device = device_interrogate = device_gfpgan = device_bsrgan = device_esrgan = device_scunet = device_codeformer = None
+device = device_interrogate = device_gfpgan = device_swinir = device_esrgan = device_scunet = device_codeformer = None
dtype = torch.float16
dtype_vae = torch.float16
@@ -81,3 +81,7 @@ def autocast(disable=False):
return contextlib.nullcontext()
return torch.autocast("cuda")
+
+# MPS workaround for https://github.com/pytorch/pytorch/issues/79383
+def mps_contiguous(input_tensor, device): return input_tensor.contiguous() if device.type == 'mps' else input_tensor
+def mps_contiguous_to(input_tensor, device): return mps_contiguous(input_tensor, device).to(device)