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

Function _ReductionDims

tensorflow/python/ops/math_ops.py:1431–1451  ·  view source on GitHub ↗

Returns range(0, rank(x)) if reduction_indices is None.

(x, axis, reduction_indices=None)

Source from the content-addressed store, hash-verified

1429
1430# Reduction operations
1431def _ReductionDims(x, axis, reduction_indices=None): # pylint: disable=invalid-name
1432 """Returns range(0, rank(x)) if reduction_indices is None."""
1433 # TODO(aselle): Remove this after deprecation
1434 if reduction_indices is not None:
1435 if axis is not None:
1436 raise ValueError("Can't specify both axis' and 'reduction_indices'.")
1437 axis = reduction_indices
1438 if axis is not None:
1439 return axis
1440 else:
1441 # Fast path: avoid creating Rank and Range ops if ndims is known.
1442 rank = common_shapes.rank(x)
1443 if rank is not None:
1444 return constant_op.constant(np.arange(rank), dtype=dtypes.int32)
1445 if (isinstance(x, sparse_tensor.SparseTensor) and
1446 x.dense_shape.shape.is_fully_defined()):
1447 rank = x.dense_shape.shape.dims[0].value # sparse.dense_shape is 1-D.
1448 return constant_op.constant(np.arange(rank), dtype=dtypes.int32)
1449
1450 # Otherwise, we rely on Range and Rank to do the right thing at run-time.
1451 return range(0, array_ops.rank(x))
1452
1453
1454def _may_reduce_to_scalar(keepdims, axis, output):

Callers 8

reduce_sumFunction · 0.85
reduce_euclidean_normFunction · 0.85
reduce_meanFunction · 0.85
reduce_prodFunction · 0.85
reduce_minFunction · 0.85
reduce_maxFunction · 0.85
reduce_allFunction · 0.85
reduce_anyFunction · 0.85

Calls 4

is_fully_definedMethod · 0.80
rangeFunction · 0.70
rankMethod · 0.45
constantMethod · 0.45

Tested by

no test coverage detected