Merge pull request #99 from jialin-zhao/jialin-zhao-xformers-inputs-revised

Update latte.py about the xformers input dims

Former-commit-id: 421b49c351124170ab476e17cba6e45bd7cf706e
This commit is contained in:
lb203
2024-03-09 09:58:51 +08:00
committed by GitHub
+2
View File
@@ -71,6 +71,8 @@ class Attention(nn.Module):
q, k, v = qkv.unbind(0) # make torchscript happy (cannot use tensor as tuple)
if self.attention_mode == 'xformers': # cause loss nan while using with amp
assert q.ndim == 4
q, k, v = q.transpose(1,2), k.transpose(1,2), v.transpose(1,2)
x = xformers.ops.memory_efficient_attention(q, k, v).reshape(B, N, C)
elif self.attention_mode == 'flash':