-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] Add save() to torch._C.Function
#20386
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
Conversation
TensorList, DoubleList, and BoolList were missing from the pickler, so this adds them. As a follow up a lot of the code for these could be templated and cut down
save() to torch._C.Function
save() to torch._C.Functionsave() to torch._C.Function
save() to torch._C.Functionsave() to torch._C.Function
zdevito
left a comment
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.
Looks good, minor comments.
torch/csrc/jit/script/init.cpp
Outdated
| Module module; | ||
| // Make a graph with a fake self argument | ||
| auto graph = self->graph()->copy(); | ||
| graph->insertInput(0, "self"); |
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 type of input 0 is not set here (it is also never checked, which is why it doesn't fail).
torch/csrc/jit/script/init.cpp
Outdated
| const ExtraFilesMap& _extra_files = ExtraFilesMap()) { | ||
| std::ostringstream buf; | ||
| Module module; | ||
| auto graph = self->graph()->copy(); |
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.
Can we put the implementation in Function::save, and avoid duplicating the logic between save and save_to_buffer?
|
Does |
|
It does return a module for now, our serialization doesn't know about functions afaik and we wanted to at least get the save/load functionality back before fixing that |
Fixes #20017
This wraps the
torch._C.Functioncurrently returned fromtorch.jit.scriptandtorch.jit.tracein aScriptFunctionandTracedFunctionrespectively, both of which are just wrappers to hold the function.Differential Revision: D15403161