
    i                         d dl Z eZdZ ee j
                  d      re j
                  j                  ZdZ G d de      Zy)    NF_CUDAGreenContextTc                   P     e Zd ZdZeddededefd       Zd	 fdZd	 fdZ	 xZ
S )
GreenContextzyWrapper around a CUDA green context.

    .. warning::
       This API is in beta and may change in future releases.
    num_sms	device_idreturnc                 P    t         st        d      t        j                  | |      S )zCreate a CUDA green context.

        Arguments:
            num_sms (int): The number of SMs to use in the green context.
            device_id (int, optional): The device index of green context.
        z1PyTorch was not built with Green Context support!)	SUPPORTEDRuntimeError_GreenContextcreate)r   r   s     S/var/www/html/engine/venv/lib/python3.12/site-packages/torch/cuda/green_contexts.pyr   zGreenContext.create   s&     RSS##GY77    c                      t         |          S )z+Make the green context the current context.)superset_contextself	__class__s    r   r   zGreenContext.set_context#   s    w"$$r   c                      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_context'   s     w"$$r   )r   )r   N)__name__
__module____qualname____doc__staticmethodintr   r   r   r   __classcell__)r   s   @r   r   r      s@     	8 	8 	8M 	8 	8%% %r   r   )torchobjectr   r
   hasattr_Cr   r    r   r   <module>r$      sC     	
588()HH..MI
%= %r   