# TODO(rahulkamat): Add missing types that are convertible to Tensor. TensorLike = Union[Tensor, TensorProtocol, int, float, bool, str, bytes, complex, tuple, list, np.ndarray, np.generic] doc_typealias.document( obj=TensorLike, doc=textwrap.dedent("""\ Union of all types that can be converted to a `tf.Tensor` by `tf.convert_to_tensor`. This definition may be used in user code. Additional types may be added in the future as more input types are supported. Example: ``` def foo(x: TensorLike): pass ``` This definition passes static type verification for: ``` foo(tf.constant([1, 2, 3])) foo([1, 2, 3]) foo(np.array([1, 2, 3])) ``` """), ) tf_export("types.experimental.TensorLike").export_constant( __name__, "TensorLike")
np.uint8: (0, 255), np.uint16: (0, 65535), np.int8: (-128, 127), np.int16: (-32768, 32767), np.int64: (-2**63, 2**63 - 1), np.uint64: (0, 2**64 - 1), np.int32: (-2**31, 2**31 - 1), np.uint32: (0, 2**32 - 1), np.float32: (-1, 1), np.float64: (-1, 1) } # Define standard wrappers for the types_pb2.DataType enum. resource = DType(types_pb2.DT_RESOURCE) doc_typealias.document( obj=resource, doc="Handle to a mutable, dynamically allocated resource.") tf_export("dtypes.resource", "resource").export_constant(__name__, "resource") variant = DType(types_pb2.DT_VARIANT) doc_typealias.document( obj=variant, doc="Data of arbitrary type (known at runtime).") tf_export("dtypes.variant", "variant").export_constant(__name__, "variant") uint8 = DType(types_pb2.DT_UINT8) doc_typealias.document( obj=uint8, doc="Unsigned 8-bit (byte) integer.") tf_export("dtypes.uint8", "uint8").export_constant(__name__, "uint8")