"...text-generation-inference.git" did not exist on "0d96468ebb1ca0141d7a23b2fdfcef9a7ef7bb81"
Unverified Commit af88b925 authored by moto's avatar moto Committed by GitHub
Browse files

Move lfilter basic test to test_functional (#539)

parent 6304db75
...@@ -10,6 +10,42 @@ import pytest ...@@ -10,6 +10,42 @@ import pytest
import common_utils import common_utils
class _LfilterMixin:
device = None
dtype = None
def test_simple(self):
"""
Create a very basic signal,
Then make a simple 4th order delay
The output should be same as the input but shifted
"""
torch.random.manual_seed(42)
waveform = torch.rand(2, 44100 * 1, dtype=self.dtype, device=self.device)
b_coeffs = torch.tensor([0, 0, 0, 1], dtype=self.dtype, device=self.device)
a_coeffs = torch.tensor([1, 0, 0, 0], dtype=self.dtype, device=self.device)
output_waveform = F.lfilter(waveform, a_coeffs, b_coeffs)
torch.testing.assert_allclose(output_waveform[:, 3:], waveform[:, 0:-3], atol=1e-5, rtol=1e-5)
class TestLfilterFloat32CPU(_LfilterMixin, unittest.TestCase):
device = torch.device('cpu')
dtype = torch.float32
class TestLfilterFloat64CPU(_LfilterMixin, unittest.TestCase):
device = torch.device('cpu')
dtype = torch.float64
@unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
class TestLfilterFloat32CUDA(_LfilterMixin, unittest.TestCase):
device = torch.device('cuda')
dtype = torch.float32
class TestComputeDeltas(unittest.TestCase): class TestComputeDeltas(unittest.TestCase):
"""Test suite for correctness of compute_deltas""" """Test suite for correctness of compute_deltas"""
def test_one_channel(self): def test_one_channel(self):
......
...@@ -12,31 +12,6 @@ from common_utils import AudioBackendScope, BACKENDS, create_temp_assets_dir ...@@ -12,31 +12,6 @@ from common_utils import AudioBackendScope, BACKENDS, create_temp_assets_dir
class TestFunctionalFiltering(unittest.TestCase): class TestFunctionalFiltering(unittest.TestCase):
test_dirpath, test_dir = create_temp_assets_dir() test_dirpath, test_dir = create_temp_assets_dir()
def _test_lfilter_basic(self, dtype, device):
"""
Create a very basic signal,
Then make a simple 4th order delay
The output should be same as the input but shifted
"""
torch.random.manual_seed(42)
waveform = torch.rand(2, 44100 * 1, dtype=dtype, device=device)
b_coeffs = torch.tensor([0, 0, 0, 1], dtype=dtype, device=device)
a_coeffs = torch.tensor([1, 0, 0, 0], dtype=dtype, device=device)
output_waveform = F.lfilter(waveform, a_coeffs, b_coeffs)
torch.testing.assert_allclose(output_waveform[:, 3:], waveform[:, 0:-3], atol=1e-5, rtol=1e-5)
def test_lfilter_basic(self):
self._test_lfilter_basic(torch.float32, torch.device("cpu"))
def test_lfilter_basic_double(self):
self._test_lfilter_basic(torch.float64, torch.device("cpu"))
@unittest.skipIf(not torch.cuda.is_available(), "CUDA not available")
def test_lfilter_basic_gpu(self):
self._test_lfilter_basic(torch.float32, torch.device("cuda:0"))
def _test_lfilter(self, waveform, device): def _test_lfilter(self, waveform, device):
""" """
Design an IIR lowpass filter using scipy.signal filter design Design an IIR lowpass filter using scipy.signal filter design
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment