(self, pos_seq, bsz=None)
| 45 | self.register_buffer('inv_freq', inv_freq) |
| 46 | |
| 47 | def forward(self, pos_seq, bsz=None): |
| 48 | sinusoid_inp = torch.ger(pos_seq, self.inv_freq) |
| 49 | pos_emb = torch.cat([sinusoid_inp.sin(), sinusoid_inp.cos()], dim=-1) |
| 50 | |
| 51 | if bsz is not None: |
| 52 | return pos_emb[None, :, :].expand(bsz, -1, -1) |
| 53 | else: |
| 54 | return pos_emb[None, :, :] |
| 55 | |
| 56 | |
| 57 | class ParallelCrossAttention(torch.nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected