99from common_utils import AudioBackendScope , BACKENDS , create_temp_assets_dir
1010
1111
12- def _test_torchscript_functional (py_method , * args , ** kwargs ):
13- jit_method = torch .jit .script (py_method )
14-
15- jit_out = jit_method (* args , ** kwargs )
16- py_out = py_method (* args , ** kwargs )
17-
18- assert torch .allclose (jit_out , py_out )
19-
20-
2112class TestFunctionalFiltering (unittest .TestCase ):
2213 test_dirpath , test_dir = create_temp_assets_dir ()
2314
@@ -88,7 +79,6 @@ def _test_lfilter(self, waveform, device):
8879 assert len (output_waveform .size ()) == 2
8980 assert output_waveform .size (0 ) == waveform .size (0 )
9081 assert output_waveform .size (1 ) == waveform .size (1 )
91- _test_torchscript_functional (F .lfilter , waveform , a_coeffs , b_coeffs )
9282
9383 def test_lfilter (self ):
9484
@@ -189,7 +179,6 @@ def test_lowpass(self):
189179 output_waveform = F .lowpass_biquad (waveform , sample_rate , CUTOFF_FREQ )
190180
191181 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
192- _test_torchscript_functional (F .lowpass_biquad , waveform , sample_rate , CUTOFF_FREQ )
193182
194183 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
195184 @AudioBackendScope ("sox" )
@@ -211,7 +200,6 @@ def test_highpass(self):
211200
212201 # TBD - this fails at the 1e-4 level, debug why
213202 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-3 )
214- _test_torchscript_functional (F .highpass_biquad , waveform , sample_rate , CUTOFF_FREQ )
215203
216204 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
217205 @AudioBackendScope ("sox" )
@@ -233,7 +221,6 @@ def test_allpass(self):
233221 output_waveform = F .allpass_biquad (waveform , sample_rate , CENTRAL_FREQ , Q )
234222
235223 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
236- _test_torchscript_functional (F .allpass_biquad , waveform , sample_rate , CENTRAL_FREQ , Q )
237224
238225 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
239226 @AudioBackendScope ("sox" )
@@ -256,7 +243,6 @@ def test_bandpass_with_csg(self):
256243 output_waveform = F .bandpass_biquad (waveform , sample_rate , CENTRAL_FREQ , Q , CONST_SKIRT_GAIN )
257244
258245 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
259- _test_torchscript_functional (F .bandpass_biquad , waveform , sample_rate , CENTRAL_FREQ , Q , CONST_SKIRT_GAIN )
260246
261247 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
262248 @AudioBackendScope ("sox" )
@@ -279,7 +265,6 @@ def test_bandpass_without_csg(self):
279265 output_waveform = F .bandpass_biquad (waveform , sample_rate , CENTRAL_FREQ , Q , CONST_SKIRT_GAIN )
280266
281267 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
282- _test_torchscript_functional (F .bandpass_biquad , waveform , sample_rate , CENTRAL_FREQ , Q , CONST_SKIRT_GAIN )
283268
284269 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
285270 @AudioBackendScope ("sox" )
@@ -301,7 +286,6 @@ def test_bandreject(self):
301286 output_waveform = F .bandreject_biquad (waveform , sample_rate , CENTRAL_FREQ , Q )
302287
303288 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
304- _test_torchscript_functional (F .bandreject_biquad , waveform , sample_rate , CENTRAL_FREQ , Q )
305289
306290 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
307291 @AudioBackendScope ("sox" )
@@ -324,7 +308,6 @@ def test_band_with_noise(self):
324308 output_waveform = F .band_biquad (waveform , sample_rate , CENTRAL_FREQ , Q , NOISE )
325309
326310 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
327- _test_torchscript_functional (F .band_biquad , waveform , sample_rate , CENTRAL_FREQ , Q , NOISE )
328311
329312 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
330313 @AudioBackendScope ("sox" )
@@ -347,7 +330,6 @@ def test_band_without_noise(self):
347330 output_waveform = F .band_biquad (waveform , sample_rate , CENTRAL_FREQ , Q , NOISE )
348331
349332 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
350- _test_torchscript_functional (F .band_biquad , waveform , sample_rate , CENTRAL_FREQ , Q , NOISE )
351333
352334 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
353335 @AudioBackendScope ("sox" )
@@ -370,7 +352,6 @@ def test_treble(self):
370352 output_waveform = F .treble_biquad (waveform , sample_rate , GAIN , CENTRAL_FREQ , Q )
371353
372354 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
373- _test_torchscript_functional (F .treble_biquad , waveform , sample_rate , GAIN , CENTRAL_FREQ , Q )
374355
375356 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
376357 @AudioBackendScope ("sox" )
@@ -389,7 +370,6 @@ def test_deemph(self):
389370 output_waveform = F .deemph_biquad (waveform , sample_rate )
390371
391372 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
392- _test_torchscript_functional (F .deemph_biquad , waveform , sample_rate )
393373
394374 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
395375 @AudioBackendScope ("sox" )
@@ -408,7 +388,6 @@ def test_riaa(self):
408388 output_waveform = F .riaa_biquad (waveform , sample_rate )
409389
410390 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
411- _test_torchscript_functional (F .riaa_biquad , waveform , sample_rate )
412391
413392 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
414393 @AudioBackendScope ("sox" )
@@ -431,7 +410,6 @@ def test_equalizer(self):
431410 output_waveform = F .equalizer_biquad (waveform , sample_rate , CENTER_FREQ , GAIN , Q )
432411
433412 assert torch .allclose (sox_output_waveform , output_waveform , atol = 1e-4 )
434- _test_torchscript_functional (F .equalizer_biquad , waveform , sample_rate , CENTER_FREQ , GAIN , Q )
435413
436414 @unittest .skipIf ("sox" not in BACKENDS , "sox not available" )
437415 @AudioBackendScope ("sox" )
@@ -458,9 +436,6 @@ def test_perf_biquad_filtering(self):
458436 )
459437
460438 assert torch .allclose (waveform_sox_out , waveform_lfilter_out , atol = 1e-4 )
461- _test_torchscript_functional (
462- F .lfilter , waveform , torch .tensor ([a0 , a1 , a2 ]), torch .tensor ([b0 , b1 , b2 ])
463- )
464439
465440
466441if __name__ == "__main__" :
0 commit comments