18.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
aliasesfloat16
float
aliasesfloat32
double
aliasesfloat64
- 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 apopxl.dtype
.- Parameters
type_value (Any) – A
numpy.dtype
,torch.dtype
, string, a built-in Python type or anumpy.ndarray
,torch.tensor
which can be converted to apopxl.dtype
.- Raises
ValueError – If
type_value
cannot be converted to apopxl.dtype
.- Returns
A
popxl.dtype
corresponding totype_value
.- Return type
- as_numpy()
Convert the
popxl.dtype
to a correspondingnumpy.dtype
.- Raises
TypeError – If the
popxl.dtype
cannot be converted to anumpy.dtype
.- Returns
A
numpy.dtype
corresponding topopxl.dtype
.- Return type
np.dtype
- as_torch()
Convert the
popxl.dtype
to a correspondingtorch.dtype
.- Raises
TypeError – If the
popxl.dtype
cannot be converted to atorch.dtype
.ModuleNotFoundError – If PyTorch is not installed.
- Returns
A
torch.dtype
corresponding 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