Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit083508f

Browse files
committed
cast attention matrix back to original dtype pre-softmax in attention
1 parent7762edd commit083508f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

‎dalle2_pytorch/dalle2_pytorch.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,8 @@ def forward(self, x, mask = None, attn_bias = None):
879879
# attention
880880

881881
attn=sim.softmax(dim=-1,dtype=torch.float32)
882+
attn=attn.type(sim.dtype)
883+
882884
attn=self.dropout(attn)
883885

884886
# aggregate values
@@ -1637,6 +1639,7 @@ def forward(self, x, context, mask = None):
16371639
sim=sim.masked_fill(~mask,max_neg_value)
16381640

16391641
attn=sim.softmax(dim=-1,dtype=torch.float32)
1642+
attn=attn.type(sim.dtype)
16401643

16411644
out=einsum('b h i j, b h j d -> b h i d',attn,v)
16421645
out=rearrange(out,'b h n d -> b n (h d)')

‎dalle2_pytorch/version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__='1.8.3'
1+
__version__='1.8.4'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp