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

Function CopyAssociatedFunctions

tensorflow/compiler/tf2xla/tf2xla_util.cc:82–107  ·  view source on GitHub ↗

For graph `g`, copy all function call nodes' FunctionDef from `lookup_fld` to `fld`. This is to ensure that `fld` can instantiate FunctionDef of graph `g`.

Source from the content-addressed store, hash-verified

80// For graph `g`, copy all function call nodes' FunctionDef from `lookup_fld` to
81// `fld`. This is to ensure that `fld` can instantiate FunctionDef of graph `g`.
82Status CopyAssociatedFunctions(Graph* g,
83 const FunctionLibraryDefinition* lookup_fld,
84 FunctionLibraryDefinition* fld) {
85 for (Node* n : g->op_nodes()) {
86 for (const auto& associated_function :
87 GetAssociatedFunctions(*n, lookup_fld)) {
88 switch (associated_function.type()) {
89 case AssociatedFunctionInfo::kFunctionCallNode: {
90 const FunctionDef* fdef =
91 lookup_fld->Find(associated_function.func_name());
92 if (!fdef) {
93 return errors::Internal(
94 "Cannot find function ", associated_function.func_name(),
95 " for function call node ", n->DebugString());
96 }
97 TF_RETURN_IF_ERROR(fld->AddFunctionDef(*fdef));
98 break;
99 }
100 case AssociatedFunctionInfo::kSymbolicGradient:
101 case AssociatedFunctionInfo::kFunctionAttr:
102 break;
103 }
104 }
105 }
106 return Status::OK();
107}
108
109// For graph `g`, replaces _Arg nodes whose "index" attribute is in
110// `const_input_index_to_node` with Const nodes.

Callers 1

Calls 7

GetAssociatedFunctionsFunction · 0.85
InternalFunction · 0.85
op_nodesMethod · 0.80
typeMethod · 0.65
FindMethod · 0.45
DebugStringMethod · 0.45
AddFunctionDefMethod · 0.45

Tested by

no test coverage detected