Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change resampler attention to scale_dot_product_attention #446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Benkovichnikita
Copy link

@Benkovichnikita Benkovichnikita commented Nov 19, 2024

I noticed two issues:

  1. PerceiverAttention consumes a huge amount of memory while calculating an attention map
  2. There are two operations of math.srqt when scale calculating: scale = 1 / math.sqrt(math.sqrt(self.dim_head))

Both of them can be fixed using more effective implementation: F.scaled_dot_product_attention(q, k, v).

PS
If you need scale with two sqrt, it can be provided as an additional argument to F.scaled_dot_product_attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant