rescale values to prevent linear attention from overflowing in fp16 setting

This commit is contained in:
Phil Wang
2022-07-27 12:25:40 -07:00
parent 6b504c4ae9
commit 12f95b33d8
2 changed files with 3 additions and 1 deletions
@@ -211,6 +211,8 @@ class LinearAttention(nn.Module):
k = k.softmax(dim = -1)
q = q * self.scale
v = v / (h * w)
context = torch.einsum('b h d n, b h e n -> b h d e', k, v)
out = torch.einsum('b h d e, b h d n -> b h e n', context, q)
+1 -1
View File
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name = 'denoising-diffusion-pytorch',
packages = find_packages(),
version = '0.26.3',
version = '0.26.4',
license='MIT',
description = 'Denoising Diffusion Probabilistic Models - Pytorch',
author = 'Phil Wang',