ArrayBackend
- class odl.ArrayBackend(impl: str, array_namespace: ModuleType, available_dtypes: dict[str, object], array_type: type, array_constructor: Callable, from_dlpack: Callable, make_contiguous: Callable, identifier_of_dtype: Callable, available_devices: list[str], to_cpu: Callable, to_numpy: Callable, to_device: Callable)
Bases:
objectClass to implement the array backend associated to each TensorSpace Implementations.
Attributes
- implstr
The implementation of the backend, e.g ‘numpy’
- array_namespaceModuleType
The actual namespace of the backend, e.g np
- available_dtypesdict
A dictionnary mapping a Number/str datatype to the corresponding backend-specific datatype, e.g {float:np.float64, ‘float64’, np.float64, …}
- array_typetype
The type of the array once implemented by the backend, e.g np.ndarray
- array_constructorCallable
The function the backend uses to create an array, e.g np.asarray
- from_dlpackCallable
Stand-in for the
from_dlpackmethod of the Python Array API. We would rather use that directly, but there are multiple inconsistencies of its behaviour particular in different PyTorch versions, so we need to wrap it as a workaround.- make_contiguousCallable
The function the backend uses to make an array contiguous, e.g np.ascontiguousasarray
- identifier_of_dtypeCallable
The function used to get a string representation of a backend-specific dtype
- available_deviceslist[str]
List of devices accepted by the backend
- to_cpuCallable
Function to copy an array to the CPU
- to_numpy: Callable
Function to create a Numpy version of an array
- __init__(impl: str, array_namespace: ModuleType, available_dtypes: dict[str, object], array_type: type, array_constructor: Callable, from_dlpack: Callable, make_contiguous: Callable, identifier_of_dtype: Callable, available_devices: list[str], to_cpu: Callable, to_numpy: Callable, to_device: Callable) None