Represents a graph node that performs computation on tensors. An `Operation` is a node in a TensorFlow `Graph` that takes zero or more `Tensor` objects as input, and produces zero or more `Tensor` objects as output. Objects of type `Operation` are created by calling a Python op constructor
| 1614 | |
| 1615 | @tf_export("Operation") |
| 1616 | class Operation(object): |
| 1617 | """Represents a graph node that performs computation on tensors. |
| 1618 | |
| 1619 | An `Operation` is a node in a TensorFlow `Graph` that takes zero or |
| 1620 | more `Tensor` objects as input, and produces zero or more `Tensor` |
| 1621 | objects as output. Objects of type `Operation` are created by |
| 1622 | calling a Python op constructor (such as |
| 1623 | `tf.matmul`) |
| 1624 | or `tf.Graph.create_op`. |
| 1625 | |
| 1626 | For example `c = tf.matmul(a, b)` creates an `Operation` of type |
| 1627 | "MatMul" that takes tensors `a` and `b` as input, and produces `c` |
| 1628 | as output. |
| 1629 | |
| 1630 | After the graph has been launched in a session, an `Operation` can |
| 1631 | be executed by passing it to |
| 1632 | `tf.Session.run`. |
| 1633 | `op.run()` is a shortcut for calling |
| 1634 | `tf.compat.v1.get_default_session().run(op)`. |
| 1635 | """ |
| 1636 | |
| 1637 | def __init__(self, |
| 1638 | node_def, |
| 1639 | g, |
| 1640 | inputs=None, |
| 1641 | output_types=None, |
| 1642 | control_inputs=None, |
| 1643 | input_types=None, |
| 1644 | original_op=None, |
| 1645 | op_def=None): |
| 1646 | r"""Creates an `Operation`. |
| 1647 | |
| 1648 | NOTE: This constructor validates the name of the `Operation` (passed |
| 1649 | as `node_def.name`). Valid `Operation` names match the following |
| 1650 | regular expression: |
| 1651 | |
| 1652 | [A-Za-z0-9.][A-Za-z0-9_.\\-/]* |
| 1653 | |
| 1654 | Args: |
| 1655 | node_def: `node_def_pb2.NodeDef`. `NodeDef` for the `Operation`. Used for |
| 1656 | attributes of `node_def_pb2.NodeDef`, typically `name`, `op`, and |
| 1657 | `device`. The `input` attribute is irrelevant here as it will be |
| 1658 | computed when generating the model. |
| 1659 | g: `Graph`. The parent graph. |
| 1660 | inputs: list of `Tensor` objects. The inputs to this `Operation`. |
| 1661 | output_types: list of `DType` objects. List of the types of the `Tensors` |
| 1662 | computed by this operation. The length of this list indicates the |
| 1663 | number of output endpoints of the `Operation`. |
| 1664 | control_inputs: list of operations or tensors from which to have a control |
| 1665 | dependency. |
| 1666 | input_types: List of `DType` objects representing the types of the tensors |
| 1667 | accepted by the `Operation`. By default uses `[x.dtype.base_dtype for x |
| 1668 | in inputs]`. Operations that expect reference-typed inputs must specify |
| 1669 | these explicitly. |
| 1670 | original_op: Optional. Used to associate the new `Operation` with an |
| 1671 | existing `Operation` (for example, a replica with the op that was |
| 1672 | replicated). |
| 1673 | op_def: Optional. The `op_def_pb2.OpDef` proto that describes the op type |
no outgoing calls
no test coverage detected