Package ai.djl.ndarray.types
Enum DataType
- java.lang.Object
-
- java.lang.Enum<DataType>
-
- ai.djl.ndarray.types.DataType
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataType.FormatThe general data type format categories.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.BufferasDataType(java.nio.ByteBuffer data)Converts aByteBufferto a buffer for this data type.java.lang.StringasNumpy()Returns a numpy string value.java.lang.StringasSafetensors()Returns a safetensors string value.static DataTypefromBuffer(java.nio.Buffer data)Returns the data type to use for a data buffer.static DataTypefromNumpy(java.lang.String dtype)Returns the data type from numpy value.static DataTypefromSafetensors(java.lang.String dtype)Returns the data type from Safetensors value.DataType.FormatgetFormat()Returns the format of the data type.intgetNumOfBytes()Returns the number of bytes for each element.booleanisBoolean()Checks whether it is a boolean data type.booleanisFloating()Checks whether it is a floating data type.booleanisInteger()Checks whether it is an integer data type.java.lang.StringtoString()static DataTypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static DataType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FLOAT32
public static final DataType FLOAT32
-
FLOAT64
public static final DataType FLOAT64
-
FLOAT16
public static final DataType FLOAT16
-
UINT8
public static final DataType UINT8
-
INT32
public static final DataType INT32
-
INT8
public static final DataType INT8
-
INT64
public static final DataType INT64
-
BOOLEAN
public static final DataType BOOLEAN
-
COMPLEX64
public static final DataType COMPLEX64
-
UNKNOWN
public static final DataType UNKNOWN
-
STRING
public static final DataType STRING
-
BFLOAT16
public static final DataType BFLOAT16
-
UINT64
public static final DataType UINT64
-
UINT32
public static final DataType UINT32
-
UINT16
public static final DataType UINT16
-
INT16
public static final DataType INT16
-
-
Method Detail
-
values
public static DataType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DataType c : DataType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DataType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- 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
public DataType.Format 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
public static DataType fromBuffer(java.nio.Buffer data)
Returns the data type to use for a data buffer.- Parameters:
data- the buffer to analyze- Returns:
- the data type for the buffer
-
fromNumpy
public static DataType fromNumpy(java.lang.String dtype)
Returns the data type from numpy value.- Parameters:
dtype- the numpy datatype- Returns:
- the data type
-
fromSafetensors
public static DataType fromSafetensors(java.lang.String dtype)
Returns the data type from Safetensors value.- Parameters:
dtype- the Safetensors datatype- Returns:
- the data type
-
asDataType
public java.nio.Buffer asDataType(java.nio.ByteBuffer data)
Converts aByteBufferto a buffer for this data type.- Parameters:
data- the buffer to convert- Returns:
- the converted buffer
-
asNumpy
public java.lang.String asNumpy()
Returns a numpy string value.- Returns:
- a numpy string value
-
asSafetensors
public java.lang.String asSafetensors()
Returns a safetensors string value.- Returns:
- a safetensors string value
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Enum<DataType>
-
-