aboutsummaryrefslogtreecommitdiff
path: root/modules/sd_hijack.py
diff options
context:
space:
mode:
authorxeonvs <xeonvs@gmail.com>2022-09-07 15:58:25 +0200
committerxeonvs <xeonvs@gmail.com>2022-09-07 15:58:25 +0200
commit65fbefd0337f9deb913c6956a9cfe2155c9c2f5b (patch)
tree832839cc42c2f698c5cd080e718aa3a6cd4fef97 /modules/sd_hijack.py
parent15bb8e8057f8e19af4e5377437687aac7e33eeb4 (diff)
Added support for launching on Apple Silicon
Diffstat (limited to 'modules/sd_hijack.py')
-rw-r--r--modules/sd_hijack.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py
index 2d26b5f7..9d0637bf 100644
--- a/modules/sd_hijack.py
+++ b/modules/sd_hijack.py
@@ -232,7 +232,10 @@ class FrozenCLIPEmbedderWithCustomWords(torch.nn.Module):
z = outputs.last_hidden_state
# restoring original mean is likely not correct, but it seems to work well to prevent artifacts that happen otherwise
- batch_multipliers = torch.asarray(np.array(batch_multipliers)).to(device)
+ if torch.has_mps:
+ batch_multipliers = torch.asarray(np.array(batch_multipliers).astype('float32')).to(device)
+ else:
+ batch_multipliers = torch.asarray(np.array(batch_multipliers)).to(device)
original_mean = z.mean()
z *= batch_multipliers.reshape(batch_multipliers.shape + (1,)).expand(z.shape)
new_mean = z.mean()