
    pj	                         S SK r S SKJrJrJrJrJrJrJrJ	r	  S r
\" 5       (       d$  \" 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XPUPlaceget_all_custom_device_typeis_compiled_with_cudais_compiled_with_custom_deviceis_compiled_with_rocmis_compiled_with_xpuc                  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      U/var/www/html/pdf-tiff/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   4   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#   8   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   F   Nc                    [         c   S5       eS U l        Uc  [        5       (       a  [        5       nOUc  [	        5       (       a5  [        [        R                  R                  SS5      5      n[        U5      nOO[        5       (       a5  [        [        R                  R                  SS5      5      n[        U5      nO[        S5      e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   FLAGS_selected_xpuszNot Supported devices)CoreCUDAGraph_graphr   r#   r   r   r   environgetr   r
   r   RuntimeError_place	ALL_MODESindex_mode_pool_id)selfplacemodepool_idr"   s        r   __init__CUDAGraph.__init__G   s    ( 	
T	
( =>@@*,E]$&&

/Da HI	!),%''

/Da HI	 +"#:;;y   __T*
r   c                 p    [         R                  " U R                  U R                  U R                  5        g N)r,   begin_capture_with_pool_idr1   r4   r5   r6   s    r   capture_beginCUDAGraph.capture_begin^   s#    00KKT]]	
r   c                 8    [         R                  " 5       U l        g r=   )r,   end_capturer-   r?   s    r   capture_endCUDAGraph.capture_endc   s    #//1r   c                 8    U R                   R                  5         g r=   )r-   replayr?   s    r   rG   CUDAGraph.replayf   s    r   c                 8    U R                   R                  5         g r=   )r-   resetr?   s    r   rJ   CUDAGraph.reseti   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bytesrM   r   makedirspathisdirr-   print_to_dot_files)r6   dirnameflagss      r   rU   CUDAGraph.print_to_dot_filesl   su    'C<00llG
40ww}}W%% 	
7)#9:	
% =E&&w6r   )r-   r4   r1   r5   )Nr%   Nr=   )__name__
__module____qualname____firstlineno__r:   r@   rD   rG   rJ   rU   __static_attributes__r   r   r   r   r   F   s      .

2	7r   r   )r   paddle.base.corer   r   r   r   r   r   r	   r
   r   r   r,   r   r#   r2   cuda_graph_idr   r   r   <module>r`      ss    
	 	 	 (**; M 2	/7 /7r   