Unverified Commit 68823423 authored by moto's avatar moto Committed by GitHub
Browse files

Ignore return_complex when returning real-valued tensor in spectrogram. (#1551)

parent 0166a851
...@@ -73,11 +73,11 @@ def spectrogram( ...@@ -73,11 +73,11 @@ def spectrogram(
onesided (bool, optional): controls whether to return half of results to onesided (bool, optional): controls whether to return half of results to
avoid redundancy. Default: ``True`` avoid redundancy. Default: ``True``
return_complex (bool, optional): return_complex (bool, optional):
``return_complex = True``, this function returns the resulting Tensor in Indicates whether the resulting complex-valued Tensor should be represented with
complex dtype, otherwise it returns the resulting Tensor in real dtype with extra native complex dtype, such as `torch.cfloat` and `torch.cdouble`, or real dtype
dimension for real and imaginary parts. (see ``torch.view_as_real``). mimicking complex value with an extra dimension for real and imaginary parts.
When ``power`` is provided, the value must be False, as the resulting This argument is only effective when ``power=None``.
Tensor represents real-valued power. See also ``torch.view_as_real``.
Returns: Returns:
Tensor: Dimension (..., freq, time), freq is Tensor: Dimension (..., freq, time), freq is
...@@ -92,11 +92,6 @@ def spectrogram( ...@@ -92,11 +92,6 @@ def spectrogram(
"for more details about torchaudio's plan to migrate to native complex type." "for more details about torchaudio's plan to migrate to native complex type."
) )
if power is not None and return_complex:
raise ValueError(
'When `power` is provided, the return value is real-valued. '
'Therefore, `return_complex` must be False.')
if pad > 0: if pad > 0:
# TODO add "with torch.no_grad():" back when JIT supports it # TODO add "with torch.no_grad():" back when JIT supports it
waveform = torch.nn.functional.pad(waveform, (pad, pad), "constant") waveform = torch.nn.functional.pad(waveform, (pad, pad), "constant")
......
...@@ -60,11 +60,11 @@ class Spectrogram(torch.nn.Module): ...@@ -60,11 +60,11 @@ class Spectrogram(torch.nn.Module):
onesided (bool, optional): controls whether to return half of results to onesided (bool, optional): controls whether to return half of results to
avoid redundancy Default: ``True`` avoid redundancy Default: ``True``
return_complex (bool, optional): return_complex (bool, optional):
``return_complex = True``, this function returns the resulting Tensor in Indicates whether the resulting complex-valued Tensor should be represented with
complex dtype, otherwise it returns the resulting Tensor in real dtype with extra native complex dtype, such as `torch.cfloat` and `torch.cdouble`, or real dtype
dimension for real and imaginary parts. (see ``torch.view_as_real``). mimicking complex value with an extra dimension for real and imaginary parts.
When ``power`` is provided, the value must be False, as the resulting This argument is only effective when ``power=None``.
Tensor represents real-valued power. See also ``torch.view_as_real``.
""" """
__constants__ = ['n_fft', 'win_length', 'hop_length', 'pad', 'power', 'normalized'] __constants__ = ['n_fft', 'win_length', 'hop_length', 'pad', 'power', 'normalized']
......
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