Skip to content

Commit

Permalink
Update SavedModel builder to use wrapped saver's clear_devices option.
Browse files Browse the repository at this point in the history
Change: 138015167
  • Loading branch information
sukritiramesh authored and tensorflower-gardener committed Nov 3, 2016
1 parent 9a66842 commit 4adf4f3
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions tensorflow/python/saved_model/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,6 @@ def _tag_and_add_meta_graph(self, meta_graph_def, tags, signature_def_map):
proto_meta_graph_def = self._saved_model.meta_graphs.add()
proto_meta_graph_def.CopyFrom(meta_graph_def)

def _maybe_clear_devices(self, clear_devices):
if not clear_devices:
return
for node in ops.get_default_graph().as_graph_def().node:
node.device = ""

def add_meta_graph(self,
tags,
signature_def_map=None,
Expand Down Expand Up @@ -287,8 +281,6 @@ def add_meta_graph(self,
"Variables and assets have not been saved yet. "
"Please invoke `add_meta_graph_and_variables()` first.")

self._maybe_clear_devices(clear_devices)

# Save asset files and write them to disk, if any.
self._save_and_write_assets(assets_collection)

Expand All @@ -300,7 +292,7 @@ def add_meta_graph(self,
sharded=True,
write_version=saver_pb2.SaverDef.V2)

meta_graph_def = saver.export_meta_graph()
meta_graph_def = saver.export_meta_graph(clear_devices=clear_devices)

# Tag the meta graph def and add it to the SavedModel.
self._tag_and_add_meta_graph(meta_graph_def, tags, signature_def_map)
Expand Down Expand Up @@ -336,8 +328,6 @@ def add_meta_graph_and_variables(self,
raise AssertionError("Variables and assets have already been saved. "
"Please invoke `add_meta_graph()` instead.")

self._maybe_clear_devices(clear_devices)

# Save asset files and write them to disk, if any.
self._save_and_write_assets(assets_collection)

Expand All @@ -361,7 +351,7 @@ def add_meta_graph_and_variables(self,
sharded=True,
write_version=saver_pb2.SaverDef.V2)
saver.save(sess, variables_path, write_meta_graph=False)
meta_graph_def = saver.export_meta_graph()
meta_graph_def = saver.export_meta_graph(clear_devices=clear_devices)

# Tag the meta graph def and add it to the SavedModel.
self._tag_and_add_meta_graph(meta_graph_def, tags, signature_def_map)
Expand Down

0 comments on commit 4adf4f3

Please sign in to comment.