Added support for launching on Apple Silicon

This commit is contained in:
xeonvs
2022-09-07 15:58:25 +02:00
parent 15bb8e8057
commit 65fbefd033
4 changed files with 17 additions and 6 deletions

View File

@@ -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()