Skip to content

Commit

Permalink
remove two deprecated function (#28220)
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-huazhong authored Jan 8, 2024
1 parent 0c2121f commit 7d9d5ce
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
2 changes: 0 additions & 2 deletions src/transformers/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@
is_training_run_on_sagemaker,
is_vision_available,
requires_backends,
tf_required,
torch_only_method,
torch_required,
)
from .peft_utils import (
ADAPTER_CONFIG_NAME,
Expand Down
36 changes: 1 addition & 35 deletions src/transformers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import sys
import warnings
from collections import OrderedDict
from functools import lru_cache, wraps
from functools import lru_cache
from itertools import chain
from types import ModuleType
from typing import Any, Tuple, Union
Expand Down Expand Up @@ -1303,40 +1303,6 @@ def __getattribute__(cls, key):
requires_backends(cls, cls._backends)


def torch_required(func):
warnings.warn(
"The method `torch_required` is deprecated and will be removed in v4.36. Use `requires_backends` instead.",
FutureWarning,
)

# Chose a different decorator name than in tests so it's clear they are not the same.
@wraps(func)
def wrapper(*args, **kwargs):
if is_torch_available():
return func(*args, **kwargs)
else:
raise ImportError(f"Method `{func.__name__}` requires PyTorch.")

return wrapper


def tf_required(func):
warnings.warn(
"The method `tf_required` is deprecated and will be removed in v4.36. Use `requires_backends` instead.",
FutureWarning,
)

# Chose a different decorator name than in tests so it's clear they are not the same.
@wraps(func)
def wrapper(*args, **kwargs):
if is_tf_available():
return func(*args, **kwargs)
else:
raise ImportError(f"Method `{func.__name__}` requires TF.")

return wrapper


def is_torch_fx_proxy(x):
if is_torch_fx_available():
import torch.fx
Expand Down

0 comments on commit 7d9d5ce

Please sign in to comment.