
    Αi                         S SK r S SKJrJrJrJrJrJr  S r\" 5       (       d  \" 5       (       d  \" 5       (       a
  S SKJ	r
  S rOSr
S rS r/ SQrS r " S	 S
5      r	g)    N)	CUDAPlaceCustomPlaceget_all_custom_device_typeis_compiled_with_cudais_compiled_with_custom_deviceis_compiled_with_rocmc                  Z    Sn [        5       nU H  n[        U5      (       d  M  Sn   U $    U $ )NFT)r   r   )custom_device_flagcustom_devices_typesdevice_types      Y/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/device/cuda/graphs.py!check_compiled_with_custom_devicer      s=    57+)+66!%	 ,     )	CUDAGraphc                      g)NT r   r   r   is_cuda_graph_supportedr   ,   s    r   c                      g)NFr   r   r   r   r   r   2   s    r   c                      [        5        HF  n [        R                  " SU  S3S5      R                  S5      n[	        US   5      n[        X5      s  $    g )NFLAGS_selected_s0,r   )r   osgetenvsplitintr   )deviceselected_devices	device_ids      r   current_expected_placer!   6   sY    ,.99vha%@#FLL
 (+,	6-- / r   )globalthread_localrelaxedc                   @    \ rS rSrS
S jrS rS rS rS rSS jr	S	r
g)r   D   Nc                 :   [         c   S5       eS U l        Uc  [        5       (       a  [        5       nO7Uc4  [	        [
        R                  R                  SS5      5      n[        U5      nXl	        U[        ;   d   e[        R                  U5      U l        X0l        g )NzFCUDA Graph is only supported on PaddlePaddle compiled with NVIDIA GPU.FLAGS_selected_gpusr   )CoreCUDAGraph_graphr   r!   r   r   environgetr   _place	ALL_MODESindex_mode_pool_id)selfplacemodepool_idr    s        r   __init__CUDAGraph.__init__E   s    ( 	
T	
( =>@@*,E]BJJNN+@!DEIi(Ey   __T*
r   c                 p    [         R                  " U R                  U R                  U R                  5        g N)r)   begin_capture_with_pool_idr-   r0   r1   r2   s    r   capture_beginCUDAGraph.capture_beginV   s#    00KKT]]	
r   c                 8    [         R                  " 5       U l        g r9   )r)   end_capturer*   r;   s    r   capture_endCUDAGraph.capture_end[   s    #//1r   c                 8    U R                   R                  5         g r9   )r*   replayr;   s    r   rC   CUDAGraph.replay^   s    r   c                 8    U R                   R                  5         g r9   )r*   resetr;   s    r   rF   CUDAGraph.reseta   s    r   c                    [        U[        [        45      (       d  UR                  n[        R
                  " USS9  [        R                  R                  U5      (       d   SU S35       eUc  SnU R                  R                  X5        g )NT)nameexist_okzThe dirname z should be a directoryi  )

isinstancestrbytesrI   r   makedirspathisdirr*   print_to_dot_files)r2   dirnameflagss      r   rQ   CUDAGraph.print_to_dot_filesd   su    'C<00llG
40ww}}W%% 	
7)#9:	
% =E&&w6r   )r*   r0   r-   r1   )Nr#   Nr9   )__name__
__module____qualname____firstlineno__r6   r<   r@   rC   rF   rQ   __static_attributes__r   r   r   r   r   D   s      "

2	7r   r   )r   paddle.base.corer   r   r   r   r   r   r   r   r)   r   r!   r.   cuda_graph_idr   r   r   <module>r\      se    
  (**; M 2	)7 )7r   