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)
| 933 | |
| 934 | @tf_export("is_tensor") |
| 935 | def 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 | |
| 952 | def shape_tensor(shape): # pylint: disable=invalid-name |
no outgoing calls
no test coverage detected