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
ab50909d
Unverified
Commit
ab50909d
authored
Oct 28, 2021
by
S Harish
Committed by
GitHub
Oct 28, 2021
Browse files
Remove F.complex_norm and T.ComplexNorm (#1942)
parent
7e5f8021
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
109 deletions
+0
-109
docs/source/functional.rst
docs/source/functional.rst
+0
-11
docs/source/transforms.rst
docs/source/transforms.rst
+0
-10
test/torchaudio_unittest/functional/functional_impl.py
test/torchaudio_unittest/functional/functional_impl.py
+0
-10
test/torchaudio_unittest/functional/torchscript_consistency_impl.py
...audio_unittest/functional/torchscript_consistency_impl.py
+0
-8
test/torchaudio_unittest/transforms/torchscript_consistency_impl.py
...audio_unittest/transforms/torchscript_consistency_impl.py
+0
-4
torchaudio/functional/__init__.py
torchaudio/functional/__init__.py
+0
-2
torchaudio/functional/functional.py
torchaudio/functional/functional.py
+0
-27
torchaudio/transforms.py
torchaudio/transforms.py
+0
-37
No files found.
docs/source/functional.rst
View file @
ab50909d
...
@@ -71,17 +71,6 @@ resample
...
@@ -71,17 +71,6 @@ resample
.. autofunction:: resample
.. autofunction:: resample
:hidden:`Complex Utility`
~~~~~~~~~~~~~~~~~~~~~~~~~
Utilities for pseudo complex tensor. This is not for the native complex dtype, such as `cfloat64`, but for tensors with real-value type and have extra dimension at the end for real and imaginary parts.
complex_norm
------------
.. autofunction:: complex_norm
:hidden:`Filtering`
:hidden:`Filtering`
~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~
...
...
docs/source/transforms.rst
View file @
ab50909d
...
@@ -88,16 +88,6 @@ Transforms are common audio transforms. They can be chained together using :clas
...
@@ -88,16 +88,6 @@ Transforms are common audio transforms. They can be chained together using :clas
.. automethod:: forward
.. automethod:: forward
:hidden:`Complex Utility`
~~~~~~~~~~~~~~~~~~~~~~~~~
:hidden:`ComplexNorm`
---------------------
.. autoclass:: ComplexNorm
.. automethod:: forward
:hidden:`Feature Extractions`
:hidden:`Feature Extractions`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
test/torchaudio_unittest/functional/functional_impl.py
View file @
ab50909d
...
@@ -319,16 +319,6 @@ class Functional(TestBaseMixin):
...
@@ -319,16 +319,6 @@ class Functional(TestBaseMixin):
f
"No values were close to the limit. Did it over-clamp?
\n
{
decibels
}
"
f
"No values were close to the limit. Did it over-clamp?
\n
{
decibels
}
"
)
)
@
parameterized
.
expand
(
list
(
itertools
.
product
([(
1
,
2
,
1025
,
400
,
2
),
(
1025
,
400
,
2
)],
[
1
,
2
,
0.7
]))
)
def
test_complex_norm
(
self
,
shape
,
power
):
torch
.
random
.
manual_seed
(
42
)
complex_tensor
=
torch
.
randn
(
*
shape
,
dtype
=
self
.
dtype
,
device
=
self
.
device
)
expected_norm_tensor
=
complex_tensor
.
pow
(
2
).
sum
(
-
1
).
pow
(
power
/
2
)
norm_tensor
=
F
.
complex_norm
(
complex_tensor
,
power
)
self
.
assertEqual
(
norm_tensor
,
expected_norm_tensor
,
atol
=
1e-5
,
rtol
=
1e-5
)
@
parameterized
.
expand
(
@
parameterized
.
expand
(
list
(
itertools
.
product
([(
2
,
1025
,
400
),
(
1
,
201
,
100
)],
[
100
],
[
0.
,
30.
],
[
1
,
2
]))
list
(
itertools
.
product
([(
2
,
1025
,
400
),
(
1
,
201
,
100
)],
[
100
],
[
0.
,
30.
],
[
1
,
2
]))
)
)
...
...
test/torchaudio_unittest/functional/torchscript_consistency_impl.py
View file @
ab50909d
...
@@ -223,14 +223,6 @@ class Functional(TempDirMixin, TestBaseMixin):
...
@@ -223,14 +223,6 @@ class Functional(TempDirMixin, TestBaseMixin):
tensor
=
torch
.
rand
((
1
,
10
))
tensor
=
torch
.
rand
((
1
,
10
))
self
.
_assert_consistency
(
func
,
tensor
)
self
.
_assert_consistency
(
func
,
tensor
)
def
test_complex_norm
(
self
):
def
func
(
tensor
):
power
=
2.
return
F
.
complex_norm
(
tensor
,
power
)
tensor
=
torch
.
randn
(
1
,
2
,
1025
,
400
,
2
)
self
.
_assert_consistency
(
func
,
tensor
)
def
test_mask_along_axis
(
self
):
def
test_mask_along_axis
(
self
):
def
func
(
tensor
):
def
func
(
tensor
):
mask_param
=
100
mask_param
=
100
...
...
test/torchaudio_unittest/transforms/torchscript_consistency_impl.py
View file @
ab50909d
...
@@ -86,10 +86,6 @@ class Transforms(TestBaseMixin):
...
@@ -86,10 +86,6 @@ class Transforms(TestBaseMixin):
tensor
=
common_utils
.
get_whitenoise
(
sample_rate
=
sr1
)
tensor
=
common_utils
.
get_whitenoise
(
sample_rate
=
sr1
)
self
.
_assert_consistency
(
T
.
Resample
(
sr1
,
sr2
),
tensor
)
self
.
_assert_consistency
(
T
.
Resample
(
sr1
,
sr2
),
tensor
)
def
test_ComplexNorm
(
self
):
tensor
=
torch
.
rand
((
1
,
2
,
201
,
2
))
self
.
_assert_consistency
(
T
.
ComplexNorm
(),
tensor
)
def
test_MuLawEncoding
(
self
):
def
test_MuLawEncoding
(
self
):
tensor
=
common_utils
.
get_whitenoise
()
tensor
=
common_utils
.
get_whitenoise
()
self
.
_assert_consistency
(
T
.
MuLawEncoding
(),
tensor
)
self
.
_assert_consistency
(
T
.
MuLawEncoding
(),
tensor
)
...
...
torchaudio/functional/__init__.py
View file @
ab50909d
from
.functional
import
(
from
.functional
import
(
amplitude_to_DB
,
amplitude_to_DB
,
complex_norm
,
compute_deltas
,
compute_deltas
,
compute_kaldi_pitch
,
compute_kaldi_pitch
,
create_dct
,
create_dct
,
...
@@ -52,7 +51,6 @@ from .filtering import (
...
@@ -52,7 +51,6 @@ from .filtering import (
__all__
=
[
__all__
=
[
'amplitude_to_DB'
,
'amplitude_to_DB'
,
'complex_norm'
,
'compute_deltas'
,
'compute_deltas'
,
'compute_kaldi_pitch'
,
'compute_kaldi_pitch'
,
'create_dct'
,
'create_dct'
,
...
...
torchaudio/functional/functional.py
View file @
ab50909d
...
@@ -28,7 +28,6 @@ __all__ = [
...
@@ -28,7 +28,6 @@ __all__ = [
"DB_to_amplitude"
,
"DB_to_amplitude"
,
"mu_law_encoding"
,
"mu_law_encoding"
,
"mu_law_decoding"
,
"mu_law_decoding"
,
"complex_norm"
,
"phase_vocoder"
,
"phase_vocoder"
,
'mask_along_axis'
,
'mask_along_axis'
,
'mask_along_axis_iid'
,
'mask_along_axis_iid'
,
...
@@ -722,32 +721,6 @@ def mu_law_decoding(
...
@@ -722,32 +721,6 @@ def mu_law_decoding(
return
x
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."
,
version
=
"0.11"
,
)
def
complex_norm
(
complex_tensor
:
Tensor
,
power
:
float
=
1.0
)
->
Tensor
:
r
"""Compute the norm of complex tensor input.
Args:
complex_tensor (Tensor): Tensor shape of `(..., complex=2)`
power (float, optional): Power of the norm. (Default: `1.0`).
Returns:
Tensor: Power of the normed input tensor. Shape of `(..., )`
"""
# Replace by torch.norm once issue is fixed
# https://github.com/pytorch/pytorch/issues/34279
return
complex_tensor
.
pow
(
2.
).
sum
(
-
1
).
pow
(
0.5
*
power
)
def
phase_vocoder
(
def
phase_vocoder
(
complex_specgrams
:
Tensor
,
complex_specgrams
:
Tensor
,
rate
:
float
,
rate
:
float
,
...
...
torchaudio/transforms.py
View file @
ab50909d
...
@@ -26,7 +26,6 @@ __all__ = [
...
@@ -26,7 +26,6 @@ __all__ = [
'MuLawEncoding'
,
'MuLawEncoding'
,
'MuLawDecoding'
,
'MuLawDecoding'
,
'Resample'
,
'Resample'
,
'ComplexNorm'
,
'TimeStretch'
,
'TimeStretch'
,
'Fade'
,
'Fade'
,
'FrequencyMasking'
,
'FrequencyMasking'
,
...
@@ -900,42 +899,6 @@ class Resample(torch.nn.Module):
...
@@ -900,42 +899,6 @@ class Resample(torch.nn.Module):
self
.
kernel
,
self
.
width
)
self
.
kernel
,
self
.
width
)
class
ComplexNorm
(
torch
.
nn
.
Module
):
r
"""Compute the norm of complex tensor input.
Args:
power (float, optional): Power of the norm. (Default: to ``1.0``)
Example
>>> complex_tensor = ... # Tensor shape of (…, complex=2)
>>> transform = transforms.ComplexNorm(power=2)
>>> complex_norm = transform(complex_tensor)
"""
__constants__
=
[
'power'
]
def
__init__
(
self
,
power
:
float
=
1.0
)
->
None
:
warnings
.
warn
(
'torchaudio.transforms.ComplexNorm has been deprecated '
'and will be removed from future release.'
'Please convert the input Tensor to complex type with `torch.view_as_complex` then '
'use `torch.abs` and `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."
)
super
(
ComplexNorm
,
self
).
__init__
()
self
.
power
=
power
def
forward
(
self
,
complex_tensor
:
Tensor
)
->
Tensor
:
r
"""
Args:
complex_tensor (Tensor): Tensor shape of `(..., complex=2)`.
Returns:
Tensor: norm of the input tensor, shape of `(..., )`.
"""
return
F
.
complex_norm
(
complex_tensor
,
self
.
power
)
class
ComputeDeltas
(
torch
.
nn
.
Module
):
class
ComputeDeltas
(
torch
.
nn
.
Module
):
r
"""Compute delta coefficients of a tensor, usually a spectrogram.
r
"""Compute delta coefficients of a tensor, usually a spectrogram.
...
...
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