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

Function _all_dimensions

tensorflow/python/ops/array_ops.py:3521–3533  ·  view source on GitHub ↗

Returns a 1D-tensor listing all dimensions in x.

(x)

Source from the content-addressed store, hash-verified

3519
3520
3521def _all_dimensions(x):
3522 """Returns a 1D-tensor listing all dimensions in x."""
3523 # Fast path: avoid creating Rank and Range ops if ndims is known.
3524 if isinstance(x, ops.Tensor) and x.get_shape().ndims is not None:
3525 return constant_op.constant(
3526 np.arange(x.get_shape().ndims), dtype=dtypes.int32)
3527 if (isinstance(x, sparse_tensor.SparseTensor) and
3528 x.dense_shape.get_shape().is_fully_defined()):
3529 r = x.dense_shape.get_shape().dims[0].value # sparse.dense_shape is 1-D.
3530 return constant_op.constant(np.arange(r), dtype=dtypes.int32)
3531
3532 # Otherwise, we rely on `range` and `rank` to do the right thing at runtime.
3533 return gen_math_ops._range(0, rank(x), 1)
3534
3535
3536@tf_export("sequence_mask")

Callers 2

sequence_maskFunction · 0.85
repeat_with_axisFunction · 0.85

Calls 4

is_fully_definedMethod · 0.80
rankFunction · 0.70
get_shapeMethod · 0.45
constantMethod · 0.45

Tested by

no test coverage detected