
    9j`
                        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y)    )annotations)SelfNc                 >    t         j                  j                         S )zL
    Return an opaque token representing the id of a graph memory pool.
    )torch_C_mtia_graphPoolHandle     U/media/conek/DATA/Code/OCR/venv/lib/python3.12/site-packages/torch/mtia/mtia_graph.pygraph_pool_handler      s    
 88))++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.
    c                $    t         |   | |      S N)super__new__)cls
keep_graph	__class__s     r   r   zMTIAGraph.__new__   s    wsJ//r
   c                $    t         |   |       y)z/
        Begin capturing a MTIA graph.
        N)r   capture_begin)selfpoolr   s     r   r   zMTIAGraph.capture_begin   s     	d#r
   c                "    t         |           y)z2
        End the capture of a MTIA graph.
        N)r   capture_endr   r   s    r   r   zMTIAGraph.capture_end"        	r
   c                "    t         |           y)z6
        Instantiate the captured MTIA graph.
        N)r   instantiater   s    r   r   zMTIAGraph.instantiate(   r   r
   c                "    t         |           y)z1
        Replay the captured MTIA graph.
        N)r   replayr   s    r   r!   zMTIAGraph.replay.   s     	r
   c                "    t         |           y)zB
        Destroy the captured graph and reset the states.
        N)r   resetr   s    r   r#   zMTIAGraph.reset4   s     	r
   c                     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     w|~r
   )F)r   boolreturnr   )r   _POOL_HANDLEr&   Noner&   r(   r&   r'   )__name__
__module____qualname____doc__r   r   r   r   r!   r#   r   __classcell__)r   s   @r   r   r      s0    0$ r
   r   c                  D    e Zd ZU dZded<   	 	 d	 	 	 	 	 ddZd	dZd
dZy)graphNtorch.mtia.Stream | Nonedefault_capture_streamc                x   | j                   j                  -t        j                  j	                         | j                   _        |dn|f| _        ||n| j                   j                  | _        | j                  t        d      t        j                  j                  | j                        | _	        || _
        y )Nr	   zcapture_stream must not be None)r   r3   r   mtiacurrent_streamr   capture_streamAssertionErrorstream
stream_ctx
mtia_graph)r   r;   r   r9   s       r   __init__zgraph.__init__D   s     >>00849JJ4M4M4ODNN1;?<RdW	(Fdnn.S.S 	 & !BCC**++D,?,?@$r
   c                    t         j                  j                          t         j                  j                          | j                  j                          | j                  r| j                  d   nd}| j                  j                  |       y )Nr   )r   r   )	r   r5   synchronizeempty_cacher:   	__enter__r   r;   r   )r   pool_args     r   r@   zgraph.__enter__V   sY    

 

 !!##'99499Q<&%%h/r
   c                j    | j                   j                           | j                  j                  |  y r   )r;   r   r:   __exit__)r   argss     r   rC   zgraph.__exit___   s&    ##%   $'r
   )NN)r;   r   r   z_POOL_HANDLE | Noner9   r2   r)   )rD   objectr&   r(   )r+   r,   r-   r3   __annotations__r<   r@   rC   r	   r
   r   r1   r1   A   sA    7;4;
 %)+/	%% "% )	%$0(r
   r1   )r   r1   r   r*   )
__future__r   typing_extensionsr   r   tupleintr'   r   r   
_MTIAGraphr   r1   __all__r	   r
   r   <module>rM      sK    " "  S#X,*## *Z (  (Fr
   