From 05dd6184e2032781ada49fe298015213d17f8a47 Mon Sep 17 00:00:00 2001 From: moto <855818+mthrok@users.noreply.github.com> Date: Thu, 6 May 2021 03:44:52 +0000 Subject: [PATCH] Add deprecation warnings to magphase and ComplexNorm --- torchaudio/functional/functional.py | 6 ++++++ torchaudio/transforms.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/torchaudio/functional/functional.py b/torchaudio/functional/functional.py index 825a07e5a9..b7d9b112b8 100644 --- a/torchaudio/functional/functional.py +++ b/torchaudio/functional/functional.py @@ -578,6 +578,12 @@ def angle( return torch.atan2(complex_tensor[..., 1], complex_tensor[..., 0]) +@_mod_utils.deprecated( + "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." +) def magphase( complex_tensor: Tensor, power: float = 1.0 diff --git a/torchaudio/transforms.py b/torchaudio/transforms.py index a04592f2c4..fa38118043 100644 --- a/torchaudio/transforms.py +++ b/torchaudio/transforms.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import math +import warnings from typing import Callable, Optional import torch @@ -673,6 +674,14 @@ class ComplexNorm(torch.nn.Module): __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