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 class
DataType.Format
The general data type format categories.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.Buffer
asDataType(java.nio.ByteBuffer data)
Converts aByteBuffer
to a buffer for this data type.java.lang.String
asNumpy()
Returns a numpy string value.static DataType
fromBuffer(java.nio.Buffer data)
Returns the data type to use for a data buffer.static DataType
fromNumpy(java.lang.String dtype)
Returns the data type from numpy value.DataType.Format
getFormat()
Returns the format of the data type.int
getNumOfBytes()
Returns the number of bytes for each element.boolean
isFloating()
Checks whether it is a floating data type.boolean
isInteger()
Checks whether it is an integer data type.java.lang.String
toString()
static DataType
valueOf(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
-
UNKNOWN
public static final DataType UNKNOWN
-
STRING
public static final DataType STRING
-
-
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
-
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
-
asDataType
public java.nio.Buffer asDataType(java.nio.ByteBuffer data)
Converts aByteBuffer
to 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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Enum<DataType>
-
-