pygwtf.backend
==============

.. py:module:: pygwtf.backend


Attributes
----------

.. autoapisummary::

   pygwtf.backend.gpu_available


Classes
-------

.. autoapisummary::

   pygwtf.backend.Backend
   pygwtf.backend.CPUBackend
   pygwtf.backend.GPUBackend


Functions
---------

.. autoapisummary::

   pygwtf.backend.get_backend


Module Contents
---------------

.. py:data:: gpu_available
   :value: True


.. py:class:: Backend

   Bases: :py:obj:`abc.ABC`


   Backend 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).


   .. py:property:: xp
      :type: Any

      :abstractmethod:


      Returns the array module to be used for computations. This will be `numpy` for CPU computations and `cupy` for GPU computations.



   .. py:property:: uses_gpu
      :type: bool


      Returns True if the backend uses GPU computations, False otherwise.



   .. py:method:: 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.



.. py:class:: CPUBackend

   Bases: :py:obj:`Backend`


   Backend 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).


   .. py:property:: xp

      Returns the array module to be used for computations. This will be `numpy` for CPU computations and `cupy` for GPU computations.



.. py:class:: GPUBackend

   Bases: :py:obj:`Backend`


   Backend 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).


   .. py:property:: xp

      Returns the array module to be used for computations. This will be `numpy` for CPU computations and `cupy` for GPU computations.



   .. py:property:: uses_gpu
      :type: bool


      Returns True if the backend uses GPU computations, False otherwise.



   .. py:method:: 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.



.. py:function:: get_backend(backend_name: str) -> Backend

   Factory function to get the appropriate backend instance based on the provided backend name.


