Skip to content

Commit ddd2425

Browse files
authored
Add deprecation warnings to magphase and ComplexNorm (#1492)
1 parent a8fbbda commit ddd2425

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

torchaudio/functional/functional.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,12 @@ def angle(
578578
return torch.atan2(complex_tensor[..., 1], complex_tensor[..., 0])
579579

580580

581+
@_mod_utils.deprecated(
582+
"Please convert the input Tensor to complex type with `torch.view_as_complex` then "
583+
"use `torch.abs` and `torch.angle`. "
584+
"Please refer to https://github.com/pytorch/audio/issues/1337 "
585+
"for more details about torchaudio's plan to migrate to native complex type."
586+
)
581587
def magphase(
582588
complex_tensor: Tensor,
583589
power: float = 1.0

torchaudio/transforms.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import math
4+
import warnings
45
from typing import Callable, Optional
56

67
import torch
@@ -673,6 +674,14 @@ class ComplexNorm(torch.nn.Module):
673674
__constants__ = ['power']
674675

675676
def __init__(self, power: float = 1.0) -> None:
677+
warnings.warn(
678+
'torchaudio.transforms.ComplexNorm has been deprecated '
679+
'and will be removed from future release.'
680+
'Please convert the input Tensor to complex type with `torch.view_as_complex` then '
681+
'use `torch.abs` and `torch.angle`. '
682+
'Please refer to https://github.com/pytorch/audio/issues/1337 '
683+
"for more details about torchaudio's plan to migrate to native complex type."
684+
)
676685
super(ComplexNorm, self).__init__()
677686
self.power = power
678687

0 commit comments

Comments
 (0)