| 324 | } |
| 325 | |
| 326 | void Scope::UpdateBuilder(NodeBuilder* builder) const { |
| 327 | std::vector<Node*> control_inputs; |
| 328 | for (const auto& op : impl()->control_deps_) { |
| 329 | control_inputs.push_back(op.node()); |
| 330 | } |
| 331 | builder->ControlInputs(control_inputs); |
| 332 | |
| 333 | if (!impl()->kernel_label_.empty()) { |
| 334 | builder->Attr("_kernel", impl()->kernel_label_); |
| 335 | } |
| 336 | |
| 337 | if (!impl()->colocation_constraints_.empty()) { |
| 338 | std::vector<string> constraints(impl()->colocation_constraints_.begin(), |
| 339 | impl()->colocation_constraints_.end()); |
| 340 | // Sort the set. |
| 341 | std::sort(constraints.begin(), constraints.end()); |
| 342 | // Add loc:@ prefix |
| 343 | std::transform(constraints.begin(), constraints.end(), constraints.begin(), |
| 344 | [](const string& s) { |
| 345 | return strings::StrCat(kColocationGroupPrefix, s); |
| 346 | }); |
| 347 | builder->Attr(kColocationAttrName, constraints); |
| 348 | } |
| 349 | if (!impl()->device_.empty()) { |
| 350 | builder->Device(impl()->device_); |
| 351 | } |
| 352 | if (!impl()->assigned_device_.empty()) { |
| 353 | builder->AssignedDevice(impl()->assigned_device_); |
| 354 | } |
| 355 | if (!impl()->xla_cluster_.empty()) { |
| 356 | builder->XlaCluster(impl()->xla_cluster_); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | string Scope::Impl::GetUniqueName(const string& prefix, |
| 361 | bool check_single_use) const { |