MCPcopy Create free account
hub / github.com/MeiGen-AI/MultiTalk / forward

Method forward

wan/modules/t5.py:238–248  ·  view source on GitHub ↗
(self, lq, lk)

Source from the content-addressed store, hash-verified

236 self.embedding = nn.Embedding(num_buckets, num_heads)
237
238 def forward(self, lq, lk):
239 device = self.embedding.weight.device
240 # rel_pos = torch.arange(lk).unsqueeze(0).to(device) - \
241 # torch.arange(lq).unsqueeze(1).to(device)
242 rel_pos = torch.arange(lk, device=device).unsqueeze(0) - \
243 torch.arange(lq, device=device).unsqueeze(1)
244 rel_pos = self._relative_position_bucket(rel_pos)
245 rel_pos_embeds = self.embedding(rel_pos)
246 rel_pos_embeds = rel_pos_embeds.permute(2, 0, 1).unsqueeze(
247 0) # [1, N, Lq, Lk]
248 return rel_pos_embeds.contiguous()
249
250 def _relative_position_bucket(self, rel_pos):
251 # preprocess

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected