Update splat_attention.py
Browse files- splat_attention.py +3 -1
splat_attention.py
CHANGED
|
@@ -216,6 +216,7 @@ class SplatAttention(nn.Module):
|
|
| 216 |
return self.drop(self.w_o(out))
|
| 217 |
|
| 218 |
|
|
|
|
| 219 |
def _demo():
|
| 220 |
torch.manual_seed(0)
|
| 221 |
dev = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -231,7 +232,7 @@ def _demo():
|
|
| 231 |
if dev == "cuda":
|
| 232 |
import time
|
| 233 |
mha = nn.MultiheadAttention(256, 8, batch_first=True).to(dev)
|
| 234 |
-
for L, B in [(128, 32), (2048,
|
| 235 |
xx = torch.randn(B, L, 256, device=dev, requires_grad=True)
|
| 236 |
def t(fn, n=10):
|
| 237 |
for _ in range(3):
|
|
@@ -250,5 +251,6 @@ def _demo():
|
|
| 250 |
"head_gates=True for learnable attenuation)")
|
| 251 |
|
| 252 |
|
|
|
|
| 253 |
if __name__ == "__main__":
|
| 254 |
_demo()
|
|
|
|
| 216 |
return self.drop(self.w_o(out))
|
| 217 |
|
| 218 |
|
| 219 |
+
|
| 220 |
def _demo():
|
| 221 |
torch.manual_seed(0)
|
| 222 |
dev = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 232 |
if dev == "cuda":
|
| 233 |
import time
|
| 234 |
mha = nn.MultiheadAttention(256, 8, batch_first=True).to(dev)
|
| 235 |
+
for L, B in [(128, 256), (256, 32), (512, 32), (768, 32), (1024, 32), (1280, 32), (2048, 32), (4096, 32), (8192, 32)]:
|
| 236 |
xx = torch.randn(B, L, 256, device=dev, requires_grad=True)
|
| 237 |
def t(fn, n=10):
|
| 238 |
for _ in range(3):
|
|
|
|
| 251 |
"head_gates=True for learnable attenuation)")
|
| 252 |
|
| 253 |
|
| 254 |
+
|
| 255 |
if __name__ == "__main__":
|
| 256 |
_demo()
|