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

Class DType

tensorflow/python/framework/dtypes.py:31–296  ·  view source on GitHub ↗

Represents the type of the elements in a `Tensor`. The following `DType` objects are defined: * `tf.float16`: 16-bit half-precision floating-point. * `tf.float32`: 32-bit single-precision floating-point. * `tf.float64`: 64-bit double-precision floating-point. * `tf.bfloat16`: 16-bit trun

Source from the content-addressed store, hash-verified

29
30@tf_export("dtypes.DType", "DType")
31class DType(object):
32 """Represents the type of the elements in a `Tensor`.
33
34 The following `DType` objects are defined:
35
36 * `tf.float16`: 16-bit half-precision floating-point.
37 * `tf.float32`: 32-bit single-precision floating-point.
38 * `tf.float64`: 64-bit double-precision floating-point.
39 * `tf.bfloat16`: 16-bit truncated floating-point.
40 * `tf.complex64`: 64-bit single-precision complex.
41 * `tf.complex128`: 128-bit double-precision complex.
42 * `tf.int8`: 8-bit signed integer.
43 * `tf.uint8`: 8-bit unsigned integer.
44 * `tf.uint16`: 16-bit unsigned integer.
45 * `tf.uint32`: 32-bit unsigned integer.
46 * `tf.uint64`: 64-bit unsigned integer.
47 * `tf.int16`: 16-bit signed integer.
48 * `tf.int32`: 32-bit signed integer.
49 * `tf.int64`: 64-bit signed integer.
50 * `tf.bool`: Boolean.
51 * `tf.string`: String.
52 * `tf.qint8`: Quantized 8-bit signed integer.
53 * `tf.quint8`: Quantized 8-bit unsigned integer.
54 * `tf.qint16`: Quantized 16-bit signed integer.
55 * `tf.quint16`: Quantized 16-bit unsigned integer.
56 * `tf.qint32`: Quantized 32-bit signed integer.
57 * `tf.resource`: Handle to a mutable resource.
58 * `tf.variant`: Values of arbitrary types.
59
60 The `tf.as_dtype()` function converts numpy types and string type
61 names to a `DType` object.
62 """
63
64 def __init__(self, type_enum):
65 """Creates a new `DataType`.
66
67 NOTE(mrry): In normal circumstances, you should not need to
68 construct a `DataType` object directly. Instead, use the
69 `tf.as_dtype()` function.
70
71 Args:
72 type_enum: A `types_pb2.DataType` enum value.
73
74 Raises:
75 TypeError: If `type_enum` is not a value `types_pb2.DataType`.
76
77 """
78 # TODO(mrry): Make the necessary changes (using __new__) to ensure
79 # that calling this returns one of the interned values.
80 type_enum = int(type_enum)
81 if (type_enum not in types_pb2.DataType.values() or
82 type_enum == types_pb2.DT_INVALID):
83 raise TypeError("type_enum is not a valid types_pb2.DataType: %s" %
84 type_enum)
85 self._type_enum = type_enum
86
87 @property
88 def _is_ref_dtype(self):

Callers 1

dtypes.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected