Skip to content

Commit

Permalink
refactor: remove unnecessary transpositions (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
charSLee013 authored Jun 28, 2024
1 parent bda9b5a commit e04ec2f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ChatTTS/model/dvae.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,16 @@ def __init__(
)
self.conv_out = nn.Conv1d(hidden, odim, kernel_size=1, bias=False)

def forward(self, input: torch.Tensor, conditioning=None) -> torch.Tensor:
# B, T, C
x = input.transpose_(1, 2)
def forward(self, x: torch.Tensor, conditioning=None) -> torch.Tensor:
# B, C, T
y = self.conv_in(x)
del x
for f in self.decoder_block:
y = f(y, conditioning)

x = self.conv_out(y)
del y
return x.transpose_(1, 2)
return x


class DVAE(nn.Module):
Expand Down Expand Up @@ -214,8 +213,8 @@ def forward(self, inp: torch.Tensor) -> torch.Tensor:

dec_out = self.out_conv(
self.decoder(
input=vq_feats.transpose_(1, 2),
).transpose_(1, 2),
x=vq_feats,
),
)

return torch.mul(dec_out, self.coef, out=dec_out)

0 comments on commit e04ec2f

Please sign in to comment.