github-actions[bot] commited on
Commit
a1f9c6d
·
1 Parent(s): b4dbe35

Sync from GitHub: f2794dbe30dd2abbd389ebcf9d4965ad9762592a

Browse files
Files changed (1) hide show
  1. rgbddepth/flexible_attention.py +3 -1
rgbddepth/flexible_attention.py CHANGED
@@ -98,7 +98,9 @@ class FlexibleCrossAttention(nn.MultiheadAttention):
98
 
99
  # Apply xFormers memory-efficient attention
100
  # This is significantly faster and uses less memory than standard attention
101
- out = xops.memory_efficient_attention(q, k, v)
 
 
102
 
103
  # Reshape back: [B, N, H, C//H] -> [B, N, C]
104
  out = out.reshape(B, N, C)
 
98
 
99
  # Apply xFormers memory-efficient attention
100
  # This is significantly faster and uses less memory than standard attention
101
+ # Scale is 1/sqrt(head_dim) as per standard scaled dot-product attention
102
+ scale = self.head_dim**-0.5
103
+ out = xops.memory_efficient_attention(q, k, v, scale=scale)
104
 
105
  # Reshape back: [B, N, H, C//H] -> [B, N, C]
106
  out = out.reshape(B, N, C)