The number of elements in the `grad` tensor.
(grad)
| 606 | |
| 607 | |
| 608 | def _num_elements(grad): |
| 609 | """The number of elements in the `grad` tensor.""" |
| 610 | if isinstance(grad, ops.Tensor): |
| 611 | shape_tuple = grad._shape_tuple() # pylint: disable=protected-access |
| 612 | if shape_tuple is None or None in shape_tuple: |
| 613 | return 0 |
| 614 | return functools.reduce(operator.mul, shape_tuple, 1) |
| 615 | if isinstance(grad, ops.IndexedSlices): |
| 616 | return functools.reduce(operator.mul, grad.values._shape_tuple(), 1) # pylint: disable=protected-access |
| 617 | raise ValueError("`grad` not a Tensor or IndexedSlices.") |
| 618 | |
| 619 | |
| 620 | def _fast_fill(value, shape, dtype): |
nothing calls this directly
no test coverage detected