MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _add_op

Method _add_op

tensorflow/python/framework/ops.py:3004–3028  ·  view source on GitHub ↗

Adds 'op' to the graph. Args: op: the Operator or Tensor to add. Raises: TypeError: if op is not an Operation or Tensor. ValueError: if the op.name or op._id are already used.

(self, op)

Source from the content-addressed store, hash-verified

3002 raise RuntimeError("Graph is finalized and cannot be modified.")
3003
3004 def _add_op(self, op):
3005 """Adds 'op' to the graph.
3006
3007 Args:
3008 op: the Operator or Tensor to add.
3009
3010 Raises:
3011 TypeError: if op is not an Operation or Tensor.
3012 ValueError: if the op.name or op._id are already used.
3013 """
3014 self._check_not_finalized()
3015 if not isinstance(op, (Tensor, Operation)):
3016 raise TypeError("op must be a Tensor or Operation: %s" % op)
3017 with self._lock:
3018 # pylint: disable=protected-access
3019 if op._id in self._nodes_by_id:
3020 raise ValueError("cannot add an op with id %d as it already "
3021 "exists in the graph" % op._id)
3022 if op.name in self._nodes_by_name:
3023 raise ValueError("cannot add op with name %s as that name "
3024 "is already used" % op.name)
3025 self._nodes_by_id[op._id] = op
3026 self._nodes_by_name[op.name] = op
3027 self._version = max(self._version, op._id)
3028 # pylint: enable=protected-access
3029
3030 @property
3031 def _c_graph(self):

Callers 1

__init__Method · 0.45

Calls 2

_check_not_finalizedMethod · 0.95
maxFunction · 0.50

Tested by

no test coverage detected