| 450 | } |
| 451 | |
| 452 | Node* Graph::CopyNode(const Node* node) { |
| 453 | DCHECK(!node->IsSource()); |
| 454 | DCHECK(!node->IsSink()); |
| 455 | Node* copy = AllocateNode(node->props_, node); |
| 456 | copy->set_assigned_device_name(node->assigned_device_name()); |
| 457 | |
| 458 | // Since the OpDef of a function may be owned by the Graph that owns 'node', |
| 459 | // relookup the OpDef in the target graph. If it differs, then clone the |
| 460 | // node properties with the updated OpDef. |
| 461 | const OpDef* op_def; |
| 462 | TF_CHECK_OK(ops_.LookUpOpDef(node->type_string(), &op_def)); |
| 463 | if (op_def != node->props_->op_def) { |
| 464 | copy->MaybeCopyOnWrite(); |
| 465 | copy->props_->op_def = op_def; |
| 466 | } |
| 467 | |
| 468 | return copy; |
| 469 | } |
| 470 | |
| 471 | void Graph::RemoveNode(Node* node) { |
| 472 | TF_DCHECK_OK(IsValidNode(node)) << node->DebugString(); |