Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
68823423
Unverified
Commit
68823423
authored
Jun 03, 2021
by
moto
Committed by
GitHub
Jun 03, 2021
Browse files
Ignore return_complex when returning real-valued tensor in spectrogram. (#1551)
parent
0166a851
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
15 deletions
+10
-15
torchaudio/functional/functional.py
torchaudio/functional/functional.py
+5
-10
torchaudio/transforms.py
torchaudio/transforms.py
+5
-5
No files found.
torchaudio/functional/functional.py
View file @
68823423
...
@@ -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"
)
...
...
torchaudio/transforms.py
View file @
68823423
...
@@ -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'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment