aboutsummaryrefslogtreecommitdiffstats
path: root/modules/devices.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-01-28 15:44:36 +0000
committerGitHub <noreply@github.com>2023-01-28 15:44:36 +0000
commitfecb990debdae2cc99b64808d22ba902e34e575b (patch)
tree5531204920675c2bbb9189e41cf331554b92f062 /modules/devices.py
parent41e76d12093dd78315925f923bb1cc0f541e5f54 (diff)
parentf9edd578e9e29d160e6d56038bb368dc49895d64 (diff)
downloadstable-diffusion-webui-gfx803-fecb990debdae2cc99b64808d22ba902e34e575b.tar.gz
stable-diffusion-webui-gfx803-fecb990debdae2cc99b64808d22ba902e34e575b.tar.bz2
stable-diffusion-webui-gfx803-fecb990debdae2cc99b64808d22ba902e34e575b.zip
Merge pull request #7309 from brkirch/fix-embeddings
Fix embeddings, upscalers, and refactor `--upcast-sampling`
Diffstat (limited to 'modules/devices.py')
-rw-r--r--modules/devices.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/devices.py b/modules/devices.py
index 4687944e..655ca1d3 100644
--- a/modules/devices.py
+++ b/modules/devices.py
@@ -87,6 +87,14 @@ dtype_unet = torch.float16
unet_needs_upcast = False
+def cond_cast_unet(input):
+ return input.to(dtype_unet) if unet_needs_upcast else input
+
+
+def cond_cast_float(input):
+ return input.float() if unet_needs_upcast else input
+
+
def randn(seed, shape):
torch.manual_seed(seed)
if device.type == 'mps':
@@ -199,6 +207,3 @@ if has_mps():
cumsum_needs_bool_fix = not torch.BoolTensor([True,True]).to(device=torch.device("mps"), dtype=torch.int64).equal(torch.BoolTensor([True,False]).to(torch.device("mps")).cumsum(0))
torch.cumsum = lambda input, *args, **kwargs: ( cumsum_fix(input, orig_cumsum, *args, **kwargs) )
torch.Tensor.cumsum = lambda self, *args, **kwargs: ( cumsum_fix(self, orig_Tensor_cumsum, *args, **kwargs) )
- orig_narrow = torch.narrow
- torch.narrow = lambda *args, **kwargs: ( orig_narrow(*args, **kwargs).clone() )
-