19.3. Data types

class popxl.dtype
Return type

None

__init__()

Construct the dtype.

A class to represent the type of elements in a tensor.

Available data types are:

  • bool

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • float8_143

  • float8_152

  • float16

  • float32

  • float64

  • complex64

  • complex128

Some data types have aliases:

  • half aliases float16

  • float aliases float32

  • double aliases float64

Raises

TypeError – If an attempt is made to create an object of this class.

Return type

None

classmethod as_dtype(type_value)

Convert the given type_value to a popxl.dtype.

Parameters

type_value (Any) – A numpy.dtype, torch.dtype, string, a built-in Python type or a numpy.ndarray, torch.tensor which can be converted to a popxl.dtype.

Raises

ValueError – If type_value cannot be converted to a popxl.dtype.

Returns

A popxl.dtype corresponding to type_value.

Return type

dtype

as_numpy()

Convert the popxl.dtype to a corresponding numpy.dtype.

Raises

TypeError – If the popxl.dtype cannot be converted to a numpy.dtype.

Returns

A numpy.dtype corresponding to popxl.dtype.

Return type

np.dtype

as_torch()

Convert the popxl.dtype to a corresponding torch.dtype.

Raises
Returns

A torch.dtype corresponding to popxl.dtype.

Return type

torch.dtype

classmethod from_name(name)

Convert a dtype name into a dtype.

Parameters

name (str) – Dtype name

Raises

ValueError – If name does not exist

Returns

dtype

Return type

dtype

property is_complex: bool

Return True if a complex number dtype. False otherwise.

property is_floating_point: bool

Return True if a float point number dtype. False otherwise.

property is_int: bool

Return True if an integer number dtype. False otherwise.

property is_signed: bool

Return True if a signed number dtype. False otherwise.

property name: str

Return the name of dtype.