diff options
author | 2017-07-10 16:54:01 -0700 | |
---|---|---|
committer | 2017-07-10 17:04:54 -0700 | |
commit | b7181debf5ca40fe67e21e5d93ac2ff6230019b6 (patch) | |
tree | 9615057aa405209a2bff60c0d3910395d8bf9b69 | |
parent | 277e0502a2afbff51dc21c496565b63d71c6a273 (diff) |
Add a call to AddDefaultAttrsToGraphDef when loading deprecated SessionBundles that may run into a problem with undefined attributes.
PiperOrigin-RevId: 161461770
-rw-r--r-- | tensorflow/contrib/session_bundle/session_bundle.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tensorflow/contrib/session_bundle/session_bundle.cc b/tensorflow/contrib/session_bundle/session_bundle.cc index bc6fdcd4de..cf26e3cae7 100644 --- a/tensorflow/contrib/session_bundle/session_bundle.cc +++ b/tensorflow/contrib/session_bundle/session_bundle.cc @@ -22,6 +22,7 @@ limitations under the License. #include "google/protobuf/any.pb.h" #include "tensorflow/contrib/session_bundle/manifest.pb.h" #include "tensorflow/core/framework/graph.pb.h" +#include "tensorflow/core/framework/graph_def_util.h" #include "tensorflow/core/framework/tensor.h" #include "tensorflow/core/framework/tensor_shape.h" #include "tensorflow/core/framework/tensor_types.h" @@ -163,6 +164,13 @@ Status LoadSessionBundleFromPathUsingRunOptionsInternal( TF_RETURN_IF_ERROR( GetMetaGraphDefFromExport(export_dir, &(bundle->meta_graph_def))); + // Deprecated SessionBundle models may fail to load because newly added + // attributes are not added to the Graph in the default Session initialization + // flow. Add an explicit call here when first loading the graph from disk. + TF_RETURN_IF_ERROR( + AddDefaultAttrsToGraphDef(bundle->meta_graph_def.mutable_graph_def(), + *OpRegistry::Global(), 0 /* node_offset */)); + const auto& collection_def_map = bundle->meta_graph_def.collection_def(); const auto graph_it = bundle->meta_graph_def.collection_def().find(kGraphKey); if (graph_it != collection_def_map.end()) { |