
    a,j&                     v    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dS )    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                 j    t           st          d          t                              || ||          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       Y/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/torch/cuda/green_contexts.pyr   zGreenContext.create   sE    8  	TRSSS##+(C	 $ 
 
 	
    c                 d    t           st          d          t                              |           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>   s3      	TRSSS666KKKr   c                 D    t                                                      S )z+Make the green context the current context.)superset_contextself	__class__s    r   r   zGreenContext.set_contextP   s    ww""$$$r   c                 D    t                                                      S )zAssuming 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     ww""$$$r   torch.cuda.Streamc                 D    t                                                      S )z1Return the CUDA Stream used by the green context.)r   Streamr   s    r   r!   zGreenContext.StreamZ   s    ww~~r   )N)r   N)r   r   )__name__
__module____qualname____doc__staticmethodintstrr   r   r   r   r   r!   __classcell__)r   s   @r   r   r      s:          #&*26 $"
 "
 "
t"
 t"
 &)4Z	"

 :"
 
"
 "
 "
 \"
H L LS4Z L3 L L L \L"% % % % % %% % % % % %                   r   )	torch__all__objectr   r   hasattr_Cr   r    r   r   <module>r0      s      	
758()) H.MI
J  J  J  J  J = J  J  J  J  J r   