示例#1
0
    def complex_dtype(self):
        if self.dtype in ['float32', 'float', torch.float, torch.float32]:
            return torch.cfloat
        if self.dtype in ['float64', 'double', torch.double, torch.float64]:
            return torch.cdouble
        raise ValueError(f'No corresponding complex dtype for {self.dtype}')


class TorchaudioTestCase(TestBaseMixin, PytorchTestCase):
    pass


def skipIfNoExec(cmd):
    return unittest.skipIf(shutil.which(cmd) is None, f'`{cmd}` is not available')


def skipIfNoModule(module, display_name=None):
    display_name = display_name or module
    return unittest.skipIf(not is_module_available(module), f'"{display_name}" is not available')


skipIfNoCuda = unittest.skipIf(not torch.cuda.is_available(), reason='CUDA not available')
skipIfNoSox = unittest.skipIf(not is_sox_available(), reason='Sox not available')
skipIfNoKaldi = unittest.skipIf(not is_kaldi_available(), reason='Kaldi not available')
skipIfRocm = unittest.skipIf(os.getenv('TORCHAUDIO_TEST_WITH_ROCM', '0') == '1',
                             reason="test doesn't currently work on the ROCm stack")
skipIfNoQengine = unittest.skipIf(
    'fbgemm' not in torch.backends.quantized.supported_engines,
    reason="`fbgemm` is not available."
)
示例#2
0
    backend = None

    def setUp(self):
        super().setUp()
        set_audio_backend(self.backend)


class TorchaudioTestCase(TestBaseMixin, PytorchTestCase):
    pass


def skipIfNoExec(cmd):
    return unittest.skipIf(
        shutil.which(cmd) is None, f'`{cmd}` is not available')


def skipIfNoModule(module, display_name=None):
    display_name = display_name or module
    return unittest.skipIf(not is_module_available(module),
                           f'"{display_name}" is not available')


skipIfNoSoxBackend = unittest.skipIf(
    'sox' not in torchaudio.list_audio_backends(), 'Sox backend not available')
skipIfNoCuda = unittest.skipIf(not torch.cuda.is_available(),
                               reason='CUDA not available')
skipIfNoSox = unittest.skipIf(not is_sox_available(),
                              reason='Sox not available')
skipIfNoKaldi = unittest.skipIf(not is_kaldi_available(),
                                reason='Kaldi not available')