-
Notifications
You must be signed in to change notification settings - Fork 0
Update serialize/deserialize #69
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,11 @@ void load_tensors(std::map<std::string, torch::Tensor>& tensor_map, | |
| torch::serialize::InputArchive archive; | ||
| archive.load_from(filename); | ||
| for (auto& pair : tensor_map) { | ||
| archive.read(pair.first, pair.second); | ||
| try { | ||
| archive.read(pair.first, pair.second); | ||
| } catch (const c10::Error& e) { | ||
| // skip missing tensors | ||
| } | ||
|
Comment on lines
+23
to
+27
|
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block catches all c10::Error exceptions, which includes many different types of errors beyond just missing tensors. This could mask serious issues like corrupted archives, I/O errors, or type mismatches. Consider checking the error type or message to only skip errors specifically related to missing tensors, and re-throw other types of errors that indicate real problems.