[TF:XLA] Fix failure in functionalize_control_flow rewrite for Enter nodes that are unused. Make sure we ignore such nodes without producing an error.
PiperOrigin-RevId: 161136545
This commit is contained in:
parent
dabcb60bc9
commit
97cbcac453
@ -261,7 +261,10 @@ Status FunctionalizeLoop(Graph* graph, Frame* frame,
|
||||
std::vector<const Edge*> edges(arg.enter->out_edges().begin(),
|
||||
arg.enter->out_edges().end());
|
||||
for (int i = 0; i < edges.size(); ++i) {
|
||||
TF_RET_CHECK(!edges[i]->IsControlEdge());
|
||||
if (edges[i]->IsControlEdge() && edges[i]->dst()->IsSink()) {
|
||||
continue;
|
||||
}
|
||||
TF_RET_CHECK(!edges[i]->IsControlEdge()) << edges[i]->src()->name();
|
||||
Arg new_arg;
|
||||
new_arg.is_loop_invariant = false;
|
||||
if (i == 0) {
|
||||
|
@ -65,6 +65,9 @@ TEST(FunctionalizeControlFlow, OneLoopVar) {
|
||||
auto source = ops::Placeholder(scope.WithOpName("source"), DT_INT32);
|
||||
auto enter =
|
||||
ops::internal::Enter(scope.WithOpName("while/Enter"), source, "aloop");
|
||||
// Add an unused Enter node. These should be ignored.
|
||||
auto enter2 =
|
||||
ops::internal::Enter(scope.WithOpName("while/Enter2"), source, "aloop");
|
||||
auto merge = ops::Merge(scope.WithOpName("while/Merge"),
|
||||
std::initializer_list<Input>{enter, dummy});
|
||||
auto ten = ops::Const<int32>(
|
||||
|
Loading…
Reference in New Issue
Block a user