MCPcopy Create free account
hub / github.com/THUDM/GLM / forward

Method forward

mpu/transformer.py:47–54  ·  view source on GitHub ↗
(self, pos_seq, bsz=None)

Source from the content-addressed store, hash-verified

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
57class ParallelCrossAttention(torch.nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected