Skip to content

Commit 6c57850

Browse files
authored
remove dep warnings for lfilter and overdrive (#3961)
1 parent a3fe94e commit 6c57850

File tree

4 files changed

+11
-25
lines changed

4 files changed

+11
-25
lines changed

src/torchaudio/functional/filtering.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from torch import Tensor
77

88
from torchaudio._extension import _IS_TORCHAUDIO_EXT_AVAILABLE
9-
from torchaudio._internal.module_utils import dropping_support
109

1110

1211
def _dB2Linear(x: float) -> float:
@@ -325,7 +324,7 @@ def biquad(waveform: Tensor, b0: float, b1: float, b2: float, a0: float, a1: flo
325324
a1 = torch.as_tensor(a1, dtype=dtype, device=device).view(1)
326325
a2 = torch.as_tensor(a2, dtype=dtype, device=device).view(1)
327326

328-
output_waveform = _lfilter_deprecated(
327+
output_waveform = lfilter(
329328
waveform,
330329
torch.cat([a0, a1, a2]),
331330
torch.cat([b0, b1, b2]),
@@ -699,8 +698,8 @@ def filtfilt(
699698
Tensor: Waveform with dimension of either `(..., num_filters, time)` if ``a_coeffs`` and ``b_coeffs``
700699
are 2D Tensors, or `(..., time)` otherwise.
701700
"""
702-
forward_filtered = _lfilter_deprecated(waveform, a_coeffs, b_coeffs, clamp=False, batching=True)
703-
backward_filtered = _lfilter_deprecated(
701+
forward_filtered = lfilter(waveform, a_coeffs, b_coeffs, clamp=False, batching=True)
702+
backward_filtered = lfilter(
704703
forward_filtered.flip(-1),
705704
a_coeffs,
706705
b_coeffs,
@@ -998,7 +997,7 @@ def _lfilter_core(
998997
_lfilter = _lfilter_core
999998

1000999

1001-
def _lfilter_deprecated(waveform: Tensor, a_coeffs: Tensor, b_coeffs: Tensor, clamp: bool = True, batching: bool = True) -> Tensor:
1000+
def lfilter(waveform: Tensor, a_coeffs: Tensor, b_coeffs: Tensor, clamp: bool = True, batching: bool = True) -> Tensor:
10021001
r"""Perform an IIR filter by evaluating difference equation, using differentiable implementation
10031002
developed separately by *Yu et al.* :cite:`ismir_YuF23` and *Forgione et al.* :cite:`forgione2021dynonet`.
10041003
The gradients of ``a_coeffs`` are computed based on a faster algorithm from :cite:`ycy2024diffapf`.
@@ -1067,7 +1066,6 @@ def _lfilter_deprecated(waveform: Tensor, a_coeffs: Tensor, b_coeffs: Tensor, cl
10671066

10681067
return output
10691068

1070-
lfilter = dropping_support(_lfilter_deprecated)
10711069

10721070
def lowpass_biquad(waveform: Tensor, sample_rate: int, cutoff_freq: float, Q: float = 0.707) -> Tensor:
10731071
r"""Design biquad lowpass filter and perform filtering. Similar to SoX implementation.
@@ -1117,7 +1115,7 @@ def _overdrive_core_loop_generic(
11171115
_overdrive_core_loop_cpu = _overdrive_core_loop_generic
11181116

11191117

1120-
def _overdrive_deprecated(waveform: Tensor, gain: float = 20, colour: float = 20) -> Tensor:
1118+
def overdrive(waveform: Tensor, gain: float = 20, colour: float = 20) -> Tensor:
11211119
r"""Apply a overdrive effect to the audio. Similar to SoX implementation.
11221120
11231121
.. devices:: CPU CUDA
@@ -1172,7 +1170,6 @@ def _overdrive_deprecated(waveform: Tensor, gain: float = 20, colour: float = 20
11721170

11731171
return output_waveform.clamp(min=-1, max=1).view(actual_shape)
11741172

1175-
overdrive = dropping_support(_overdrive_deprecated)
11761173

11771174
def phaser(
11781175
waveform: Tensor,

src/torchaudio/functional/functional.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ def preemphasis(waveform, coeff: float = 0.97) -> torch.Tensor:
24762476
return waveform
24772477

24782478

2479-
def _deemphasis(waveform, coeff: float = 0.97) -> torch.Tensor:
2479+
def deemphasis(waveform, coeff: float = 0.97) -> torch.Tensor:
24802480
r"""De-emphasizes a waveform along its last dimension.
24812481
Inverse of :meth:`preemphasis`. Concretely, for each signal
24822482
:math:`x` in ``waveform``, computes output :math:`y` as
@@ -2498,9 +2498,8 @@ def _deemphasis(waveform, coeff: float = 0.97) -> torch.Tensor:
24982498
"""
24992499
a_coeffs = torch.tensor([1.0, -coeff], dtype=waveform.dtype, device=waveform.device)
25002500
b_coeffs = torch.tensor([1.0, 0.0], dtype=waveform.dtype, device=waveform.device)
2501-
return torchaudio.functional.filtering._lfilter_deprecated(waveform, a_coeffs=a_coeffs, b_coeffs=b_coeffs)
2501+
return torchaudio.functional.filtering.lfilter(waveform, a_coeffs=a_coeffs, b_coeffs=b_coeffs)
25022502

2503-
deemphasis = dropping_support(_deemphasis)
25042503

25052504
def frechet_distance(mu_x, sigma_x, mu_y, sigma_y):
25062505
r"""Computes the Fréchet distance between two multivariate normal distributions :cite:`dowson1982frechet`.

src/torchaudio/transforms/_transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,4 +2135,4 @@ def forward(self, waveform: torch.Tensor) -> torch.Tensor:
21352135
Returns:
21362136
torch.Tensor: De-emphasized waveform, with shape `(..., N)`.
21372137
"""
2138-
return F.functional._deemphasis(waveform, coeff=self.coeff)
2138+
return F.functional.deemphasis(waveform, coeff=self.coeff)

test/torchaudio_unittest/functional/torchscript_consistency_impl.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,7 @@ def test_lfilter(self):
285285
device=waveform.device,
286286
dtype=waveform.dtype,
287287
)
288-
# This is hack for those functions which are deprecated with decorators
289-
# like @deprecated or @dropping_support. Adding the decorators breaks
290-
# TorchScript. So here we use the private function which make the tests
291-
# pass, but that's a lie: the public (deprecated) function doesn't
292-
# support torchscript anymore
293-
self._assert_consistency(F.filtering._lfilter_deprecated, (waveform, a_coeffs, b_coeffs, True, True))
288+
self._assert_consistency(F.lfilter, (waveform, a_coeffs, b_coeffs, True, True))
294289

295290
def test_filtfilt(self):
296291
waveform = common_utils.get_whitenoise(sample_rate=8000)
@@ -490,7 +485,7 @@ def test_perf_biquad_filtering(self):
490485
def func(tensor):
491486
a = torch.tensor([0.7, 0.2, 0.6], device=tensor.device, dtype=tensor.dtype)
492487
b = torch.tensor([0.4, 0.2, 0.9], device=tensor.device, dtype=tensor.dtype)
493-
return F.filtering._lfilter_deprecated(tensor, a, b)
488+
return F.lfilter(tensor, a, b)
494489

495490
self._assert_consistency(func, (waveform,))
496491

@@ -535,12 +530,7 @@ def test_overdrive(self):
535530
def func(tensor):
536531
gain = 30.0
537532
colour = 50.0
538-
# This is hack for those functions which are deprecated with decorators
539-
# like @deprecated or @dropping_support. Adding the decorators breaks
540-
# TorchScript. So here we use the private function which make the tests
541-
# pass, but that's a lie: the public (deprecated) function doesn't
542-
# support torchscript anymore
543-
return F.filtering._overdrive_deprecated(tensor, gain, colour)
533+
return F.overdrive(tensor, gain, colour)
544534

545535
self._assert_consistency(func, (waveform,))
546536

0 commit comments

Comments
 (0)