Creates the `loop_var_idx`-th Merge node of a loop being constructed with `scope`. `enter_output` is the `loop_var_idx`-th Enter node's output.
| 64 | // Creates the `loop_var_idx`-th Merge node of a loop being constructed with |
| 65 | // `scope`. `enter_output` is the `loop_var_idx`-th Enter node's output. |
| 66 | Status CreateMerge(const Scope& scope, int loop_var_idx, |
| 67 | const Output& enter_output, Output* merge_output) { |
| 68 | // The merge nodes accept the while loop's back edges as an input (i.e. the |
| 69 | // not-yet-created next iteration nodes). Use the underlying NodeBuilder API |
| 70 | // directly to create the back edge. |
| 71 | NodeBuilder::NodeOut enter_input(enter_output.node(), enter_output.index()); |
| 72 | |
| 73 | const int next_output_index = 0; |
| 74 | DataType dtype = enter_output.node()->output_type(0); |
| 75 | NodeBuilder::NodeOut next_input(NextIterationName(scope, loop_var_idx), |
| 76 | next_output_index, dtype); |
| 77 | |
| 78 | std::vector<NodeBuilder::NodeOut> input_list({enter_input, next_input}); |
| 79 | const string unique_name = scope.GetUniqueNameForOp("Merge"); |
| 80 | NodeBuilder builder = NodeBuilder(unique_name, "Merge").Input(input_list); |
| 81 | scope.UpdateBuilder(&builder); |
| 82 | |
| 83 | Node* merge_node; |
| 84 | TF_RETURN_IF_ERROR(builder.Finalize(scope.graph(), &merge_node)); |
| 85 | TF_RETURN_IF_ERROR(scope.DoShapeInference(merge_node)); |
| 86 | *merge_output = Output(merge_node, 0); |
| 87 | return Status::OK(); |
| 88 | } |
| 89 | |
| 90 | // Creates the condition subgraph defined by `cond`. |
| 91 | Status CreateCond(const Scope& scope, const CondGraphBuilderFn& cond, |
no test coverage detected