| 1113 | } |
| 1114 | |
| 1115 | Status FunctionLibraryDefinition::AddFunctionDefHelper(const FunctionDef& fdef, |
| 1116 | bool* added) { |
| 1117 | *added = false; |
| 1118 | std::shared_ptr<FunctionDefAndOpRegistration>& entry = |
| 1119 | function_defs_[fdef.signature().name()]; |
| 1120 | if (entry) { |
| 1121 | if (!FunctionDefsEqual(entry->fdef, fdef)) { |
| 1122 | return errors::InvalidArgument( |
| 1123 | "Cannot add function '", fdef.signature().name(), |
| 1124 | "' because a different function with the same name already " |
| 1125 | "exists."); |
| 1126 | } |
| 1127 | // Ignore duplicate FunctionDefs. |
| 1128 | return Status::OK(); |
| 1129 | } |
| 1130 | const OpDef* op_def; |
| 1131 | if (default_registry_->LookUpOpDef(fdef.signature().name(), &op_def).ok()) { |
| 1132 | return errors::InvalidArgument( |
| 1133 | "Cannot add function '", fdef.signature().name(), |
| 1134 | "' because an op with the same name already exists."); |
| 1135 | } |
| 1136 | entry = std::make_shared<FunctionDefAndOpRegistration>(fdef); |
| 1137 | *added = true; |
| 1138 | return Status::OK(); |
| 1139 | } |
| 1140 | |
| 1141 | Status FunctionLibraryDefinition::AddHelper( |
| 1142 | std::shared_ptr<FunctionDefAndOpRegistration> registration, bool* added) { |
nothing calls this directly
no test coverage detected