Package ai.djl.ndarray.types
Enum Class DataType
- All Implemented Interfaces:
Serializable
,Comparable<DataType>
,Constable
An enum representing the underlying
NDArray
's data type.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The general data type format categories.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionasDataType
(ByteBuffer data) Converts aByteBuffer
to a buffer for this data type.asNumpy()
Returns a numpy string value.Returns a safetensors string value.static DataType
fromBuffer
(Buffer data) Returns the data type to use for a data buffer.static DataType
Returns the data type from numpy value.static DataType
fromSafetensors
(String dtype) Returns the data type from Safetensors value.Returns the format of the data type.int
Returns the number of bytes for each element.boolean
Checks whether it is a boolean data type.boolean
Checks whether it is a floating data type.boolean
Checks whether it is an integer data type.toString()
static DataType
Returns the enum constant of this class with the specified name.static DataType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FLOAT32
-
FLOAT64
-
FLOAT16
-
UINT8
-
INT32
-
INT8
-
INT64
-
BOOLEAN
-
COMPLEX64
-
UNKNOWN
-
STRING
-
BFLOAT16
-
UINT64
-
UINT32
-
UINT16
-
INT16
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getNumOfBytes
public int getNumOfBytes()Returns the number of bytes for each element.- Returns:
- the number of bytes for each element
-
getFormat
Returns the format of the data type.- Returns:
- the format of the data type
-
isFloating
public boolean isFloating()Checks whether it is a floating data type.- Returns:
- whether it is a floating data type
-
isInteger
public boolean isInteger()Checks whether it is an integer data type.- Returns:
- whether it is an integer type
-
isBoolean
public boolean isBoolean()Checks whether it is a boolean data type.- Returns:
- whether it is a boolean data type
-
fromBuffer
Returns the data type to use for a data buffer.- Parameters:
data
- the buffer to analyze- Returns:
- the data type for the buffer
-
fromNumpy
Returns the data type from numpy value.- Parameters:
dtype
- the numpy datatype- Returns:
- the data type
-
fromSafetensors
Returns the data type from Safetensors value.- Parameters:
dtype
- the Safetensors datatype- Returns:
- the data type
-
asDataType
Converts aByteBuffer
to a buffer for this data type.- Parameters:
data
- the buffer to convert- Returns:
- the converted buffer
-
asNumpy
Returns a numpy string value.- Returns:
- a numpy string value
-
asSafetensors
Returns a safetensors string value.- Returns:
- a safetensors string value
-
toString
-