aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/framework/meta_graph.py
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2017-12-05 16:58:24 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-05 17:05:45 -0800
commitaf8a5507937108a41781ba117fa16edd3b1091b5 (patch)
tree30f94053af5df3a30ba0b4506be1f54f8e508918 /tensorflow/python/framework/meta_graph.py
parent44cb3887b39d2c5edbf5f5a638cef08be8bc6aeb (diff)
Always include the function library when exporting a MetaGraphDef.
Previously, some code paths through `tf.train.export_meta_graph()` did not ensure that the function library was persisted in the resulting `MetaGraphDef`. This would break serialization for meta-graphs that included `tf.data` pipelines that used functions. This fix ensures that the library is copied to all such meta-graphs. Fixes #15019. Fixes #14143. PiperOrigin-RevId: 178033103
Diffstat (limited to 'tensorflow/python/framework/meta_graph.py')
-rw-r--r--tensorflow/python/framework/meta_graph.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tensorflow/python/framework/meta_graph.py b/tensorflow/python/framework/meta_graph.py
index 44ddc013b2..c839d7a9a6 100644
--- a/tensorflow/python/framework/meta_graph.py
+++ b/tensorflow/python/framework/meta_graph.py
@@ -773,6 +773,7 @@ def export_scoped_meta_graph(filename=None,
if graph_def:
new_graph_def = graph_pb2.GraphDef()
new_graph_def.versions.CopyFrom(graph_def.versions)
+ new_graph_def.library.CopyFrom(graph_def.library)
if clear_extraneous_savers:
exclude_nodes = _find_extraneous_saver_nodes(graph_def, saver_def)
@@ -810,6 +811,9 @@ def export_scoped_meta_graph(filename=None,
bytesize += value.node_def.ByteSize()
if bytesize >= (1 << 31) or bytesize < 0:
raise ValueError("GraphDef cannot be larger than 2GB.")
+
+ graph._copy_functions_to_graph_def(graph_def, bytesize) # pylint: disable=protected-access
+
# It's possible that not all the inputs are in the export_scope.
# If we would like such information included in the exported meta_graph,
# add them to a special unbound_inputs collection.