From e648c0605a5e2384131d546217170a20a4bfe74d Mon Sep 17 00:00:00 2001 From: Adrian Lyjak Date: Tue, 18 Feb 2025 13:06:48 -0600 Subject: [PATCH] Add additional onnx compat for https://github.com/pytorch/pytorch/issues/92977 (#104) --- kokoro/istftnet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kokoro/istftnet.py b/kokoro/istftnet.py index e61e510..5e4143e 100644 --- a/kokoro/istftnet.py +++ b/kokoro/istftnet.py @@ -23,7 +23,8 @@ def get_padding(kernel_size, dilation=1): class AdaIN1d(nn.Module): def __init__(self, style_dim, num_features): super().__init__() - self.norm = nn.InstanceNorm1d(num_features, affine=False) + # affine should be False, however there's a bug in the old torch.onnx.export (not newer dynamo) that causes the channel dimension to be lost if affine=False. When affine is true, there's additional learnably parameters. This shouldn't really matter setting it to True, since we're in inference mode + self.norm = nn.InstanceNorm1d(num_features, affine=True) self.fc = nn.Linear(style_dim, num_features*2) def forward(self, x, s):