Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cherry-Pick] Copy Json to SaveDir in NLP Demo #1252

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion example/auto_compression/nlp/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import functools
from functools import partial
import numpy as np
import shutil
import paddle
import paddle.nn as nn
from paddle.io import Dataset, BatchSampler, DataLoader
Expand Down Expand Up @@ -305,13 +306,17 @@ def main():
if 'HyperParameterOptimization' not in all_config else eval_dataloader,
eval_dataloader=eval_dataloader)

ac.compress()
if not os.path.exists(args.save_dir):
os.makedirs(args.save_dir)

for file_name in os.listdir(global_config['model_dir']):
if 'json' in file_name or 'txt' in file_name:
shutil.copy(
os.path.join(global_config['model_dir'], file_name),
args.save_dir)

ac.compress()


if __name__ == '__main__':
paddle.enable_static()
Expand Down
5 changes: 4 additions & 1 deletion example/auto_compression/pytorch_huggingface/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,17 @@ def main():
'HyperParameterOptimization' not in all_config else eval_dataloader,
eval_dataloader=eval_dataloader)

ac.compress()
if not os.path.exists(args.save_dir):
os.makedirs(args.save_dir)

for file_name in os.listdir(global_config['model_dir']):
if 'json' in file_name or 'txt' in file_name:
shutil.copy(
os.path.join(global_config['model_dir'], file_name),
args.save_dir)

ac.compress()


if __name__ == '__main__':
paddle.enable_static()
Expand Down