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

Function _num_elements

tensorflow/python/eager/backprop.py:608–617  ·  view source on GitHub ↗

The number of elements in the `grad` tensor.

(grad)

Source from the content-addressed store, hash-verified

606
607
608def _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
620def _fast_fill(value, shape, dtype):

Callers

nothing calls this directly

Calls 2

_shape_tupleMethod · 0.45
reduceMethod · 0.45

Tested by

no test coverage detected