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`.
| 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`. |
| 82 | Status 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. |
no test coverage detected