(self, num_buckets, num_heads, bidirectional, max_dist=128)
| 226 | class T5RelativeEmbedding(nn.Module): |
| 227 | |
| 228 | def __init__(self, num_buckets, num_heads, bidirectional, max_dist=128): |
| 229 | super(T5RelativeEmbedding, self).__init__() |
| 230 | self.num_buckets = num_buckets |
| 231 | self.num_heads = num_heads |
| 232 | self.bidirectional = bidirectional |
| 233 | self.max_dist = max_dist |
| 234 | |
| 235 | # layers |
| 236 | self.embedding = nn.Embedding(num_buckets, num_heads) |
| 237 | |
| 238 | def forward(self, lq, lk): |
| 239 | device = self.embedding.weight.device |