Checkpointable: Make Templates Checkpointable
Uses a variable_creator_scope to hook all variable creation within the Template. For variables without a more deeply nested Template parent, it adds a dependency directly. For variables with a Template parent, it adds a dependency on the sub-Template instead. The variable scope prefix for the Template itself is stripped. However, any variable_scopes inside the Template (such as those for Layers) will be included in the dependency names. So within Templates we essentially have name-based saving (with the exception of dependencies between Templates themselves, which use the object-based dependency mechanism). This isn't ideal, but will hopefully allow migration toward object oriented dependencies more smoothly. Throws an error on object-based save() if the dependencies don't match between Checkpointable and .variables. Includes a semi-related usability fix for the Checkpoint utility; mostly in unit tests, restore() is not called before save(), which when graph building was leading to the save counter not being initialized. Fixes that. PiperOrigin-RevId: 187560911
Loading
Please sign in to comment