| 274 | } |
| 275 | |
| 276 | Status ContainerInfo::Init(ResourceMgr* rmgr, const NodeDef& ndef, |
| 277 | bool use_node_name_as_default) { |
| 278 | CHECK(rmgr); |
| 279 | rmgr_ = rmgr; |
| 280 | string attr_container; |
| 281 | TF_RETURN_IF_ERROR(GetNodeAttr(ndef, "container", &attr_container)); |
| 282 | if (!attr_container.empty() && !IsValidContainerName(attr_container)) { |
| 283 | return errors::InvalidArgument("container contains invalid characters: ", |
| 284 | attr_container); |
| 285 | } |
| 286 | string attr_shared_name; |
| 287 | TF_RETURN_IF_ERROR(GetNodeAttr(ndef, "shared_name", &attr_shared_name)); |
| 288 | if (!attr_shared_name.empty() && (attr_shared_name[0] == '_')) { |
| 289 | return errors::InvalidArgument("shared_name cannot start with '_':", |
| 290 | attr_shared_name); |
| 291 | } |
| 292 | if (!attr_container.empty()) { |
| 293 | container_ = attr_container; |
| 294 | } else { |
| 295 | container_ = rmgr_->default_container(); |
| 296 | } |
| 297 | if (!attr_shared_name.empty()) { |
| 298 | name_ = attr_shared_name; |
| 299 | } else if (use_node_name_as_default) { |
| 300 | name_ = ndef.name(); |
| 301 | } else { |
| 302 | resource_is_private_to_kernel_ = true; |
| 303 | static std::atomic<int64> counter(0); |
| 304 | name_ = strings::StrCat("_", counter.fetch_add(1), "_", ndef.name()); |
| 305 | } |
| 306 | return Status::OK(); |
| 307 | } |
| 308 | |
| 309 | string ContainerInfo::DebugString() const { |
| 310 | return strings::StrCat("[", container(), ",", name(), ",", |
nothing calls this directly
no test coverage detected