瀏覽代碼

[QuartzNet/PyT][Jasper/PyT][HiFi-GAN/PyT][FastPitch/PyT] Mute pyt is_namedtuple warning (1.13.0a0+d321be6)

Adrian Lancucki 3 年之前
父節點
當前提交
206a46c385

+ 27 - 0
PyTorch/SpeechRecognition/Jasper/common/filter_warnings.py

@@ -0,0 +1,27 @@
+# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#           http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import warnings
+
+
+# NGC 22.04-py3 container (PyTorch 1.12.0a0+bd13bc6)
+warnings.filterwarnings(
+    "ignore",
+    message='positional arguments and argument "destination" are deprecated.'
+            ' nn.Module.state_dict will not accept them in the future.')
+
+# 22.08-py3 RC
+warnings.filterwarnings(
+    "ignore",
+    message="is_namedtuple is deprecated, please use the python checks")

+ 0 - 20
PyTorch/SpeechRecognition/Jasper/common/monkey_patch.py

@@ -1,20 +0,0 @@
-import re
-import warnings
-
-import torch
-
-
-major, minor, *_ = re.search('(\d+)\.(\d+)', torch.__version__).groups()
-
-if int(major) >= 1 and int(minor) >= 12:
-    # Mutes 'UserWarning: positional arguments and argument "destination"
-    # are deprecated. nn.Module.state_dict will not accept them in the future.'
-
-    def state_dict(self, *args, **kwargs):
-        warnings.filterwarnings("ignore")
-        ret = self._state_dict(*args, **kwargs)
-        warnings.filterwarnings("default")
-        return ret
-
-    torch.nn.Module._state_dict = torch.nn.Module.state_dict
-    torch.nn.Module.state_dict = state_dict

+ 1 - 1
PyTorch/SpeechRecognition/Jasper/jasper/model.py

@@ -16,7 +16,7 @@ import torch
 import torch.nn as nn
 import torch.nn.functional as F
 
-from common import monkey_patch
+from common import filter_warnings
 
 
 activations = {

+ 27 - 0
PyTorch/SpeechRecognition/QuartzNet/common/filter_warnings.py

@@ -0,0 +1,27 @@
+# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#           http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import warnings
+
+
+# NGC 22.04-py3 container (PyTorch 1.12.0a0+bd13bc6)
+warnings.filterwarnings(
+    "ignore",
+    message='positional arguments and argument "destination" are deprecated.'
+            ' nn.Module.state_dict will not accept them in the future.')
+
+# 22.08-py3 RC
+warnings.filterwarnings(
+    "ignore",
+    message="is_namedtuple is deprecated, please use the python checks")

+ 0 - 20
PyTorch/SpeechRecognition/QuartzNet/common/monkey_patch.py

@@ -1,20 +0,0 @@
-import re
-import warnings
-
-import torch
-
-
-major, minor, *_ = re.search('(\d+)\.(\d+)', torch.__version__).groups()
-
-if int(major) >= 1 and int(minor) >= 12:
-    # Mutes 'UserWarning: positional arguments and argument "destination"
-    # are deprecated. nn.Module.state_dict will not accept them in the future.'
-
-    def state_dict(self, *args, **kwargs):
-        warnings.filterwarnings("ignore")
-        ret = self._state_dict(*args, **kwargs)
-        warnings.filterwarnings("default")
-        return ret
-
-    torch.nn.Module._state_dict = torch.nn.Module.state_dict
-    torch.nn.Module.state_dict = state_dict

+ 1 - 1
PyTorch/SpeechRecognition/QuartzNet/quartznet/model.py

@@ -16,7 +16,7 @@ import torch
 import torch.nn as nn
 import torch.nn.functional as F
 
-from common import monkey_patch
+from common import filter_warnings
 
 
 activations = {

+ 27 - 0
PyTorch/SpeechSynthesis/FastPitch/common/filter_warnings.py

@@ -0,0 +1,27 @@
+# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#           http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import warnings
+
+
+# NGC 22.04-py3 container (PyTorch 1.12.0a0+bd13bc6)
+warnings.filterwarnings(
+    "ignore",
+    message='positional arguments and argument "destination" are deprecated.'
+            ' nn.Module.state_dict will not accept them in the future.')
+
+# 22.08-py3 RC
+warnings.filterwarnings(
+    "ignore",
+    message="is_namedtuple is deprecated, please use the python checks")

+ 1 - 1
PyTorch/SpeechSynthesis/FastPitch/fastpitch/model.py

@@ -33,7 +33,7 @@ import torch
 import torch.nn as nn
 import torch.nn.functional as F
 
-from common import monkey_patch
+from common import filter_warnings
 from common.layers import ConvReLUNorm
 from common.utils import mask_from_lens
 from fastpitch.alignment import b_mas, mas_width1

+ 1 - 0
PyTorch/SpeechSynthesis/FastPitch/fastpitch/model_jit.py

@@ -30,6 +30,7 @@ from typing import Optional
 import torch
 from torch import nn as nn
 
+from common import filter_warnings
 from fastpitch.model import TemporalPredictor
 from fastpitch.transformer_jit import FFTransformer
 

+ 27 - 0
PyTorch/SpeechSynthesis/HiFi-GAN/common/filter_warnings.py

@@ -0,0 +1,27 @@
+# Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#           http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import warnings
+
+
+# NGC 22.04-py3 container (PyTorch 1.12.0a0+bd13bc6)
+warnings.filterwarnings(
+    "ignore",
+    message='positional arguments and argument "destination" are deprecated.'
+            ' nn.Module.state_dict will not accept them in the future.')
+
+# 22.08-py3 RC
+warnings.filterwarnings(
+    "ignore",
+    message="is_namedtuple is deprecated, please use the python checks")

+ 1 - 1
PyTorch/SpeechSynthesis/HiFi-GAN/hifigan/models.py

@@ -45,7 +45,7 @@ import torch.nn.functional as F
 from torch.nn import AvgPool1d, Conv1d, Conv2d, ConvTranspose1d
 from torch.nn.utils import remove_weight_norm, spectral_norm, weight_norm
 
-from common import monkey_patch
+from common import filter_warnings
 from common.stft import STFT
 from common.utils import AttrDict, init_weights, get_padding