mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-16 21:00:14 +00:00
remove existed dir for output external data (#8887)
This commit is contained in:
parent
a171d13b19
commit
f6e7cd8050
1 changed files with 11 additions and 1 deletions
|
|
@ -7,7 +7,7 @@
|
|||
import os
|
||||
import logging
|
||||
import torch
|
||||
import onnx
|
||||
import shutil
|
||||
import random
|
||||
import numpy
|
||||
import time
|
||||
|
|
@ -777,6 +777,16 @@ class Gpt2Helper:
|
|||
model_name += "_past"
|
||||
|
||||
if new_folder:
|
||||
# Remove the directories if existed.
|
||||
for suffix in ["", "_fp32", "_fp16", "_int8"]:
|
||||
new_dir = os.path.join(output_dir, model_name + suffix)
|
||||
if os.path.exists(new_dir):
|
||||
try:
|
||||
shutil.rmtree(new_dir)
|
||||
logger.info(f"Removed the existed directory: {new_dir}")
|
||||
except OSError as e:
|
||||
logger.info(f"Failed to remove the directory {new_dir}: {e.strerror}")
|
||||
|
||||
# store each model to its own directory (for external data format).
|
||||
return {
|
||||
"raw": os.path.join(os.path.join(output_dir, model_name), model_name + ".onnx"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue