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) # pylint: disable=protected-access for t in op.inputs ] # 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
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