Ë
    g^(h"  ã                   ó<  — d Z ddlmZ ddlmZ ddlZddlmZmZ g d¢Z	de
fd	„Zdefd
„Zddedeej                     fd„Zde
fd„Z  ede¬«      e«      Zdeddfd„Z  ede¬«      e«      Zddedej*                  fd„Zdej*                  ddfd„Zddeddfd„Zy)z]
This package introduces support for the current :ref:`accelerator<accelerators>` in python.
é    )ÚOptional)Ú
deprecatedNé   )Ú	_device_tÚ_get_device_index)
Úcurrent_acceleratorÚcurrent_device_idxÚcurrent_device_indexÚcurrent_streamÚdevice_countÚis_availableÚset_device_idxÚset_device_indexÚ
set_streamÚsynchronizeÚreturnc                  ó>   — t         j                  j                  «       S )zëReturn the number of current :ref:`accelerator<accelerators>` available.

    Returns:
        int: the number of the current :ref:`accelerator<accelerators>` available.
            If there is no available accelerators, return 0.
    )ÚtorchÚ_CÚ_accelerator_deviceCount© ó    úX/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/accelerator/__init__.pyr   r      s   € ô �8‰8×,Ñ,Ó.Ð.r   c                  óf   — t        «       } | €yt        j                  | «      }|j                  «       S )a§  Check if the current accelerator is available at runtime: it was build, all the
    required drivers are available and at least one device is visible.
    See :ref:`accelerator<accelerators>` for details.

    Returns:
        bool: A boolean indicating if there is an available :ref:`accelerator<accelerators>`.

    Example::

        >>> assert torch.accelerator.is_available() "No available accelerators detected."
    F)r   r   Úget_device_moduler   )ÚaccÚmods     r   r   r   %   s3   € ô  Ó
€CØ
€{Øä
×
!Ñ
! #Ó
&€CØ×ÑÓÐr   Úcheck_availablec                 ód   — t         j                  j                  «       x}�| r| rt        «       r|S y)aä  Return the device of the accelerator available at compilation time.
    If no accelerator were available at compilation time, returns None.
    See :ref:`accelerator<accelerators>` for details.

    Args:
        check_available (bool, optional): if True, will also do a runtime check to see
            if the device :func:`torch.accelerator.is_available` on top of the compile-time
            check.
            Default: ``False``

    Returns:
        torch.device: return the current accelerator as :class:`torch.device`.

    .. note:: The index of the returned :class:`torch.device` will be ``None``, please use
        :func:`torch.accelerator.current_device_index` to know the current index being used.

    Example::

        >>> # xdoctest:
        >>> # If an accelerator is available, sent the model to it
        >>> model = torch.nn.Linear(2, 2)
        >>> if (current_device := current_accelerator(check_available=True)) is not None:
        >>>     model.to(current_device)
    N)r   r   Ú_accelerator_getAcceleratorr   )r   r   s     r   r   r   =   s-   € ô2 �x‰x×3Ñ3Ó5Ð5ˆÐBÙ¡_¼¼ØˆJØr   c                  ó>   — t         j                  j                  «       S )z«Return the index of a currently selected device for the current :ref:`accelerator<accelerators>`.

    Returns:
        int: the index of a currently selected device.
    )r   r   Ú_accelerator_getDeviceIndexr   r   r   r
   r
   \   s   € ô �8‰8×/Ñ/Ó1Ð1r   z#Use `current_device_index` instead.)ÚcategoryÚdevicec                óX   — t        | «      }t        j                  j                  |«       y)a   Set the current device index to a given device.

    Args:
        device (:class:`torch.device`, str, int): a given device that must match the current
            :ref:`accelerator<accelerators>` device type.

    .. note:: This function is a no-op if this device index is negative.
    N)r   r   r   Ú_accelerator_setDeviceIndex©r$   Údevice_indexs     r   r   r   k   s    € ô % VÓ,€LÜ	‡H�H×(Ñ(¨Õ6r   zUse `set_device_index` instead.c                óX   — t        | d«      }t        j                  j                  |«      S )a˜  Return the currently selected stream for a given device.

    Args:
        device (:class:`torch.device`, str, int, optional): a given device that must match the current
            :ref:`accelerator<accelerators>` device type. If not given,
            use :func:`torch.accelerator.current_device_index` by default.

    Returns:
        torch.Stream: the currently selected stream for a given device.
    T)r   r   r   Ú_accelerator_getStreamr'   s     r   r   r   ~   s%   € ô % V¨TÓ2€LÜ�8‰8×*Ñ*¨<Ó8Ð8r   Ústreamc                 óB   — t         j                  j                  | «       y)a  Set the current stream to a given stream.

    Args:
        stream (torch.Stream): a given stream that must match the current :ref:`accelerator<accelerators>` device type.

    .. note:: This function will set the current device index to the device index of the given stream.
    N)r   r   Ú_accelerator_setStream)r+   s    r   r   r   �   s   € ô 
‡H�H×#Ñ# FÕ+r   c                óZ   — t        | d«      }t        j                  j                  |«       y)a  Wait for all kernels in all streams on the given device to complete.

    Args:
        device (:class:`torch.device`, str, int, optional): device for which to synchronize. It must match
            the current :ref:`accelerator<accelerators>` device type. If not given,
            use :func:`torch.accelerator.current_device_index` by default.

    .. note:: This function is a no-op if the current :ref:`accelerator<accelerators>` is not initialized.

    Example::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CUDA)
        >>> assert torch.accelerator.is_available() "No available accelerators detected."
        >>> start_event = torch.Event(enable_timing=True)
        >>> end_event = torch.Event(enable_timing=True)
        >>> start_event.record()
        >>> tensor = torch.randn(100, device=torch.accelerator.current_accelerator())
        >>> sum = torch.sum(tensor)
        >>> end_event.record()
        >>> torch.accelerator.synchronize()
        >>> elapsed_time_ms = start_event.elapsed_time(end_event)
    TN)r   r   r   Ú_accelerator_synchronizeDevicer'   s     r   r   r   ˜   s"   € ô. % V¨TÓ2€LÜ	‡H�H×+Ñ+¨LÕ9r   )F)N)Ú__doc__Útypingr   Útyping_extensionsr   r   Ú_utilsr   r   Ú__all__Úintr   Úboolr   r$   r   r
   ÚFutureWarningr	   r   r   ÚStreamr   r   r   r   r   r   ú<module>r9      sð   ðñõ Ý (ã ç 0ò€ð/�có /ð�dó ñ0¨ð ¸(À5Ç<Á<Ñ:Pó ð>2˜có 2ð‘ZØ)Øôð óÐ ð
7˜Yð 
7¨dó 
7ð‘Ø%Øôð ó€ñ9˜9ð 9°5·<±<ó 9ð,�u—|‘|ð ,¨ó ,ñ:˜	ð :°ô :r   