
    ?pj                     h    S SK JrJr  SSKJrJrJrJrJrJ	r	J
r
Jr  SSKJr  / SQrS rS rS rS	 rg
)    )get_default_deviceparse_device   )DEFAULT_CPU_THREADSDEFAULT_DEVICEDEFAULT_ENABLE_MKLDNNDEFAULT_MKLDNN_CACHE_CAPACITYDEFAULT_PRECISIONDEFAULT_USE_TENSORRTSUPPORTED_PRECISION_LISTDEFAULT_USE_CINN)str2bool)paddlepaddle_staticpaddle_dynamictransformersonnxruntimec                   [         S S U[        [        [        [        [
        [        S.
nU R                  5       UR                  5       -
  nU H  n[        SU 35      e   0 UEU En U S   b&  U S   [        ;  a  [        SU S    S[         S35      eU S   [        ;  a  [        SU S    S[         S35      eU R                  S	5      U S
'   U R                  S5      U S'   U $ )N)
deviceengineengine_config
enable_hpiuse_tensorrt	precisionenable_mkldnnmkldnn_cache_capacitycpu_threadsenable_cinnzUnknown argument: r   zInvalid engine: z. Supported values are: .r   zInvalid precision: r   	use_pptrtpptrt_precision)r   r   r
   r   r	   r   r   keys
ValueErrorSUPPORTED_INFERENCE_ENGINE_LISTr   pop)kwargsdefault_enable_hpidefault_valsunknown_namesnames        R/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/paddleocr/_common_args.pyparse_common_argsr,   &   s    (,&.!>*'L KKML$5$5$77M-dV455  (''F 	x$8$CCvh/00HIhHiijk
 	
 k"::!&"5!66NOgNhhij
 	
 !**^4F; &

; 7FM    c                     0 nUS:X  a8  U S   (       a(  U S   S:X  a  SUS'   OKU S   S:X  d
   U S   5       eSUS'   O2S	US'   O,US
:X  a!  U S   (       a	  U S   US'   OS	US'   U S   US'   OS	US'   U S   US'   U$ )Ngpur    r!   fp32trt_fp32run_modefp16trt_fp16r   cpur   r   r   r    )common_argsdevice_typecfgs      r+   "_build_paddle_static_engine_configr:   M   s    
Ce{#,-7",J"#45? %B ? #-J&C
O		'+67N+OC'(&C
O(7M"J$]3CJr-   c                     US   nUc
  [        5       n[        U5      u  p40 nX%S'   US   US'   US   US'   US   nUS   n[        X5      nUb  XeS'   U$ US:X  a  XS'   U$ US;   a	  SU0US'   U$ S US'   U$ )Nr   r   r   use_hpipr   r   )Nr   )r   r   r:   )	
model_namer7   r   r8   _init_kwargsuser_engine_configr   builts	            r+   prepare_common_init_argsrB   f   s    "F~#%!&)NKK"'1K),7K
$_5"F.{HE%'9O$  
?	"',O$  
#	#(7'?O$  (,O$r-   c                   U(       a  SnOSnU R                  S[        [        US9  U R                  S[        [        SS9  U R                  S[        US	S9  U R                  S
[        [
        SS9  U R                  S[        [        [        SS9  U R                  S[        [        SS9  U R                  S[        [        SS9  U R                  S[        [        SS9  U R                  S[        [        SS9  g )Na  Device(s) to use for inference, e.g., `cpu`, `gpu`, `npu`, `gpu:0`, `gpu:0,1`. If multiple devices are specified, inference will be performed in parallel. Note that parallel inference is not always supported. By default, GPU 0 will be used if available; otherwise, the CPU will be used.zDevice to use for inference, e.g., `cpu`, `gpu`, `npu`, `gpu:0`. By default, GPU 0 will be used if available; otherwise, the CPU will be used.z--device)typedefaulthelpz--engineznInference engine to use. For CLI, engine-specific configuration should be set in the PaddleX YAML config file.)rD   choicesrF   z--enable_hpiz&Enable the high performance inference.z--use_tensorrtzWhether to use the Paddle Inference TensorRT subgraph engine. If the model does not support TensorRT acceleration, even if this flag is set, acceleration will not be used.z--precisionzPPrecision for TensorRT when using the Paddle Inference TensorRT subgraph engine.)rD   rE   rG   rF   z--enable_mkldnnzEnable MKL-DNN acceleration for inference. If MKL-DNN is unavailable or the model does not support it, acceleration will not be used even if this flag is set.z--mkldnn_cache_capacityzMKL-DNN cache capacity.z--cpu_threadsz/Number of threads to use for inference on CPUs.z--enable_cinnz!Whether to use the CINN compiler.)add_argumentstrr   r$   r   r   r
   r   r   intr	   r   r   )parserr'   allow_multiple_deviceshelp_s       r+   add_common_cli_optsrN      sE    q a
	   /}	   "5	   $ {	   !(_   % n	   !-&	   #>	    0	  r-   N)paddlex.utils.devicer   r   
_constantsr   r   r   r	   r
   r   r   r   
_utils.clir   r$   r,   r:   rB   rN   r6   r-   r+   <module>rR      s<    B	 	 	 !# $N26;r-   