Skip to content

Commit

Permalink
Make sure the path to save onnx zip file exist
Browse files Browse the repository at this point in the history
Signed-off-by: LinGeLin <[email protected]>
  • Loading branch information
LinGeLin committed Aug 1, 2024
1 parent 0004163 commit d14b200
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tf2onnx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ def save_onnx_model(save_path_root, onnx_file_name, feed_dict, model_proto, incl


def save_onnx_zip(target_path, model_proto, external_tensor_storage):
dir_name = os.path.dirname(target_path)
if dir_name:
os.makedirs(dir_name, exist_ok=True)
with zipfile.ZipFile(target_path, 'w') as z:
z.writestr("__MODEL_PROTO.onnx", model_proto.SerializeToString())
for k, v in external_tensor_storage.name_to_tensor_data.items():
Expand Down

0 comments on commit d14b200

Please sign in to comment.