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

When splitting external data, avoid renaming model.data to model.data.1 if only one external data file gets eventually saved #414

Merged
merged 2 commits into from
Jan 25, 2024
Merged
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
8 changes: 8 additions & 0 deletions src/sparsezoo/utils/onnx/external_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ def split_external_data(
# WRITE - ONNX model with updated tensor external data info
onnx.save(model, model_path)

# RENAME - if as a result of splitting we end up with a single file, rename it to
# the original external data file name
if current_external_data_file_number == 1:
os.rename(
os.path.join(base_dir, updated_file_name),
os.path.join(base_dir, external_data_file),
)


def _write_external_data_file_from_base_bytes(
new_file_name, original_byte_ranges, original_file_bytes_reader
Expand Down
Loading