Detach the inputs of a subgraph view. Args: sgv: the subgraph view to be detached. This argument is converted to a subgraph using the same rules as the function subgraph.make_view. Note that sgv is modified in place. control_inputs: if True control_inputs are also detached.
(sgv, control_inputs=False)
| 68 | |
| 69 | |
| 70 | def detach_inputs(sgv, control_inputs=False): |
| 71 | """Detach the inputs of a subgraph view. |
| 72 | |
| 73 | Args: |
| 74 | sgv: the subgraph view to be detached. This argument is converted to a |
| 75 | subgraph using the same rules as the function subgraph.make_view. |
| 76 | Note that sgv is modified in place. |
| 77 | control_inputs: if True control_inputs are also detached. |
| 78 | Returns: |
| 79 | A tuple `(sgv, input_placeholders)` where |
| 80 | `sgv` is a new subgraph view of the detached subgraph; |
| 81 | `input_placeholders` is a list of the created input placeholders. |
| 82 | Raises: |
| 83 | StandardError: if sgv cannot be converted to a SubGraphView using |
| 84 | the same rules than the function subgraph.make_view. |
| 85 | """ |
| 86 | sgv = subgraph.make_view(sgv) |
| 87 | |
| 88 | with sgv.graph.as_default(): |
| 89 | input_placeholders = [ |
| 90 | tf_array_ops.placeholder( |
| 91 | dtype=input_t.dtype, name=util.placeholder_name(input_t)) |
| 92 | for input_t in sgv.inputs |
| 93 | ] |
| 94 | |
| 95 | reroute.swap_inputs(sgv, input_placeholders) |
| 96 | if control_inputs: |
| 97 | detach_control_inputs(sgv) |
| 98 | return sgv, input_placeholders |
| 99 | |
| 100 | |
| 101 | def detach_outputs(sgv, control_outputs=None): |
no test coverage detected