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