Skip to content

Commit

Permalink
support old name
Browse files Browse the repository at this point in the history
  • Loading branch information
zpcore committed Jul 17, 2024
1 parent 33751e7 commit 7bb16fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions torch_xla/experimental/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
FN = TypeVar('FN')


def deprecated(module, new: FN) -> FN:
def deprecated(module, new: FN, old_name=None) -> FN:
already_warned = [False]
old_name = old_name or new.__name__

@functools.wraps(new)
def wrapped(*args, **kwargs):
if not already_warned[0]:
logging.warning(
f'{module.__name__}.{new.__name__} is deprecated. Use {new.__module__}.{new.__name__} instead.'
f'{module.__name__}.{old_name} is deprecated. Use {new.__module__}.{new.__name__} instead.'
)
already_warned[0] = True

Expand Down

0 comments on commit 7bb16fa

Please sign in to comment.