Fix latent bug in dependency optimizer.
authorA. Unique TensorFlower <gardener@tensorflow.org>
Fri, 2 Feb 2018 17:20:26 +0000 (09:20 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 2 Feb 2018 18:56:20 +0000 (10:56 -0800)
PiperOrigin-RevId: 184291701

tensorflow/core/grappler/optimizers/dependency_optimizer.cc

index 0842fc9..7b4ca14 100644 (file)
@@ -97,7 +97,12 @@ bool DependencyOptimizer::SafeToRemoveIdentity(const NodeDef& node) {
       // TODO(rmlarsen): Try to remove this artificial contraint.
       return false;
     }
-    for (auto consumer : node_map_->GetOutputs(node.name())) {
+  }
+  for (auto consumer : node_map_->GetOutputs(node.name())) {
+    if (node.input_size() > 1 && IsMerge(*consumer)) {
+      return false;
+    }
+    if (IsSwitch(*input)) {
       for (const string& consumer_input : consumer->input()) {
         if (consumer_input == AsControlDependency(node.name())) {
           return false;