DataTypeΒΆ

class onnx_ir.DataType(value)ΒΆ

Enum for the data types of ONNX tensors, defined in onnx.TensorProto.

classmethod from_numpy(dtype: dtype) DataType[source]ΒΆ

Returns the ONNX data type for the numpy dtype.

Raises:

TypeError – If the data type is not supported by ONNX.

classmethod from_short_name(short_name: str) DataType[source]ΒΆ

Returns the ONNX data type for the short name.

Raises:

TypeError – If the short name is not available for the data type.

property itemsize: floatΒΆ

Returns the size of the data type in bytes.

numpy() dtype[source]ΒΆ

Returns the numpy dtype for the ONNX data type.

Raises:

TypeError – If the data type is not supported by numpy.

short_name() str[source]ΒΆ

Returns the short name of the data type.

The short name is a string that is used to represent the data type in a more compact form. For example, the short name for DataType.FLOAT is β€œf32”. To get the corresponding data type back, call from_short_name on a string.

Naming reference: https://github.com/pytorch/pytorch/blob/4bead7b85ea4160243c74109e0ce9bb80686d016/torch/utils/_dtype_abbrs.py

Raises:

TypeError – If the short name is not available for the data type.

is_floating_point() bool[source]ΒΆ

Returns True if the data type is a floating point type.

UNDEFINED = 0ΒΆ
FLOAT = 1ΒΆ
UINT8 = 2ΒΆ
INT8 = 3ΒΆ
UINT16 = 4ΒΆ
INT16 = 5ΒΆ
INT32 = 6ΒΆ
INT64 = 7ΒΆ
STRING = 8ΒΆ
BOOL = 9ΒΆ
FLOAT16 = 10ΒΆ
DOUBLE = 11ΒΆ
UINT32 = 12ΒΆ
UINT64 = 13ΒΆ
COMPLEX64 = 14ΒΆ
COMPLEX128 = 15ΒΆ
BFLOAT16 = 16ΒΆ
FLOAT8E4M3FN = 17ΒΆ
FLOAT8E4M3FNUZ = 18ΒΆ
FLOAT8E5M2 = 19ΒΆ
FLOAT8E5M2FNUZ = 20ΒΆ
UINT4 = 21ΒΆ
INT4 = 22ΒΆ
FLOAT4E2M1 = 23ΒΆ