Fix bug where name generated by Graph::NewName can conflict with generated Send node...
authorSkye Wanderman-Milne <skyewm@google.com>
Wed, 4 Apr 2018 00:57:08 +0000 (17:57 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 4 Apr 2018 01:01:18 +0000 (18:01 -0700)
I fixed this very locally to avoid having to fix a bunch of tests
(this is currently blocking enabling the C API), but this should be
fixed more generally in the future.

PiperOrigin-RevId: 191528409

tensorflow/core/graph/quantize_training.cc

index cb0fc8a..3b6e8cc 100644 (file)
@@ -259,8 +259,14 @@ Status AddRestoreVariableSubgraphs(Graph* graph, Node* save_op,
   const string restore_op_name = strings::StrCat(name_prefix, "/RestoreV2");
   const string assign_op_name = strings::StrCat(name_prefix, "/Assign");
   for (Node* var : variables) {
-    string new_restore_op_name = graph->NewName(restore_op_name);
-    string new_assign_op_name = graph->NewName(assign_op_name);
+    // Add an extra prefix after calling graph->NewName because the "unique"
+    // name may conflict with names generated for Send nodes.
+    // TODO(b/77547936): fix this more generally and get rid of the extra prefix
+    // here.
+    string new_restore_op_name =
+        strings::StrCat(graph->NewName(restore_op_name), "_qt");
+    string new_assign_op_name =
+        strings::StrCat(graph->NewName(assign_op_name), "_qt");
     string tensor_names_op_name =
         strings::StrCat(new_restore_op_name, "/tensor_names");
     string shape_and_slices_op_name =