|
|
@ -14,6 +14,7 @@
|
|
|
|
# ============================================================================
|
|
|
|
# ============================================================================
|
|
|
|
"""Providing decorators."""
|
|
|
|
"""Providing decorators."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from mindspore import log
|
|
|
|
|
|
|
|
|
|
|
|
def deprecated(version, substitute, use_substitute_name=False):
|
|
|
|
def deprecated(version, substitute, use_substitute_name=False):
|
|
|
|
"""deprecated warning
|
|
|
|
"""deprecated warning
|
|
|
@ -28,8 +29,8 @@ def deprecated(version, substitute, use_substitute_name=False):
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
cls = getattr(args[0], "__class__", None) if args else None
|
|
|
|
cls = getattr(args[0], "__class__", None) if args else None
|
|
|
|
name = cls.__name__ if cls else func.__name__
|
|
|
|
name = cls.__name__ if cls else func.__name__
|
|
|
|
print(f"WARNING: '{name}' is deprecated from version {version} and will be removed in a future version, "
|
|
|
|
log.warning(f"'{name}' is deprecated from version {version} and "
|
|
|
|
f"use '{substitute}' instead.")
|
|
|
|
f"will be removed in a future version, use '{substitute}' instead.")
|
|
|
|
if cls and use_substitute_name:
|
|
|
|
if cls and use_substitute_name:
|
|
|
|
cls.substitute_name = substitute
|
|
|
|
cls.substitute_name = substitute
|
|
|
|
ret = func(*args, **kwargs)
|
|
|
|
ret = func(*args, **kwargs)
|
|
|
|