Skip to content

Commit bb6c735

Browse files
committed
update
1 parent b35fd5d commit bb6c735

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

paddlenlp/transformers/model_utils.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from paddle.utils.download import is_url as is_remote_url
5353
from tqdm.auto import tqdm
5454

55-
from paddlenlp.utils.downloader import get_path_from_url_with_filelock, hf_file_exists
55+
from paddlenlp.utils.downloader import get_path_from_url_with_filelock
5656
from paddlenlp.utils.env import (
5757
CONFIG_NAME,
5858
LEGACY_CONFIG_NAME,
@@ -367,28 +367,7 @@ def resolve_weight_file_from_hf_hub(repo_id: str, cache_dir: str, support_conver
367367
support_conversion (bool): whether support converting pytorch weight file to paddle weight file
368368
subfolder (str, optional) An optional value corresponding to a folder inside the repo.
369369
"""
370-
is_local = os.path.isdir(repo_id)
371-
if not is_local:
372-
if hf_file_exists(repo_id, PADDLE_WEIGHTS_NAME, subfolder=subfolder):
373-
file_name = PADDLE_WEIGHTS_NAME
374-
assert (
375-
support_conversion is False
376-
), "Please call set convert_from_torch for paddle weights on huggingface hub, eg. Model.from_pretrained(model_name, from_hf_hub=True, convert_from_torch=False)"
377-
elif hf_file_exists(repo_id, PYTORCH_WEIGHTS_NAME, subfolder=subfolder):
378-
if not support_conversion:
379-
raise EntryNotFoundError(
380-
f"can not download `{PADDLE_WEIGHTS_NAME} from https://huggingface.co/{repo_id}` "
381-
"and current model doesn't support conversion from pytorch weight file to paddle weight file"
382-
)
383-
file_name = PYTORCH_WEIGHTS_NAME
384-
else:
385-
raise EntryNotFoundError(
386-
message=f"can not find the paddle/pytorch weight file from: https://huggingface.co/{repo_id}",
387-
response=None,
388-
)
389-
else:
390-
# for local file, we use support_conversion to select paddle or torch weight.
391-
file_name = PYTORCH_WEIGHTS_NAME if support_conversion else PADDLE_WEIGHTS_NAME
370+
file_name = PYTORCH_WEIGHTS_NAME if support_conversion else PADDLE_WEIGHTS_NAME
392371

393372
file_name_list = [SAFE_WEIGHTS_NAME] + [file_name] + [PYTORCH_WEIGHTS_INDEX_NAME] + [SAFE_WEIGHTS_INDEX_NAME]
394373
resolved_file = None

0 commit comments

Comments
 (0)