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

Function CreateMerge

tensorflow/cc/ops/while_loop.cc:66–88  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
66Status 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`.
91Status CreateCond(const Scope& scope, const CondGraphBuilderFn& cond,

Callers 1

BuildWhileLoopFunction · 0.85

Calls 12

NextIterationNameFunction · 0.85
GetUniqueNameForOpMethod · 0.80
UpdateBuilderMethod · 0.80
DoShapeInferenceMethod · 0.80
NodeBuilderClass · 0.50
OutputClass · 0.50
nodeMethod · 0.45
indexMethod · 0.45
output_typeMethod · 0.45
InputMethod · 0.45
FinalizeMethod · 0.45
graphMethod · 0.45

Tested by

no test coverage detected