| 294 | } |
| 295 | |
| 296 | Status LowerWhileHelper::CreateBodyFuncCallNode() { |
| 297 | for (Node* switch_node : switch_nodes_) { |
| 298 | body_call_builder_.Input(NodeOut(switch_node, 1)); |
| 299 | } |
| 300 | body_call_builder_.Device(while_op_->requested_device()); |
| 301 | TF_RETURN_IF_ERROR(body_call_builder_.Finalize(graph_, &body_call_node_)); |
| 302 | // Add a control edge to make sure the Const nodes in the body function |
| 303 | // are in the same frame as the rest of the function, otherwise |
| 304 | // `BuildControlFlowInfo` throws an error. |
| 305 | // TODO(srbs): The choice of input at index 0 seems arbitrary(is it?) however |
| 306 | // this is how tf.while_loop does it. Can this affect performance if the 0th |
| 307 | // node is not the first one to be ready? Can we speed that case up using some |
| 308 | // sort of multi-input Merge? |
| 309 | Node* body_control_node_; |
| 310 | string op_type = "Identity"; |
| 311 | if (IsRefType(switch_nodes_[0]->output_type(1))) { |
| 312 | op_type = "RefIdentity"; |
| 313 | } |
| 314 | TF_RETURN_IF_ERROR(NodeBuilder(NewName("loop_body_control"), op_type, |
| 315 | graph_->op_registry(), &debug_info_) |
| 316 | .Input(NodeOut(switch_nodes_[0], 1)) |
| 317 | .Device(while_op_->requested_device()) |
| 318 | .Finalize(graph_, &body_control_node_)); |
| 319 | graph_->AddControlEdge(body_control_node_, body_call_node_); |
| 320 | return Status::OK(); |
| 321 | } |
| 322 | |
| 323 | Status LowerWhileHelper::CreateExitNodes() { |
| 324 | std::vector<NodeOut> outputs; |
nothing calls this directly
no test coverage detected