-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[v1.x] Save/Load Gluon Blocks & HybridBlocks #19565
Conversation
Hey @samskalicky , Thanks for submitting the PR
CI supported jobs: [edge, sanity, centos-cpu, unix-gpu, miscellaneous, clang, website, centos-gpu, windows-gpu, windows-cpu, unix-cpu] Note: |
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.
Must not change load_json
-> fromjson
in the 1.x branch due to API compatibility
backed out the change |
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.
Thanks @samskalicky
Description
v1.x branch version of PoC for saving & loading Gluon Blocks & HybridBlocks from #19535. Version for master branch is #19564. This PR is fundamentally different due to the changes on the master branch for block names/UUIDs compared to v1.x
This PR adds 2 new APIs to Gluon Blocks:
save
Saves the model parameters and a json structure of the model that stores the names of blocks' children in order to later restore and match the saved parameters. This does not actually store the model. Users still need to recreate their model architecture using their Gluon code in Python.
It also stores the hybridized Symbol objects for HybridBlocks and associated settings so that it can be later reloaded.
load
Loads the model parameters and a json structure of the model. It restores the names of blocks' children in order to match the saved parameters.
Also restores hybridized Symbol objects in HybridBlocks so they do not need to be hybridized again. After calling the
load
API users can immediately run inference without needing to hybridize.