Creates a new `Tensor`. Args: op: An `Operation`. `Operation` that computes this tensor. value_index: An `int`. Index of the operation's endpoint that produces this tensor. dtype: A `DType`. Type of elements stored in this tensor. Raises: TypeError: If the o
(self, op, value_index, dtype)
| 368 | _USE_EQUALITY = tf2.enabled() |
| 369 | |
| 370 | def __init__(self, op, value_index, dtype): |
| 371 | """Creates a new `Tensor`. |
| 372 | |
| 373 | Args: |
| 374 | op: An `Operation`. `Operation` that computes this tensor. |
| 375 | value_index: An `int`. Index of the operation's endpoint that produces |
| 376 | this tensor. |
| 377 | dtype: A `DType`. Type of elements stored in this tensor. |
| 378 | |
| 379 | Raises: |
| 380 | TypeError: If the op is not an `Operation`. |
| 381 | """ |
| 382 | if not isinstance(op, Operation): |
| 383 | raise TypeError("op needs to be an Operation: %s" % op) |
| 384 | self._op = op |
| 385 | self._value_index = value_index |
| 386 | self._dtype = dtypes.as_dtype(dtype) |
| 387 | # This will be set by self._as_tf_output(). |
| 388 | self._tf_output = None |
| 389 | # This will be set by self.shape(). |
| 390 | self._shape_val = None |
| 391 | # List of operations that use this Tensor as input. We maintain this list |
| 392 | # to easily navigate a computation graph. |
| 393 | self._consumers = [] |
| 394 | self._id = uid() |
| 395 | self._name = None |
| 396 | |
| 397 | @property |
| 398 | def op(self): |