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
e911e5eb
Unverified
Commit
e911e5eb
authored
Apr 13, 2021
by
moto
Committed by
GitHub
Apr 13, 2021
Browse files
Add deprecation warnings to functions for complex (#1445)
parent
749c0e39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
torchaudio/functional/functional.py
torchaudio/functional/functional.py
+33
-4
No files found.
torchaudio/functional/functional.py
View file @
e911e5eb
...
...
@@ -84,6 +84,14 @@ def spectrogram(
``n_fft // 2 + 1`` and ``n_fft`` is the number of
Fourier bins, and time is the number of window hops (n_frame).
"""
if
power
is
None
and
not
return_complex
:
warnings
.
warn
(
"The use of pseudo complex type in spectrogram is now deprecated."
"Please migrate to native complex type by providing `return_complex=True`. "
"Please refer to https://github.com/pytorch/audio/issues/1337 "
"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. '
...
...
@@ -525,6 +533,12 @@ def mu_law_decoding(
return
x
@
_mod_utils
.
deprecated
(
"Please convert the input Tensor to complex type with `torch.view_as_complex` then "
"use `torch.abs`. "
"Please refer to https://github.com/pytorch/audio/issues/1337 "
"for more details about torchaudio's plan to migrate to native complex type."
)
def
complex_norm
(
complex_tensor
:
Tensor
,
power
:
float
=
1.0
...
...
@@ -544,6 +558,12 @@ def complex_norm(
return
complex_tensor
.
pow
(
2.
).
sum
(
-
1
).
pow
(
0.5
*
power
)
@
_mod_utils
.
deprecated
(
"Please convert the input Tensor to complex type with `torch.view_as_complex` then "
"use `torch.angle`. "
"Please refer to https://github.com/pytorch/audio/issues/1337 "
"for more details about torchaudio's plan to migrate to native complex type."
)
def
angle
(
complex_tensor
:
Tensor
)
->
Tensor
:
...
...
@@ -621,10 +641,19 @@ def phase_vocoder(
if
rate
==
1.0
:
return
complex_specgrams
if
not
complex_specgrams
.
is_complex
()
and
complex_specgrams
.
size
(
-
1
)
!=
2
:
raise
ValueError
(
"complex_specgrams must be either native complex tensors or "
"real valued tensors with shape (..., 2)"
)
if
not
complex_specgrams
.
is_complex
():
warnings
.
warn
(
"The use of pseudo complex type in `torchaudio.functional.phase_vocoder` and "
"`torchaudio.transforms.TimeStretch` is now deprecated."
"Please migrate to native complex type by converting the input tensor with "
"`torch.view_as_complex`. "
"Please refer to https://github.com/pytorch/audio/issues/1337 "
"for more details about torchaudio's plan to migrate to native complex type."
)
if
complex_specgrams
.
size
(
-
1
)
!=
2
:
raise
ValueError
(
"complex_specgrams must be either native complex tensors or "
"real valued tensors with shape (..., 2)"
)
is_complex
=
complex_specgrams
.
is_complex
()
...
...
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