
    3j&                         S SK r S/r\rSr\" \ R                  S5      (       a  \ R                  R                  rSr " S S\5      rg)    NGreenContextF_CUDAGreenContextTc                      ^  \ rS rSrSr\SSSSS.S\S-  S\S-  S\S-  S\S-  S	\4
S
 jj5       r	\SS\S-  S	\4S jj5       r
SU 4S jjrSU 4S jjrSU 4S jjrSrU =r$ )r      zmWrapper 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                 Z    [         (       d  [        S5      e[        R                  UU UUS9$ )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       S/home/wildlama/miniconda3/lib/python3.13/site-packages/torch/cuda/green_contexts.pyr   GreenContext.create   s9    8 yRSS##+(C	 $ 
 	
    c                 T    [         (       d  [        S5      e[        R                  U S9$ )a?  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   &GreenContext.max_workqueue_concurrency>   s)     yRSS666KKr   c                     > [         TU ]  5       $ )z+Make the green context the current context.)superset_contextself	__class__s    r   r   GreenContext.set_contextP   s    w"$$r   c                     > [         TU ]  5       $ )zsAssuming the green context is the current context, pop it from the
context stack and restore the previous context.
)r   pop_contextr   s    r   r"   GreenContext.pop_contextT   s     w"$$r   c                     > [         TU ]  5       $ )z1Return the CUDA Stream used by the green context.)r   Streamr   s    r   r%   GreenContext.StreamZ   s    w~r    )N)r   N)r   ztorch.cuda.Stream)__name__
__module____qualname____firstlineno____doc__staticmethodintstrr   r   r   r   r"   r%   __static_attributes____classcell__)r   s   @r   r   r      s      #&*26 $"
t"
 t"
 &)4Z	"

 :"
 
"
 "
H LS4Z L3 L L"%%   r   )	torch__all__objectr   r   hasattr_Cr   r   r'   r   r   <module>r7      sT      	
588())HH..MI
J = J r   