Skip to content

Commit

Permalink
Copy Json to SaveDir in NLP Demo (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelXu7 authored Jul 5, 2022
1 parent 072ff7a commit c590123
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit c590123

Please sign in to comment.