-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resample can't process waveforms whose dtype=int16 #2294
Comments
Hi @Mashiro009 The resample transform caches the kernel at the construction, and by default the cached kernel is resampler = torchaudio.transforms.Resample(...)
resampler.to(dtype=<DTYPE>, device=<DEVICE>) However, integer type is not supported by the underlying PyTorch features (
similarly trying with
I gave some thought but since the underlying convolution implementation requires the same dtype across the input and the kernel, to perform resample on int type, the kernel has to be on int type. But if the kernel is on int type, it cannot express the sinc interpolation kernel. So I do not think it is plausible to perform resampling with integer type. Keeping the |
Hi @mthrok Thanks for your effort. Is it possible to add codes later to limit or handle this situation, rather than letting conv1d report the error? |
@carolineechen Could you follow-up on this? There is not |
Summary: Resolves pytorch#2294 Raise an error if the waveform to be resampled is not of floating point type. The `conv1d` operation used in resampling and `nn.Module` used for the transforms don't support integer type. Pull Request resolved: pytorch#2318 Reviewed By: mthrok Differential Revision: D35379276 Pulled By: carolineechen fbshipit-source-id: f8f9539a051e7c3d22bcb45ca6a34aaef67abed0
🐛 Describe the bug
I found that the default input for torchaudio Resample function is audio(waveforms) whose dtype=float32.
Therefore, Resample can't process waveforms whose dtype=int16.
I'm not quite sure whether this can be considered as a bug.
To Reproduce
The following problem will be encountered, because kernel.dtype=float32, but waveform.dtype=int16
This is a type conflict when used as parameters for the
torch.nn.functional.conv1d
functionVersions
Versions of relevant libraries:
[pip3] numpy==1.22.3
[pip3] torch==1.10.0
[pip3] torchaudio==0.10.0
[pip3] torchvision==0.11.1
[conda] blas 1.0 mkl
[conda] cpuonly 2.0 0 pytorch
[conda] ffmpeg 4.3 hf484d3e_0 pytorch
[conda] mkl 2021.4.0 h06a4308_640
[conda] mkl-service 2.4.0 py38h497a2fe_0 conda-forge
[conda] mkl_fft 1.3.1 py38hd3c417c_0
[conda] mkl_random 1.2.2 py38h1abd341_0 conda-forge
[conda] numpy 1.22.3 pypi_0 pypi
[conda] numpy-base 1.21.2 py38h79a1101_0
[conda] pytorch 1.10.0 py3.8_cpu_0 pytorch
[conda] pytorch-mutex 1.0 cpu pytorch
[conda] torchaudio 0.10.0 py38_cpu [cpuonly] pytorch
[conda] torchvision 0.11.1 py38_cpu [cpuonly] pytorch
The text was updated successfully, but these errors were encountered: