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:
boolint8int16int32int64uint8uint16uint32uint64float8_143float8_152float16float32float64complex64complex128
Some data types have aliases:
halfaliasesfloat16floataliasesfloat32doublealiasesfloat64
- 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_valueto apopxl.dtype.- Parameters
type_value (Any) – A
numpy.dtype,torch.dtype, string, a built-in Python type or anumpy.ndarray,torch.tensorwhich can be converted to apopxl.dtype.- Raises
ValueError – If
type_valuecannot be converted to apopxl.dtype.- Returns
A
popxl.dtypecorresponding totype_value.- Return type
- as_numpy()
Convert the
popxl.dtypeto a correspondingnumpy.dtype.- Raises
TypeError – If the
popxl.dtypecannot be converted to anumpy.dtype.- Returns
A
numpy.dtypecorresponding topopxl.dtype.- Return type
np.dtype
- as_torch()
Convert the
popxl.dtypeto a correspondingtorch.dtype.- Raises
TypeError – If the
popxl.dtypecannot be converted to atorch.dtype.ModuleNotFoundError – If PyTorch is not installed.
- Returns
A
torch.dtypecorresponding topopxl.dtype.- Return type
- 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