o
    * iG                  
   @   s  d dl Z d dlZd dlZd dlZdZejdkrdZejeje	ej
 d e ZejerPejde d  zee W n eyO Z zedZ[ww dd	lmZmZmZmZmZmZmZmZmZmZmZmZmZm Z  dd
lm!Z!m"Z" ddlm#Z#m$Z$m%Z%m&Z& ddlm'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddlm4Z4 ddl5m6Z6 ddlm7Z7m8Z8 ddl9m:Z:m;Z; ddl<m=Z= ddlm>Z>m?Z?m@Z@ ddlmAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZX ddlmYZY ddlZm[Z[ ddl\m]Z]m^Z^ ddl_m`Z`maZa ddlmbZbmcZcmdZdmeZemfZfmgZg e+Zhe;Zie:Zjg Zkdd Zle[  el  e=  e mejn e mejojp e mejq e mejr e mejsjt dS )    NsontZpydzcore.zDeleting legacy file 
   )backwardcompilercoredata_feed_descdatasetdygraphexecutor	frameworkincubateinitializeriolayerstrainer_descunique_name)append_backward	gradients)BuildStrategyCompiledProgramIpuCompiledProgramIpuStrategy)CPUPlaceCUDAPinnedPlace	CUDAPlaceCustomPlaceDenseTensorDenseTensorArrayIPUPlaceScopeXPUPinnedPlaceXPUPlace_cuda_synchronize_Scope_set_warmup)DataFeedDesc)
DataFeeder)DatasetFactoryInMemoryDataset)disable_dygraphenable_dygraph)monkey_patch_tensor)Executorglobal_scopescope_guard)ProgramVariable
cpu_placescuda_pinned_placescuda_placesdefault_main_programdefault_startup_programdevice_guard	get_flagsin_dygraph_modein_dynamic_or_pir_modein_pir_modeipu_shard_guardis_compiled_with_cinnis_compiled_with_cudais_compiled_with_rocmis_compiled_with_xpu
name_scopeprocess_type_promotionprogram_guardrequire_version	set_flagsset_ipu_shard
xpu_places)set_global_initializer)monkey_patch_variable)create_lod_tensorcreate_random_int_lodtensor)	ParamAttrWeightNormParamAttr)DistMultiTrainerHeterPipelineTrainerHeterXpuTrainerMultiTrainerPipelineTrainerTrainerDescc                     s<  dt jv } z
ttdd}W n ty   d}Y nw |dkr1td| dt jd tdt jd t|tj	d< d	  fd
dt
  D fdd}t }d|v rY|d t
 rag 7 t
dd g z
t
t jd  W n ty   dgt _t
t jd  Y nw t
  t
  t
  t
  dS )zV
    Enable reading gflags from environment variables.

    Returns:
        None
    ZunittestZOMP_NUM_THREADS1r   z WARNING: OMP_NUM_THREADS set to z, not 1. The computation speed will not be optimized if you use data parallel. It will fail if this PaddlePaddle binary is compiled with OpenBlas since OpenBlas does not support multi-threads.)filez"PLEASE USE OMP_NUM_THREADS WISELY.ZFLAGS_c                    s&   g | ]}|  r|t d  qS N)
startswithlen).0key)flag_prefix `/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/paddle/base/__init__.py
<listcomp>   s    z!__bootstrap__.<locals>.<listcomp>c                    s   |  v r  |  d S d S rW   )remove)name)read_env_flagsr]   r^   remove_flag_if_exists   s   z,__bootstrap__.<locals>.remove_flag_if_existsDarwinZuse_pinned_memoryz--tryfromenv=,r    N)sysmodulesintosgetenv
ValueErrorprintstderrstrenvironr   globalskeysplatformsystemZis_compiled_with_ipuZinit_gflagsjoinZ	init_glogargv	ExceptionZinit_memory_methodZinit_devicesZinit_tensor_operantsZinit_default_kernel_signatures)Zin_testZnum_threadsrc   Zsysstrr]   )r\   rb   r^   __bootstrap__   sD   



rx   )uatexitrj   rs   rg   Zcore_suffixra   pathabspathdirname__file__sepZlegacy_coreexistsrn   writer`   rw   erf   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   Zdata_feederr(   r)   r*   Zdygraph.baser+   r,   Zdygraph.tensor_patch_methodsr-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   Zlayers.math_op_patchrJ   Z
lod_tensorrK   rL   Z
param_attrrM   rN   rO   rP   rQ   rR   rS   rT   ZTensorZenable_imperativeZdisable_imperative__all__rx   registerZclear_executor_cacheZpirZclear_cinn_compilation_cacheZclear_device_managerZclear_kernel_factoryZProcessGroupIdMapdestroyr]   r]   r]   r^   <module>   s\   
 @<h 	?