This may be a disappointing answer, but it is not possible to add a control dependency (or any other input) to TensorFlow Operationafter it is created. Tensors and operations are immutable after they are created.
, , . , Operation, op_first op_second, , op_first op_second:
def first_before_second(op_first, op_second):
"""Sequence `op_first` before `op_second`.
Given two operations, returns a pair of operations with the same behavior
except that the first returned operation will execute before the second
returned operation.
"""
with tf.control_dependencies([op_first]):
g = tf.get_default_graph()
op_second_clone = g.create_op(op_second.type,
[in_t for in_t in op_second.inputs],
[out_t.dtype for out_t in op_second.outputs],
attrs=op_second.node_def.attr,
op_def=op_second.op_def)
return op_first, op_second_clone
Tensor, .