if context.in_eager_mode() and not isinstance(
input, (sparse_tensor.SparseTensor,
sparse_tensor.SparseTensorValue)):
- size_ = 1
- for dim in ops.convert_to_tensor(input)._shape_tuple(): # pylint: disable=protected-access
- size_ *= dim
- return size_
+ return np.prod(ops.convert_to_tensor(input)._shape_tuple()) # pylint: disable=protected-access
with ops.name_scope(name, "Size", [input]) as name:
if isinstance(input, (sparse_tensor.SparseTensor,
sparse_tensor.SparseTensorValue)):
Returns:
The element-wise value of the numerator divided by the denominator.
"""
- if isinstance(denominator, float):
- if math_ops.equal(denominator, 0.0):
- return ops.convert_to_tensor(0.0, dtype=numerator.dtype)
- return math_ops.div(numerator, denominator)
- if context.in_eager_mode() and denominator._rank() == 0: # pylint: disable=protected-access
- if math_ops.equal(denominator, 0.0):
- return ops.convert_to_tensor(0.0, dtype=numerator.dtype)
- return math_ops.div(numerator, denominator)
return array_ops.where(
math_ops.greater(denominator, 0),
math_ops.div(numerator, array_ops.where(