Ë
    M²j&  ã                   ó†   — d dl Z dgZeZdZ ee j                  d«      re j                  j                  ZdZ G d„ de«      Zy)é    NÚGreenContextFÚ_CUDAGreenContextTc                   ó¨   ‡ — e Zd ZdZedddddœdedz  dedz  dedz  dedz  def
d	„«       Zeddedz  defd
„«       Z	dˆ fd„Z
dˆ fd„Zdˆ fd„Zˆ xZS )r   zyWrapper around a CUDA green context.

    .. warning::
       This API is in beta and may change in future releases.
    N©Únum_smsÚworkqueue_scopeÚworkqueue_concurrency_limitÚ	device_idr   r   r	   r
   Úreturnc                 óV   — t         st        d«      ‚t        j                  || ||¬«      S )a+  Create a CUDA green context.

        At least one of ``num_sms`` or ``workqueue_scope`` must be specified.
        Both can be combined to partition SMs and configure workqueues in the
        same green context.

        Arguments:
            num_sms (int, optional): The number of SMs to use in the green
                context. When ``None``, SMs are not partitioned.
            workqueue_scope (str, optional): Workqueue sharing scope. One of
                ``"device_ctx"`` (shared across all contexts, default driver
                behaviour) or ``"balanced"`` (non-overlapping workqueues with
                other balanced green contexts). When ``None``, no workqueue
                configuration is applied.
            workqueue_concurrency_limit (int, optional): Maximum number of
                concurrent stream-ordered workloads for the workqueue. Requires
                ``workqueue_scope`` to be set.
            device_id (int, optional): The device index of green context.
                When ``None``, the current device is used.
        ú1PyTorch was not built with Green Context support!)r
   r   r   r	   )Ú	SUPPORTEDÚRuntimeErrorÚ_GreenContextÚcreater   s       úX/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/torch/cuda/green_contexts.pyr   zGreenContext.create   s7   € õ8 ÜÐRÓSÐSÜ×#Ñ#ØØØ+Ø(Cð	 $ó 
ð 	
ó    c                 óP   — t         st        d«      ‚t        j                  | ¬«      S )aw  Return the maximum workqueue concurrency limit for the device.

        This queries the device for the default number of concurrent
        stream-ordered workloads supported by workqueue configuration
        resources.

        Arguments:
            device_id (int, optional): The device index to query. When
                ``None``, the current device is used.
        r   ©r
   )r   r   r   Úmax_workqueue_concurrencyr   s    r   r   z&GreenContext.max_workqueue_concurrency>   s'   € õ ÜÐRÓSÐSÜ×6Ñ6ÀÐ6ÓKÐKr   c                 ó    •— t         ‰| �  «       S )z+Make the green context the current context.)ÚsuperÚset_context©ÚselfÚ	__class__s    €r   r   zGreenContext.set_contextP   s   ø€ ä‰wÑ"Ó$Ð$r   c                 ó    •— t         ‰| �  «       S )zƒAssuming the green context is the current context, pop it from the
        context stack and restore the previous context.
        )r   Úpop_contextr   s    €r   r   zGreenContext.pop_contextT   s   ø€ ô ‰wÑ"Ó$Ð$r   c                 ó    •— t         ‰| �  «       S )z1Return the CUDA Stream used by the green context.)r   ÚStreamr   s    €r   r    zGreenContext.StreamZ   s   ø€ ä‰w‰~ÓÐr   )N)r   N)r   ztorch.cuda.Stream)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstaticmethodÚintÚstrr   r   r   r   r   r    Ú__classcell__)r   s   @r   r   r      s©   ø„ ñð ð #Ø&*Ø26Ø $ò"
à�t‘ð"
ð ˜t™ð"
ð &)¨4¡Zð	"
ð
 ˜‘:ð"
ð 
ò"
ó ð"
ðH ñL¨S°4©Zð LÀ3ò Ló ðLõ"%õ%÷ ñ  r   )	ÚtorchÚ__all__Úobjectr   r   ÚhasattrÚ_Cr   r   © r   r   ú<module>r/      sQ   ðÛ ð ð€ð €Ø€	á
ˆ5�8‰8Ð(Ô)Ø—H‘H×.Ñ.€MØ€Iô
J �=õ J r   