Enum Class DataType

java.lang.Object
java.lang.Enum<DataType>
ai.djl.ndarray.types.DataType
All Implemented Interfaces:
Serializable, Comparable<DataType>, Constable

public enum DataType extends Enum<DataType>
An enum representing the underlying NDArray's data type.
  • Enum Constant Details

    • 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 Details

    • values

      public static DataType[] 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

      public static DataType valueOf(String name)
      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 name
      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(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(String dtype)
      Returns the data type from numpy value.
      Parameters:
      dtype - the numpy datatype
      Returns:
      the data type
    • fromSafetensors

      public static DataType fromSafetensors(String dtype)
      Returns the data type from Safetensors value.
      Parameters:
      dtype - the Safetensors datatype
      Returns:
      the data type
    • asDataType

      public Buffer asDataType(ByteBuffer data)
      Converts a ByteBuffer to a buffer for this data type.
      Parameters:
      data - the buffer to convert
      Returns:
      the converted buffer
    • asNumpy

      public String asNumpy()
      Returns a numpy string value.
      Returns:
      a numpy string value
    • asSafetensors

      public String asSafetensors()
      Returns a safetensors string value.
      Returns:
      a safetensors string value
    • toString

      public String toString()
      Overrides:
      toString in class Enum<DataType>