Copy a subgraph. Args: sgv: the source subgraph-view. This argument is converted to a subgraph using the same rules than the function subgraph.make_view. dst_graph: the destination graph. dst_scope: the destination scope. src_scope: the source scope. reuse_dst_scope: if
(sgv, dst_graph=None, dst_scope="", src_scope="",
reuse_dst_scope=False)
| 589 | |
| 590 | |
| 591 | def copy(sgv, dst_graph=None, dst_scope="", src_scope="", |
| 592 | reuse_dst_scope=False): |
| 593 | """Copy a subgraph. |
| 594 | |
| 595 | Args: |
| 596 | sgv: the source subgraph-view. This argument is converted to a subgraph |
| 597 | using the same rules than the function subgraph.make_view. |
| 598 | dst_graph: the destination graph. |
| 599 | dst_scope: the destination scope. |
| 600 | src_scope: the source scope. |
| 601 | reuse_dst_scope: if True the dst_scope is re-used if it already exists. |
| 602 | Otherwise, the scope is given a unique name based on the one given |
| 603 | by appending an underscore followed by a digit (default). |
| 604 | Returns: |
| 605 | A tuple `(sgv, info)` where: |
| 606 | `sgv` is the transformed subgraph view; |
| 607 | `info` is an instance of TransformerInfo containing |
| 608 | information about the transform, including mapping between |
| 609 | original and transformed tensors and operations. |
| 610 | Raises: |
| 611 | TypeError: if `dst_graph` is not a `tf.Graph`. |
| 612 | StandardError: if sgv cannot be converted to a SubGraphView using |
| 613 | the same rules than the function subgraph.make_view. |
| 614 | """ |
| 615 | sgv = subgraph.make_view(sgv) |
| 616 | if dst_graph is None: |
| 617 | dst_graph = sgv.graph |
| 618 | if not isinstance(dst_graph, tf_ops.Graph): |
| 619 | raise TypeError("Expected a tf.Graph, got: {}".format(type(dst_graph))) |
| 620 | |
| 621 | copier = Transformer() |
| 622 | return copier( |
| 623 | sgv, dst_graph, dst_scope, src_scope, reuse_dst_scope=reuse_dst_scope) |
| 624 | |
| 625 | |
| 626 | def copy_with_input_replacements(sgv, replacement_ts, |