Skip to content

Commit ad36a14

Browse files
wj-McatguoshengCS
andauthored
fix skep tokenizer and samefile (#2648)
* fix skep tokenizer * change samefile to abspath Co-authored-by: Guo Sheng <[email protected]>
1 parent 40417bf commit ad36a14

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

paddlenlp/transformers/ernie/tokenizer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,8 @@ def save_resources(self, save_directory):
595595
source_path = os.path.join(MODEL_HOME, 'ernie-tiny', file_name)
596596
save_path = os.path.join(save_directory,
597597
self.resource_files_names[name])
598-
if not os.path.samefile(source_path, save_path):
598+
599+
if os.path.abspath(source_path) != os.path.abspath(save_path):
599600
shutil.copyfile(source_path, save_path)
600601

601602
def num_special_tokens_to_add(self, pair=False):

paddlenlp/transformers/skep/tokenizer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ def save_resources(self, save_directory):
447447
"""
448448
for name, file_name in self.resource_files_names.items():
449449
save_path = os.path.join(save_directory, file_name)
450-
source_file = getattr(self, name)
451-
if not os.path.samefile(source_file, save_path):
450+
source_file = getattr(self, name, None)
451+
if not source_file:
452+
continue
453+
454+
if os.path.abspath(source_file) != os.path.abspath(save_path):
452455
shutil.copyfile(source_file, save_path)

0 commit comments

Comments
 (0)