Skip to content

Commit

Permalink
slight efficiency gain by using += in attention.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed Sep 11, 2022
1 parent b86a1de commit 7708f4f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ldm/modules/attention.py
Expand Up @@ -244,9 +244,9 @@ def forward(self, x, context=None):

def _forward(self, x, context=None):
x = x.contiguous() if x.device.type == 'mps' else x
x = self.attn1(self.norm1(x)) + x
x = self.attn2(self.norm2(x), context=context) + x
x = self.ff(self.norm3(x)) + x
x += self.attn1(self.norm1(x))
x += self.attn2(self.norm2(x), context=context)
x += self.ff(self.norm3(x))
return x


Expand Down

0 comments on commit 7708f4f

Please sign in to comment.