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

Function shape_tensor

tensorflow/python/framework/tensor_util.py:952–964  ·  view source on GitHub ↗

Convert to an int32 or int64 tensor, defaulting to int32 if empty.

(shape)

Source from the content-addressed store, hash-verified

950
951
952def shape_tensor(shape): # pylint: disable=invalid-name
953 """Convert to an int32 or int64 tensor, defaulting to int32 if empty."""
954 dtype = None
955 if isinstance(shape, (tuple, list)):
956 if not shape:
957 dtype = dtypes.int32
958 else:
959 # If there are Dimension objects in the shape, unwrap them. This can be a
960 # problem if v1 and v2 TensorShape objects get mixed up in partial
961 # conversions, leading to shapes such as (1, 2, Dimension(5)), which are
962 # not convertible to Tensors becasue of mixed content.
963 shape = tuple(map(tensor_shape.dimension_value, shape))
964 return ops.convert_to_tensor(shape, dtype=dtype, name="shape")
965
966
967# DO NOT USE: For testing only.

Callers 1

maybe_set_static_shapeFunction · 0.70

Calls 1

tupleFunction · 0.85

Tested by

no test coverage detected