| 610 | } |
| 611 | |
| 612 | void MarkForCudaGraphModePassImpl::Cluster::Merge(Cluster* other) { |
| 613 | // We keep our own cycles_graph_node_id_ to mirror what GraphCycles does. |
| 614 | |
| 615 | // Clearing out data structures in `other` is just a memory saving |
| 616 | // optimization and not needed for correctness. |
| 617 | |
| 618 | cluster_size_ += other->cluster_size_; |
| 619 | effective_cluster_size_ += other->effective_cluster_size_; |
| 620 | has_functional_control_flow_ |= other->has_functional_control_flow_; |
| 621 | |
| 622 | devices_.UnionWith(other->devices_); |
| 623 | |
| 624 | DCHECK(!(resource_op_device_.has_value() && |
| 625 | other->resource_op_device_.has_value()) || |
| 626 | *resource_op_device_ == *other->resource_op_device_) |
| 627 | << "AreDevicesCompatible should have returned false otherwise!"; |
| 628 | |
| 629 | if (!resource_op_device_.has_value()) { |
| 630 | resource_op_device_ = other->resource_op_device_; |
| 631 | } |
| 632 | |
| 633 | is_cuda_graph_mode_attr_true_ |= other->is_cuda_graph_mode_attr_true_; |
| 634 | |
| 635 | if (!cuda_graph_mode_scope_.has_value()) { |
| 636 | cuda_graph_mode_scope_ = std::move(other->cuda_graph_mode_scope_); |
| 637 | } |
| 638 | |
| 639 | resource_var_operation_node_ids_.reserve( |
| 640 | resource_var_operation_node_ids_.size() + |
| 641 | other->resource_var_operation_node_ids_.size()); |
| 642 | absl::c_copy(other->resource_var_operation_node_ids_, |
| 643 | std::back_inserter(resource_var_operation_node_ids_)); |
| 644 | other->resource_var_operation_node_ids_.clear(); |
| 645 | } |
| 646 | |
| 647 | Status IgnoreResourceOpForSafetyAnalysis( |
| 648 | jit::DeviceInfoCache* device_info_cache, const Node& n, bool* ignore) { |