Do not skip pruning identities inserted by Grappler in dependency optimizer.

PiperOrigin-RevId: 236370572
This commit is contained in:
A. Unique TensorFlower 2019-03-01 13:44:12 -08:00 committed by TensorFlower Gardener
parent 0afe41679f
commit 8fa58e7762

View File

@ -75,16 +75,8 @@ bool DependencyOptimizer::SafeToRemoveIdentity(const NodeDef& node) const {
// Recv. // Recv.
if (IsVariable(*input) || IsRecv(*input)) { if (IsVariable(*input) || IsRecv(*input)) {
return false; return false;
} else if (IsSwitch(*input)) {
// Don't turn Identity nodes following Switch into NoOp or remove them
// if it requires anchoring a control dependencies the Switch node, which
// is not valid.
if (str_util::StartsWith(node.name(), kConstantFoldingCtrl)) {
// TODO(rmlarsen): Try to remove this artificial contraint.
return false;
} }
} for (const auto& consumer : node_map_->GetOutputs(node.name())) {
for (auto consumer : node_map_->GetOutputs(node.name())) {
if (node.input_size() > 1 && IsMerge(*consumer)) { if (node.input_size() > 1 && IsMerge(*consumer)) {
return false; return false;
} }