diff --git a/docs/source/functional.rst b/docs/source/functional.rst index 16899815ef..0d22d1f6c1 100644 --- a/docs/source/functional.rst +++ b/docs/source/functional.rst @@ -71,17 +71,6 @@ resample .. autofunction:: resample -:hidden:`Complex Utility` -~~~~~~~~~~~~~~~~~~~~~~~~~ - -Utilities for pseudo complex tensor. This is not for the native complex dtype, such as `cfloat64`, but for tensors with real-value type and have extra dimension at the end for real and imaginary parts. - - -complex_norm ------------- - -.. autofunction:: complex_norm - :hidden:`Filtering` ~~~~~~~~~~~~~~~~~~~ diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst index f05c7eba9e..7e4a193d1d 100644 --- a/docs/source/transforms.rst +++ b/docs/source/transforms.rst @@ -88,16 +88,6 @@ Transforms are common audio transforms. They can be chained together using :clas .. automethod:: forward -:hidden:`Complex Utility` -~~~~~~~~~~~~~~~~~~~~~~~~~ - -:hidden:`ComplexNorm` ---------------------- - -.. autoclass:: ComplexNorm - - .. automethod:: forward - :hidden:`Feature Extractions` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/test/torchaudio_unittest/functional/functional_impl.py b/test/torchaudio_unittest/functional/functional_impl.py index c3bebbf076..b355293235 100644 --- a/test/torchaudio_unittest/functional/functional_impl.py +++ b/test/torchaudio_unittest/functional/functional_impl.py @@ -319,16 +319,6 @@ def test_amplitude_to_DB_top_db_clamp(self, shape): f"No values were close to the limit. Did it over-clamp?\n{decibels}" ) - @parameterized.expand( - list(itertools.product([(1, 2, 1025, 400, 2), (1025, 400, 2)], [1, 2, 0.7])) - ) - def test_complex_norm(self, shape, power): - torch.random.manual_seed(42) - complex_tensor = torch.randn(*shape, dtype=self.dtype, device=self.device) - expected_norm_tensor = complex_tensor.pow(2).sum(-1).pow(power / 2) - norm_tensor = F.complex_norm(complex_tensor, power) - self.assertEqual(norm_tensor, expected_norm_tensor, atol=1e-5, rtol=1e-5) - @parameterized.expand( list(itertools.product([(2, 1025, 400), (1, 201, 100)], [100], [0., 30.], [1, 2])) ) diff --git a/test/torchaudio_unittest/functional/torchscript_consistency_impl.py b/test/torchaudio_unittest/functional/torchscript_consistency_impl.py index 4097b20e34..86719875c6 100644 --- a/test/torchaudio_unittest/functional/torchscript_consistency_impl.py +++ b/test/torchaudio_unittest/functional/torchscript_consistency_impl.py @@ -223,14 +223,6 @@ def func(tensor): tensor = torch.rand((1, 10)) self._assert_consistency(func, tensor) - def test_complex_norm(self): - def func(tensor): - power = 2. - return F.complex_norm(tensor, power) - - tensor = torch.randn(1, 2, 1025, 400, 2) - self._assert_consistency(func, tensor) - def test_mask_along_axis(self): def func(tensor): mask_param = 100 diff --git a/test/torchaudio_unittest/transforms/torchscript_consistency_impl.py b/test/torchaudio_unittest/transforms/torchscript_consistency_impl.py index 27f57adba1..39406549f8 100644 --- a/test/torchaudio_unittest/transforms/torchscript_consistency_impl.py +++ b/test/torchaudio_unittest/transforms/torchscript_consistency_impl.py @@ -86,10 +86,6 @@ def test_Resample(self): tensor = common_utils.get_whitenoise(sample_rate=sr1) self._assert_consistency(T.Resample(sr1, sr2), tensor) - def test_ComplexNorm(self): - tensor = torch.rand((1, 2, 201, 2)) - self._assert_consistency(T.ComplexNorm(), tensor) - def test_MuLawEncoding(self): tensor = common_utils.get_whitenoise() self._assert_consistency(T.MuLawEncoding(), tensor) diff --git a/torchaudio/functional/__init__.py b/torchaudio/functional/__init__.py index ad90516d42..2fc66df69e 100644 --- a/torchaudio/functional/__init__.py +++ b/torchaudio/functional/__init__.py @@ -1,6 +1,5 @@ from .functional import ( amplitude_to_DB, - complex_norm, compute_deltas, compute_kaldi_pitch, create_dct, @@ -52,7 +51,6 @@ __all__ = [ 'amplitude_to_DB', - 'complex_norm', 'compute_deltas', 'compute_kaldi_pitch', 'create_dct', diff --git a/torchaudio/functional/functional.py b/torchaudio/functional/functional.py index c55e61603e..a973230d2a 100644 --- a/torchaudio/functional/functional.py +++ b/torchaudio/functional/functional.py @@ -28,7 +28,6 @@ "DB_to_amplitude", "mu_law_encoding", "mu_law_decoding", - "complex_norm", "phase_vocoder", 'mask_along_axis', 'mask_along_axis_iid', @@ -722,32 +721,6 @@ def mu_law_decoding( return x -@_mod_utils.deprecated( - "Please convert the input Tensor to complex type with `torch.view_as_complex` then " - "use `torch.abs`. " - "Please refer to https://github.com/pytorch/audio/issues/1337 " - "for more details about torchaudio's plan to migrate to native complex type.", - version="0.11", -) -def complex_norm( - complex_tensor: Tensor, - power: float = 1.0 -) -> Tensor: - r"""Compute the norm of complex tensor input. - - Args: - complex_tensor (Tensor): Tensor shape of `(..., complex=2)` - power (float, optional): Power of the norm. (Default: `1.0`). - - Returns: - Tensor: Power of the normed input tensor. Shape of `(..., )` - """ - - # Replace by torch.norm once issue is fixed - # https://github.com/pytorch/pytorch/issues/34279 - return complex_tensor.pow(2.).sum(-1).pow(0.5 * power) - - def phase_vocoder( complex_specgrams: Tensor, rate: float, diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index eae3a50e73..edfacd6186 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -26,7 +26,6 @@ 'MuLawEncoding', 'MuLawDecoding', 'Resample', - 'ComplexNorm', 'TimeStretch', 'Fade', 'FrequencyMasking', @@ -900,42 +899,6 @@ def forward(self, waveform: Tensor) -> Tensor: self.kernel, self.width) -class ComplexNorm(torch.nn.Module): - r"""Compute the norm of complex tensor input. - - Args: - power (float, optional): Power of the norm. (Default: to ``1.0``) - - Example - >>> complex_tensor = ... # Tensor shape of (…, complex=2) - >>> transform = transforms.ComplexNorm(power=2) - >>> complex_norm = transform(complex_tensor) - """ - __constants__ = ['power'] - - def __init__(self, power: float = 1.0) -> None: - warnings.warn( - 'torchaudio.transforms.ComplexNorm has been deprecated ' - 'and will be removed from future release.' - 'Please convert the input Tensor to complex type with `torch.view_as_complex` then ' - 'use `torch.abs` and `torch.angle`. ' - 'Please refer to https://github.com/pytorch/audio/issues/1337 ' - "for more details about torchaudio's plan to migrate to native complex type." - ) - super(ComplexNorm, self).__init__() - self.power = power - - def forward(self, complex_tensor: Tensor) -> Tensor: - r""" - Args: - complex_tensor (Tensor): Tensor shape of `(..., complex=2)`. - - Returns: - Tensor: norm of the input tensor, shape of `(..., )`. - """ - return F.complex_norm(complex_tensor, self.power) - - class ComputeDeltas(torch.nn.Module): r"""Compute delta coefficients of a tensor, usually a spectrogram.