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

Function is_tensor

tensorflow/python/framework/tensor_util.py:935–949  ·  view source on GitHub ↗

Checks whether `x` is a tensor or "tensor-like". If `is_tensor(x)` returns `True`, it is safe to assume that `x` is a tensor or can be converted to a tensor using `ops.convert_to_tensor(x)`. Args: x: A python object to check. Returns: `True` if `x` is a tensor or "tensor-like", `F

(x)

Source from the content-addressed store, hash-verified

933
934@tf_export("is_tensor")
935def is_tensor(x): # pylint: disable=invalid-name
936 """Checks whether `x` is a tensor or "tensor-like".
937
938 If `is_tensor(x)` returns `True`, it is safe to assume that `x` is a tensor or
939 can be converted to a tensor using `ops.convert_to_tensor(x)`.
940
941 Args:
942 x: A python object to check.
943
944 Returns:
945 `True` if `x` is a tensor or "tensor-like", `False` if not.
946 """
947 return (isinstance(x, tensor_like._TensorLike) or # pylint: disable=protected-access
948 ops.is_dense_tensor_like(x) or
949 getattr(x, "is_tensor_like", False))
950
951
952def shape_tensor(shape): # pylint: disable=invalid-name

Callers 5

constant_valueFunction · 0.70
maybe_set_static_shapeFunction · 0.70
tensorMethod · 0.50
GetTrtDimsMethod · 0.50
DebugStringMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected