Remove the control inputs cops from co. Warning: this function is directly manipulating the internals of the `tf.Graph`. Args: op: a `tf.Operation` from which to remove the control inputs. cops: an object convertible to a list of `tf.Operation`. Raises: TypeError: if op is not
(op, cops)
| 452 | |
| 453 | |
| 454 | def remove_control_inputs(op, cops): |
| 455 | """Remove the control inputs cops from co. |
| 456 | |
| 457 | Warning: this function is directly manipulating the internals of the |
| 458 | `tf.Graph`. |
| 459 | |
| 460 | Args: |
| 461 | op: a `tf.Operation` from which to remove the control inputs. |
| 462 | cops: an object convertible to a list of `tf.Operation`. |
| 463 | Raises: |
| 464 | TypeError: if op is not a `tf.Operation`. |
| 465 | ValueError: if any cop in cops is not a control input of op. |
| 466 | """ |
| 467 | if not isinstance(op, _tf_ops.Operation): |
| 468 | raise TypeError("Expected a tf.Operation, got: {}", type(op)) |
| 469 | cops = _util.make_list_of_op(cops, allow_graph=False) |
| 470 | for cop in cops: |
| 471 | if cop not in op.control_inputs: |
| 472 | raise ValueError("{} is not a control_input of {}".format(op.name, |
| 473 | cop.name)) |
| 474 | control_inputs = [cop for cop in op.control_inputs if cop not in cops] |
| 475 | # pylint: disable=protected-access |
| 476 | op._remove_all_control_inputs() |
| 477 | op._add_control_inputs(control_inputs) |
| 478 | # pylint: enable=protected-access |
| 479 | |
| 480 | |
| 481 | def add_control_inputs(op, cops): |
nothing calls this directly
no test coverage detected