コード例 #1
0
ファイル: edit.py プロジェクト: 2020zyc/tensorflow
def bypass(sgv):
  """Bypass the given subgraph by connecting its inputs to its outputs.

  Args:
    sgv: the subgraph view to be bypassed. This argument is converted to a
      subgraph using the same rules than the function subgraph.make_view.
  Returns:
    A new subgraph view of the bypassed subgraph.
      Note that sgv is also modified in place.
  Raises:
    StandardError: if sgv cannot be converted to a SubGraphView using
      the same rules than the function subgraph.make_view.
  """
  # TODO(fkp): allows to plug sgv.inputs to individual sgv.outputs consumers
  sgv = subgraph.make_view(sgv)
  sgv_inputs = list(sgv.inputs)
  sgv, detached_inputs = detach_inputs(sgv)
  reroute.reroute_a2b_ts(sgv_inputs, sgv.outputs)
  return sgv, detached_inputs
コード例 #2
0
ファイル: edit.py プロジェクト: instadeep/Mobile-ai
def bypass(sgv):
    """Bypass the given subgraph by connecting its inputs to its outputs.

  Args:
    sgv: the subgraph view to be bypassed. This argument is converted to a
      subgraph using the same rules than the function subgraph.make_view.
  Returns:
    A new subgraph view of the bypassed subgraph.
      Note that sgv is also modified in place.
  Raises:
    StandardError: if sgv cannot be converted to a SubGraphView using
      the same rules than the function subgraph.make_view.
  """
    # TODO(fkp): allows to plug sgv.inputs to individual sgv.outputs consumers
    sgv = subgraph.make_view(sgv)
    sgv_inputs = list(sgv.inputs)
    sgv, detached_inputs = detach_inputs(sgv)
    reroute.reroute_a2b_ts(sgv_inputs, sgv.outputs)
    return sgv, detached_inputs
コード例 #3
0
def transform_op_in_place(info, op, detach_outputs=False):
    """Transform a op in-place - experimental!

  Transform an operation in place. It reconnects the inputs if they have been
  modified. if detach_outputs is True, the outputs of op are also detached.

  Args:
    info: Transform._Info instance.
    op: the op to transform in place.
    detach_outputs: if True, the outputs of op are detached, ready for the user
      to add more operation.
  Returns:
    The transformed op.
  """
    # recursive call to the inputs:
    inputs = [info.transformer._transform_t(t) for t in op.inputs]  # pylint: disable=protected-access
    # re-connect to the inputs if they have changed:
    if inputs != list(op.inputs):
        reroute.reroute_a2b_ts(inputs, op.inputs)
    # detach op from its consumer first ?
    if detach_outputs:
        edit.detach_outputs(op)
    return op
コード例 #4
0
ファイル: transform.py プロジェクト: 2020zyc/tensorflow
def transform_op_in_place(info, op, detach_outputs=False):
  """Transform a op in-place - experimental!

  Transform an operation in place. It reconnects the inputs if they have been
  modified. if detach_outputs is True, the outputs of op are also detached.

  Args:
    info: Transform._Info instance.
    op: the op to transform in place.
    detach_outputs: if True, the outputs of op are detached, ready for the user
      to add more operation.
  Returns:
    the transformed op.
  """
  # recursive call to the inputs:
  inputs = [info.transformer._transform_t(t) for t in op.inputs]  # pylint: disable=protected-access
  # re-connect to the inputs if they have changed:
  if inputs != list(op.inputs):
    reroute.reroute_a2b_ts(inputs, op.inputs)
  # detach op from its consumer first ?
  if detach_outputs:
    edit.detach_outputs(op)
  return op