-
-
Notifications
You must be signed in to change notification settings - Fork 757
Catch RuntimeError to avoid serialization fail when using pytorch #2619
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
52e5d0e
ea0ae32
18963d9
e0d9ce5
fffb68b
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 |
|---|---|---|
|
|
@@ -7,7 +7,12 @@ | |
| @dask_serialize.register(torch.Tensor) | ||
| def serialize_torch_Tensor(t): | ||
| requires_grad_ = t.requires_grad | ||
| header, frames = serialize(t.detach_().numpy()) | ||
|
|
||
| if requires_grad_: | ||
| header, frames = serialize(t.detach().numpy()) | ||
| else: | ||
| header, frames = serialize(t.numpy()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not an use an if-statement instead? It's known when the error will be thrown: when
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed this block to use an if-statement. |
||
|
|
||
| if t.grad is not None: | ||
| grad_header, grad_frames = serialize(t.grad.numpy()) | ||
| header["grad"] = {"header": grad_header, "start": len(frames)} | ||
|
|
||
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.
I would test that serialization and de-serialization does not modify
t.requires_grad. Adding this line below the serialization would test that: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.
Done, too.