pygwtf.backend#
Attributes#
Classes#
Backend base class. Defines the interface for the array module to be used for computations (e.g. numpy or cupy) |
|
Backend base class. Defines the interface for the array module to be used for computations (e.g. numpy or cupy) |
|
Backend base class. Defines the interface for the array module to be used for computations (e.g. numpy or cupy) |
Functions#
|
Factory function to get the appropriate backend instance based on the provided backend name. |
Module Contents#
- pygwtf.backend.gpu_available = True#
- class pygwtf.backend.Backend#
Bases:
abc.ABCBackend base class. Defines the interface for the array module to be used for computations (e.g. numpy or cupy) and any other backend-specific functionality (such as kernel selection).
- property xp: Any#
- Abstractmethod:
Returns the array module to be used for computations. This will be numpy for CPU computations and cupy for GPU computations.
- property uses_gpu: bool#
Returns True if the backend uses GPU computations, False otherwise.
- asnumpy(array: Any) numpy.ndarray#
Converts the given array to a NumPy array. For CPU backend, this can be a no-op. For GPU backend, this will transfer the array from GPU to CPU.
- class pygwtf.backend.CPUBackend#
Bases:
BackendBackend base class. Defines the interface for the array module to be used for computations (e.g. numpy or cupy) and any other backend-specific functionality (such as kernel selection).
- property xp#
Returns the array module to be used for computations. This will be numpy for CPU computations and cupy for GPU computations.
- class pygwtf.backend.GPUBackend#
Bases:
BackendBackend base class. Defines the interface for the array module to be used for computations (e.g. numpy or cupy) and any other backend-specific functionality (such as kernel selection).
- property xp#
Returns the array module to be used for computations. This will be numpy for CPU computations and cupy for GPU computations.
- property uses_gpu: bool#
Returns True if the backend uses GPU computations, False otherwise.
- asnumpy(array: Any) numpy.ndarray#
Converts the given array to a NumPy array. For CPU backend, this can be a no-op. For GPU backend, this will transfer the array from GPU to CPU.