
    9i                        % S SK Jr  S SKJrJr  S SKJrJrJr  S SK	J
r
  \
" SSS9rS\S	'    " S
 S5      r " S S5      rg)    )annotations)CallableOptional)Executoras_completedFuture)
ContextVarasync_compile_active_modeN)defaultz&ContextVar[Optional[AsyncCompileMode]]active_modec                  $    \ rS rSrSS jrS rSrg)FutureKernel	   c                *    Xl         S U l        X l        g N)finalize_compilekernelfuture)selfr   r   s      ]/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/triton/runtime/_async_compile.py__init__FutureKernel.__init__   s     0    c                    U R                   b  U R                   $ U R                  R                  5       nU R                  U5        Xl         U$ r   )r   r   resultr   )r   r   s     r   r   FutureKernel.result   s@    ;;";;##%f%r   )r   r   r   N)r   r   r   r   )__name__
__module____qualname____firstlineno__r   r   __static_attributes__ r   r   r   r   	   s    
r   r   c                  0    \ rS rSrSS jrS rS rS rSrg)	AsyncCompileMode   c                ,    Xl         / U l        0 U l        g r   )executorraw_futuresfuture_kernels)r   r'   s     r   r   AsyncCompileMode.__init__   s      r   c                    U R                   R                  U5      nUb  U$ U R                  R                  U5      nXl        U R
                  R                  U5        [        X45      nXPR                   U'   U$ r   )r)   getr'   submit_keyr(   appendr   )r   key
compile_fnfinalize_fnr   future_kernels         r   r-   AsyncCompileMode.submit!   sn    $$((-M%%j1'$[9#0C r   c                p    [         R                  5       b  [        S5      e[         R                  U 5        U $ )Nz*Another AsyncCompileMode is already active)r   r,   RuntimeErrorset)r   s    r   	__enter__AsyncCompileMode.__enter__-   s,    ??(KLLr   c                    [        U R                  5       H*  nU R                  UR                     R	                  5         M,     [
        R                  S 5        g r   )r   r(   r)   r.   r   r   r7   )r   exc_type	exc_value	tracebackr   s        r   __exit__AsyncCompileMode.__exit__3   s>    "4#3#34F,335 5r   )r'   r)   r(   N)r'   r   )	r   r   r   r    r   r-   r8   r>   r!   r"   r   r   r$   r$      s    !

r   r$   )
__future__r   typingr   r   concurrent.futuresr   r   r   contextvarsr	   r   __annotations__r   r$   r"   r   r   <module>rE      s<    " % = = "6@A\fj6k3 k " r   