MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / forward

Method forward

modules/fastspeech/pe.py:23–41  ·  view source on GitHub ↗

:param x: [B, T, 80] :return: [L, B, T, H], [B, T, H]

(self, x)

Source from the content-addressed store, hash-verified

21 self.out_proj = nn.Linear(out_dim, out_dim)
22
23 def forward(self, x):
24 """
25
26 :param x: [B, T, 80]
27 :return: [L, B, T, H], [B, T, H]
28 """
29 padding_mask = x.abs().sum(-1).eq(0).data # [B, T]
30 nonpadding_mask_TB = 1 - padding_mask.float()[:, None, :] # [B, 1, T]
31 x = x.transpose(1, 2)
32 hiddens = []
33 for i, l in enumerate(self.layers):
34 nonpadding_mask_TB = nonpadding_mask_TB[:, :, ::self.strides[i]]
35 x = l(x) * nonpadding_mask_TB
36 hiddens.append(x)
37 hiddens = torch.stack(hiddens, 0) # [L, B, H, T]
38 hiddens = hiddens.transpose(2, 3) # [L, B, T, H]
39 x = self.out_proj(x.transpose(1, 2)) # [B, T, H]
40 x = x * nonpadding_mask_TB.transpose(1, 2)
41 return hiddens, x
42
43
44class ConvBlock(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected