| 1167 | } |
| 1168 | |
| 1169 | Status FunctionLibraryDefinition::CopyFunctionDefFrom( |
| 1170 | const string& func, const FunctionLibraryDefinition& other) { |
| 1171 | if (default_registry_ != other.default_registry_) { |
| 1172 | return errors::InvalidArgument( |
| 1173 | "Cannot copy function '", func, |
| 1174 | "' because CopyFunctionDefFrom() requires that both libraries have the " |
| 1175 | "same default registry."); |
| 1176 | } |
| 1177 | std::shared_ptr<FunctionDefAndOpRegistration> function_def; |
| 1178 | { |
| 1179 | tf_shared_lock l(other.mu_); |
| 1180 | function_def = other.FindHelper(func); |
| 1181 | } |
| 1182 | if (!function_def) { |
| 1183 | return errors::InvalidArgument( |
| 1184 | "Cannot copy function '", func, |
| 1185 | "' because no function with that name exists in the other library."); |
| 1186 | } |
| 1187 | { |
| 1188 | mutex_lock l(mu_); |
| 1189 | std::shared_ptr<FunctionDefAndOpRegistration>& entry = function_defs_[func]; |
| 1190 | if (entry) { |
| 1191 | if (!FunctionDefsEqual(entry->fdef, function_def->fdef)) { |
| 1192 | return errors::InvalidArgument( |
| 1193 | "Cannot copy function '", func, |
| 1194 | "' because a different function with the same name already " |
| 1195 | "exists."); |
| 1196 | } |
| 1197 | } else { |
| 1198 | entry = std::move(function_def); |
| 1199 | } |
| 1200 | } |
| 1201 | return Status::OK(); |
| 1202 | } |
| 1203 | |
| 1204 | Status FunctionLibraryDefinition::AddGradientDef(const GradientDef& grad) { |
| 1205 | mutex_lock l(mu_); |
no test coverage detected