(self, num_buckets, num_heads, bidirectional, max_dist=128)
| 207 | |
| 208 | class T5RelativeEmbedding(nn.Module): |
| 209 | def __init__(self, num_buckets, num_heads, bidirectional, max_dist=128): |
| 210 | super(T5RelativeEmbedding, self).__init__() |
| 211 | self.num_buckets = num_buckets |
| 212 | self.num_heads = num_heads |
| 213 | self.bidirectional = bidirectional |
| 214 | self.max_dist = max_dist |
| 215 | |
| 216 | # layers |
| 217 | self.embedding = nn.Embedding(num_buckets, num_heads) |
| 218 | |
| 219 | def forward(self, lq, lk): |
| 220 | device = self.embedding.weight.device |