Skip to content

Commit ab50909

Browse files
authored
Remove F.complex_norm and T.ComplexNorm (#1942)
1 parent 7e5f802 commit ab50909

File tree

8 files changed

+0
-109
lines changed

8 files changed

+0
-109
lines changed

docs/source/functional.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ resample
7171

7272
.. autofunction:: resample
7373

74-
:hidden:`Complex Utility`
75-
~~~~~~~~~~~~~~~~~~~~~~~~~
76-
77-
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.
78-
79-
80-
complex_norm
81-
------------
82-
83-
.. autofunction:: complex_norm
84-
8574

8675
:hidden:`Filtering`
8776
~~~~~~~~~~~~~~~~~~~

docs/source/transforms.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,6 @@ Transforms are common audio transforms. They can be chained together using :clas
8888

8989
.. automethod:: forward
9090

91-
:hidden:`Complex Utility`
92-
~~~~~~~~~~~~~~~~~~~~~~~~~
93-
94-
:hidden:`ComplexNorm`
95-
---------------------
96-
97-
.. autoclass:: ComplexNorm
98-
99-
.. automethod:: forward
100-
10191
:hidden:`Feature Extractions`
10292
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10393

test/torchaudio_unittest/functional/functional_impl.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,6 @@ def test_amplitude_to_DB_top_db_clamp(self, shape):
319319
f"No values were close to the limit. Did it over-clamp?\n{decibels}"
320320
)
321321

322-
@parameterized.expand(
323-
list(itertools.product([(1, 2, 1025, 400, 2), (1025, 400, 2)], [1, 2, 0.7]))
324-
)
325-
def test_complex_norm(self, shape, power):
326-
torch.random.manual_seed(42)
327-
complex_tensor = torch.randn(*shape, dtype=self.dtype, device=self.device)
328-
expected_norm_tensor = complex_tensor.pow(2).sum(-1).pow(power / 2)
329-
norm_tensor = F.complex_norm(complex_tensor, power)
330-
self.assertEqual(norm_tensor, expected_norm_tensor, atol=1e-5, rtol=1e-5)
331-
332322
@parameterized.expand(
333323
list(itertools.product([(2, 1025, 400), (1, 201, 100)], [100], [0., 30.], [1, 2]))
334324
)

test/torchaudio_unittest/functional/torchscript_consistency_impl.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,6 @@ def func(tensor):
223223
tensor = torch.rand((1, 10))
224224
self._assert_consistency(func, tensor)
225225

226-
def test_complex_norm(self):
227-
def func(tensor):
228-
power = 2.
229-
return F.complex_norm(tensor, power)
230-
231-
tensor = torch.randn(1, 2, 1025, 400, 2)
232-
self._assert_consistency(func, tensor)
233-
234226
def test_mask_along_axis(self):
235227
def func(tensor):
236228
mask_param = 100

test/torchaudio_unittest/transforms/torchscript_consistency_impl.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ def test_Resample(self):
8686
tensor = common_utils.get_whitenoise(sample_rate=sr1)
8787
self._assert_consistency(T.Resample(sr1, sr2), tensor)
8888

89-
def test_ComplexNorm(self):
90-
tensor = torch.rand((1, 2, 201, 2))
91-
self._assert_consistency(T.ComplexNorm(), tensor)
92-
9389
def test_MuLawEncoding(self):
9490
tensor = common_utils.get_whitenoise()
9591
self._assert_consistency(T.MuLawEncoding(), tensor)

torchaudio/functional/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .functional import (
22
amplitude_to_DB,
3-
complex_norm,
43
compute_deltas,
54
compute_kaldi_pitch,
65
create_dct,
@@ -52,7 +51,6 @@
5251

5352
__all__ = [
5453
'amplitude_to_DB',
55-
'complex_norm',
5654
'compute_deltas',
5755
'compute_kaldi_pitch',
5856
'create_dct',

torchaudio/functional/functional.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"DB_to_amplitude",
2929
"mu_law_encoding",
3030
"mu_law_decoding",
31-
"complex_norm",
3231
"phase_vocoder",
3332
'mask_along_axis',
3433
'mask_along_axis_iid',
@@ -722,32 +721,6 @@ def mu_law_decoding(
722721
return x
723722

724723

725-
@_mod_utils.deprecated(
726-
"Please convert the input Tensor to complex type with `torch.view_as_complex` then "
727-
"use `torch.abs`. "
728-
"Please refer to https://github.com/pytorch/audio/issues/1337 "
729-
"for more details about torchaudio's plan to migrate to native complex type.",
730-
version="0.11",
731-
)
732-
def complex_norm(
733-
complex_tensor: Tensor,
734-
power: float = 1.0
735-
) -> Tensor:
736-
r"""Compute the norm of complex tensor input.
737-
738-
Args:
739-
complex_tensor (Tensor): Tensor shape of `(..., complex=2)`
740-
power (float, optional): Power of the norm. (Default: `1.0`).
741-
742-
Returns:
743-
Tensor: Power of the normed input tensor. Shape of `(..., )`
744-
"""
745-
746-
# Replace by torch.norm once issue is fixed
747-
# https://github.com/pytorch/pytorch/issues/34279
748-
return complex_tensor.pow(2.).sum(-1).pow(0.5 * power)
749-
750-
751724
def phase_vocoder(
752725
complex_specgrams: Tensor,
753726
rate: float,

torchaudio/transforms.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
'MuLawEncoding',
2727
'MuLawDecoding',
2828
'Resample',
29-
'ComplexNorm',
3029
'TimeStretch',
3130
'Fade',
3231
'FrequencyMasking',
@@ -900,42 +899,6 @@ def forward(self, waveform: Tensor) -> Tensor:
900899
self.kernel, self.width)
901900

902901

903-
class ComplexNorm(torch.nn.Module):
904-
r"""Compute the norm of complex tensor input.
905-
906-
Args:
907-
power (float, optional): Power of the norm. (Default: to ``1.0``)
908-
909-
Example
910-
>>> complex_tensor = ... # Tensor shape of (…, complex=2)
911-
>>> transform = transforms.ComplexNorm(power=2)
912-
>>> complex_norm = transform(complex_tensor)
913-
"""
914-
__constants__ = ['power']
915-
916-
def __init__(self, power: float = 1.0) -> None:
917-
warnings.warn(
918-
'torchaudio.transforms.ComplexNorm has been deprecated '
919-
'and will be removed from future release.'
920-
'Please convert the input Tensor to complex type with `torch.view_as_complex` then '
921-
'use `torch.abs` and `torch.angle`. '
922-
'Please refer to https://github.com/pytorch/audio/issues/1337 '
923-
"for more details about torchaudio's plan to migrate to native complex type."
924-
)
925-
super(ComplexNorm, self).__init__()
926-
self.power = power
927-
928-
def forward(self, complex_tensor: Tensor) -> Tensor:
929-
r"""
930-
Args:
931-
complex_tensor (Tensor): Tensor shape of `(..., complex=2)`.
932-
933-
Returns:
934-
Tensor: norm of the input tensor, shape of `(..., )`.
935-
"""
936-
return F.complex_norm(complex_tensor, self.power)
937-
938-
939902
class ComputeDeltas(torch.nn.Module):
940903
r"""Compute delta coefficients of a tensor, usually a spectrogram.
941904

0 commit comments

Comments
 (0)