(self, x, pos, cond)
| 476 | return f"d_head={self.d_head}, window_size={self.window_size}, window_shift={self.window_shift}" |
| 477 | |
| 478 | def forward(self, x, pos, cond): |
| 479 | skip = x |
| 480 | x = self.norm(x, cond) |
| 481 | qkv = self.qkv_proj(x) |
| 482 | q, k, v = rearrange(qkv, "n h w (t nh e) -> t n nh h w e", t=3, e=self.d_head) |
| 483 | q, k = scale_for_cosine_sim(q, k, self.scale[:, None, None, None], 1e-6) |
| 484 | theta = self.pos_emb(pos).movedim(-2, -4) |
| 485 | q = apply_rotary_emb_(q, theta) |
| 486 | k = apply_rotary_emb_(k, theta) |
| 487 | x = apply_window_attention(self.window_size, self.window_shift, q, k, v, scale=1.0) |
| 488 | x = rearrange(x, "n nh h w e -> n h w (nh e)") |
| 489 | x = self.dropout(x) |
| 490 | x = self.out_proj(x) |
| 491 | return x + skip |
| 492 | |
| 493 | |
| 494 | class FeedForwardBlock(nn.Module): |
nothing calls this directly
no test coverage detected