Commit Graph

1 Commits

Author SHA1 Message Date
Stella Laurenzo
ae07e29a16 Load SavedModelV2 variables directly from the checkpoint.
* This fixes a correctness problem where we were relying on the variable's "name" attribute, which is merely advisory.
* Should match the load heuristics in Python by reading the TrackableObjectGraph from the checkpoint, re-associating it with the SavedObjectGraph and using that to restore the variable.
* Has a side-effect of eliminating the dependency of the importer on the CPU runtime and kernels, which should reduce necessary dependencies to compile by tens of megabytes.

Open questions:
* I created a new bundle_v2.h because V2 is so substantially different from V1. Also, it has a different dependency surface area and I therefore wanted to use it as a different (lighter) library. Advise if you would like this organized differently. I tried to factor it so that a future C++ SavedModel loader/runner could be built on this as well (with some incremental work).
* There didn't seem to be a facility for generating the testdata SavedModels. I ended up just writing a small standalone python script that I can invoke from the command line to generate the new ones. It isn't wired up in any way but it should be possible to do so at some point (I'm not familiar enough with the test infra on this side of the tree, so please advise).
* I could see factoring the SavedModelV2Bundle::RestoreObjects method into a dedicated facility for loading arbitrary checkpoints. Not sure what the roadmap here is so just kept is simple for now.

PiperOrigin-RevId: 282439157
Change-Id: I685df47ab621917eed270319cde220498f191b74
2019-11-25 15:01:01 -08:00