MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CreateBodyFuncCallNode

Method CreateBodyFuncCallNode

tensorflow/core/common_runtime/lower_while_op.cc:296–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296Status 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
323Status LowerWhileHelper::CreateExitNodes() {
324 std::vector<NodeOut> outputs;

Callers

nothing calls this directly

Calls 10

IsRefTypeFunction · 0.85
NewNameFunction · 0.85
NodeOutClass · 0.50
NodeBuilderClass · 0.50
InputMethod · 0.45
DeviceMethod · 0.45
FinalizeMethod · 0.45
output_typeMethod · 0.45
op_registryMethod · 0.45
AddControlEdgeMethod · 0.45

Tested by

no test coverage detected