Parallel Module Base Class
- class gpubackendtools.parallelbase.ParallelModuleBase(force_backend=None)
Bases:
objectBase class for modules that can use a GPU (or revert back to CPU).
This class mainly handles backend selection. Each backend offers accelerated computations on a specific device (cpu, CUDA 11.x enabled GPU, CUDA 12.x enabled GPU).
- Parameters:
force_backend (str, optional) – Name of the backend to use
- property backend: Backend
Access the underlying backend.
- classmethod supported_backends() Sequence[str]
List of backends supported by a parallel module by order of preference.
- static CPU_ONLY() list[str]
List of supported backend for CPU only class
- static GPU_RECOMMENDED() list[str]
List of supported backends for GPU-recommended class with CPU support
- static CPU_RECOMMENDED_WITH_GPU_SUPPORT() list[str]
List of supported backends for CPU-recommended class with GPU support
- static GPU_ONLY() list[str]
List of supported backends for GPU-only class
- property xp: ModuleType
Return the module providing ndarray capabilities
- property backend_name: str
Return the name of current backend
- build_with_same_backend(module_class: type[ParallelModuleDerivate], args: list | None = None, kwargs: dict | None = None) ParallelModuleDerivate
Build an instance of module_class with same backend as current object.
- Parameters:
module_class – class of the object to be built, must derive from ParallelModuleBase
args (list, optional) – positional arguments for module_class constructor
kwargs (dict, optional) – keyword arguments for module_class constructor (the ‘force_backend’ argument will be ignored and replaced)
- adapt_backend_kwargs(kwargs: dict | None = None) dict
Adapt a set of keyword arguments to add/set ‘force_backend’ to current backend