aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/saved_model
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-07-07 14:03:48 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-07-07 14:11:29 -0700
commitb1b7d5930ecdc9412e7a3035bdd2be49e9cfc230 (patch)
tree44de31557bac8640d0b6086d5e3d2935bb97982b /tensorflow/python/saved_model
parent996605b0e4ef96e6732f7496abf44b6e5e1eb504 (diff)
Add a tag constant, gpu, to present graph with GPU support.
PiperOrigin-RevId: 161242660
Diffstat (limited to 'tensorflow/python/saved_model')
-rw-r--r--tensorflow/python/saved_model/saved_model_test.py14
-rw-r--r--tensorflow/python/saved_model/tag_constants.py5
2 files changed, 18 insertions, 1 deletions
diff --git a/tensorflow/python/saved_model/saved_model_test.py b/tensorflow/python/saved_model/saved_model_test.py
index fcd6bc3954..5639e6855d 100644
--- a/tensorflow/python/saved_model/saved_model_test.py
+++ b/tensorflow/python/saved_model/saved_model_test.py
@@ -207,6 +207,13 @@ class SavedModelTest(test.TestCase):
self._init_and_validate_variable(sess, "v", 43)
builder.add_meta_graph([tag_constants.SERVING])
+ # Graph that updates the single variable. SavedModel invoked to:
+ # - simply add the model (weights are not updated).
+ # - multiple tags (from predefined constants).
+ with self.test_session(graph=ops.Graph()) as sess:
+ self._init_and_validate_variable(sess, "v", 45)
+ builder.add_meta_graph([tag_constants.SERVING, tag_constants.GPU])
+
# Graph that updates the single variable. SavedModel is invoked:
# - to add the model (weights are not updated).
# - multiple custom tags.
@@ -230,6 +237,13 @@ class SavedModelTest(test.TestCase):
self.assertEqual(
42, ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)[0].eval())
+ # Restore the graph with multiple predefined tags whose variables were not
+ # saved.
+ with self.test_session(graph=ops.Graph()) as sess:
+ loader.load(sess, [tag_constants.SERVING, tag_constants.GPU], export_dir)
+ self.assertEqual(
+ 42, ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)[0].eval())
+
# Restore the graph with multiple tags. Provide duplicate tags to test set
# semantics.
with self.test_session(graph=ops.Graph()) as sess:
diff --git a/tensorflow/python/saved_model/tag_constants.py b/tensorflow/python/saved_model/tag_constants.py
index 4fb9645dea..52868bdf99 100644
--- a/tensorflow/python/saved_model/tag_constants.py
+++ b/tensorflow/python/saved_model/tag_constants.py
@@ -28,9 +28,12 @@ SERVING = "serve"
# Tag for the `training` graph.
TRAINING = "train"
+# Tag for the `gpu` graph.
+GPU = "gpu"
_allowed_symbols = [
"SERVING",
- "TRAINING"
+ "TRAINING",
+ "GPU"
]
remove_undocumented(__name__, _allowed_symbols)