[Grappler] Do not add control edges from placeholder inputs in function inlining

PiperOrigin-RevId: 311412339
Change-Id: Ie40c0c44f1d6b42b53c259f8ad92d171577cd9c7
This commit is contained in:
Eugene Zhulenev 2020-05-13 15:05:25 -07:00 committed by TensorFlower Gardener
parent 4eeb6d742e
commit 7e39134874

View File

@ -1122,7 +1122,15 @@ void AddStrictInputSemantics(Node* caller, Graph* g) {
VLOG(3) << "Add control edges from all data inputs to enforce strict "
"semantics with regard to function inputs";
// Do not add control edges from placeholders, because it will prevent
// pruning, and they can't produce any side effects anyway.
const auto is_placeholder = [](const Node* node) -> bool {
return node->type_string() == "Placeholder";
};
for (const Node* node : data_inputs) {
if (is_placeholder(node)) continue;
g->AddControlEdge(g->FindNodeId(node->id()), caller,
/*allow_duplicates=*/true);
}