Returns the size of a tensor. Returns a 0-D `Tensor` representing the number of elements in `input` of type `out_type`. Defaults to tf.int32. For example: ```python t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]) tf.size(t) # 12 ``` Args: input: A `Tensor`
(input, name=None, out_type=dtypes.int32)
| 504 | @tf_export(v1=["size"]) |
| 505 | @dispatch.add_dispatch_support |
| 506 | def size(input, name=None, out_type=dtypes.int32): |
| 507 | # pylint: disable=redefined-builtin |
| 508 | """Returns the size of a tensor. |
| 509 | |
| 510 | Returns a 0-D `Tensor` representing the number of elements in `input` |
| 511 | of type `out_type`. Defaults to tf.int32. |
| 512 | |
| 513 | For example: |
| 514 | |
| 515 | ```python |
| 516 | t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]) |
| 517 | tf.size(t) # 12 |
| 518 | ``` |
| 519 | |
| 520 | Args: |
| 521 | input: A `Tensor` or `SparseTensor`. |
| 522 | name: A name for the operation (optional). |
| 523 | out_type: (Optional) The specified non-quantized numeric output type of the |
| 524 | operation. Defaults to `tf.int32`. |
| 525 | |
| 526 | Returns: |
| 527 | A `Tensor` of type `out_type`. Defaults to `tf.int32`. |
| 528 | |
| 529 | @compatibility(numpy) |
| 530 | Equivalent to np.size() |
| 531 | @end_compatibility |
| 532 | """ |
| 533 | return size_internal(input, name, optimize=True, out_type=out_type) |
| 534 | |
| 535 | |
| 536 | def size_internal(input, name=None, optimize=True, out_type=dtypes.int32): |
no test coverage detected