diff options
author | C43H66N12O12S2 <36072735+C43H66N12O12S2@users.noreply.github.com> | 2022-09-17 22:05:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 22:05:31 +0000 |
commit | d63dbb3acc16a737711fddb3a954238f82deb2fa (patch) | |
tree | 10cfd3b787e1695561a66142b96f6bd4bd1a4034 /modules/sd_hijack.py | |
parent | 8ff6f093206111940e2601187f3f208d761543d6 (diff) | |
download | stable-diffusion-webui-gfx803-d63dbb3acc16a737711fddb3a954238f82deb2fa.tar.gz stable-diffusion-webui-gfx803-d63dbb3acc16a737711fddb3a954238f82deb2fa.tar.bz2 stable-diffusion-webui-gfx803-d63dbb3acc16a737711fddb3a954238f82deb2fa.zip |
Move scale multiplication to the front
Diffstat (limited to 'modules/sd_hijack.py')
-rw-r--r-- | modules/sd_hijack.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 65414518..d819c01c 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -20,7 +20,7 @@ def split_cross_attention_forward_v1(self, x, context=None, mask=None): q = self.to_q(x)
context = default(context, x)
- k = self.to_k(context)
+ k = self.to_k(context) * self.scale
v = self.to_v(context)
del context, x
@@ -85,7 +85,7 @@ def split_cross_attention_forward(self, x, context=None, mask=None): slice_size = q.shape[1] // steps if (q.shape[1] % steps) == 0 else q.shape[1]
for i in range(0, q.shape[1], slice_size):
end = i + slice_size
- s1 = einsum('b i d, b j d -> b i j', q[:, i:end], k) * self.scale
+ s1 = einsum('b i d, b j d -> b i j', q[:, i:end], k)
s2 = s1.softmax(dim=-1, dtype=q.dtype)
del s1
|