Skip to content

Commit

Permalink
Merge pull request #33 from GavChap/sdp-attn-fix
Browse files Browse the repository at this point in the history
Update PixArt_blocks.py
  • Loading branch information
city96 authored May 12, 2024
2 parents c2e2f6e + 3824b0d commit 1e5dc8e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion PixArt/models/PixArt_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def forward(self, x, mask=None, HW=None, block_id=None):
q, k, v = map(lambda t: t.transpose(1, 2),(q, k, v),)
x = torch.nn.functional.scaled_dot_product_attention(
q, k, v,
dropout_p=self.attn_drop.p,
attn_mask=attn_bias
).transpose(1, 2).contiguous()
x = x.view(B, N, C)
Expand Down Expand Up @@ -467,4 +468,4 @@ def forward(self, caption, train, force_drop_ids=None):
if (train and use_dropout) or (force_drop_ids is not None):
global_caption, caption = self.token_drop(global_caption, caption, force_drop_ids)
y_embed = self.proj(global_caption)
return y_embed, caption
return y_embed, caption

0 comments on commit 1e5dc8e

Please sign in to comment.