
    /j`
                        d dl mZ d dlmZ d dlZeeef         ZddZ G d dej	        j
                  Z G d	 d
          Zg dZdS )    )annotations)SelfNreturn_POOL_HANDLEc                 >    t           j                                        S )zL
    Return an opaque token representing the id of a graph memory pool.
    )torch_C_mtia_graphPoolHandle     Z/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/torch/mtia/mtia_graph.pygraph_pool_handler      s    
 8))+++r   c                  n     e Zd ZdZdd fdZd fdZd fdZd fdZd fdZd fdZ	d fdZ
 xZS )	MTIAGraphz&
    Wrapper around a MTIA graph.
    F
keep_graphboolr   r   c                H    t                                          | |          S N)super__new__)clsr   	__class__s     r   r   zMTIAGraph.__new__   s    wwsJ///r   poolr   Nonec                J    t                                          |           dS )z/
        Begin capturing a MTIA graph.
        N)r   capture_begin)selfr   r   s     r   r   zMTIAGraph.capture_begin   s#     	d#####r   c                H    t                                                       dS )z2
        End the capture of a MTIA graph.
        N)r   capture_endr   r   s    r   r   zMTIAGraph.capture_end"   !     	r   c                H    t                                                       dS )z6
        Instantiate the captured MTIA graph.
        N)r   instantiater    s    r   r#   zMTIAGraph.instantiate(   r!   r   c                H    t                                                       dS )z1
        Replay the captured MTIA graph.
        N)r   replayr    s    r   r%   zMTIAGraph.replay.   s     	r   c                H    t                                                       dS )zB
        Destroy the captured graph and reset the states.
        N)r   resetr    s    r   r'   zMTIAGraph.reset4   s     	r   c                D    t                                                      S )zX
        Return an opaque token representing the id of this graph's memory pool
        )r   r   r    s    r   r   zMTIAGraph.pool:   s     ww||~~r   )F)r   r   r   r   )r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r   r   r   r#   r%   r'   r   __classcell__)r   s   @r   r   r      s         0 0 0 0 0 0 0$ $ $ $ $ $                             r   r   c                  <    e Zd ZU dZded<   	 	 ddd	ZddZddZdS )graphNtorch.mtia.Stream | Nonedefault_capture_stream
mtia_graphr   r   _POOL_HANDLE | Nonestreamc                <   | j         j        (t          j                                        | j         _        |dn|f| _        ||n| j         j        | _        | j        t          d          t          j                            | j                  | _	        || _
        d S )Nr   zcapture_stream must not be None)r   r3   r   mtiacurrent_streamr   capture_streamAssertionErrorr6   
stream_ctxr4   )r   r4   r   r6   s       r   __init__zgraph.__init__D   s     >0849J4M4M4O4ODN1;?<RRdW	(FFdn.S 	 & !BCCC*++D,?@@$r   r   r   c                   t           j                                         t           j                                         | j                                         | j        r| j        d         nd}| j                            |           d S )Nr   )r   r   )	r   r8   synchronizeempty_cacher<   	__enter__r   r4   r   )r   pool_args     r   rA   zgraph.__enter__V   sp    
   
   !!####'9849Q<<&%%h/////r   argsobjectc                V    | j                                           | j        j        |  d S r   )r4   r   r<   __exit__)r   rC   s     r   rF   zgraph.__exit___   s.    ##%%%  $''''r   )NN)r4   r   r   r5   r6   r2   r)   )rC   rD   r   r   )r+   r,   r-   r3   __annotations__r=   rA   rF   r   r   r   r1   r1   A   sq         7;;;;;
 %)+/	% % % % %$0 0 0 0( ( ( ( ( (r   r1   )r   r1   r   r*   )
__future__r   typing_extensionsr   r   tupleintr   r   r	   
_MTIAGraphr   r1   __all__r   r   r   <module>rN      s    " " " " " " " " " " " "  S#X, , , ,* * * * *# * * *Z (  (  (  (  (  (  (  (F  r   