+
    9i%                         ^ RI t ^ RIt^ RIt^ RIHt ^ RIt^ RIt^ RIHt ^ RI	H
t
Ht ^RIHt ^RIHt ^RIHtHt ] P&                  ! ]4      tR
R R	 lltR# )    N)Path)SymbolicShapeInference)extract_raw_data_from_modelhas_external_data)ReplaceUpsampleWithResize)	ONNXModel)add_pre_process_metadata&save_and_reload_model_with_shape_inferc                8   V ^8  d   QhR\         \        ,          \        P                  ,          R,          R\         \        ,          R,          R\        R\        R\        R\        R\
        R	\        R
\
        R\        R\        R\         R,          R\
        RR/# )   input_modelNoutput_model_pathskip_optimizationskip_onnx_shapeskip_symbolic_shape
auto_mergeint_maxguess_output_rankverbosesave_as_external_dataall_tensors_to_one_fileexternal_data_locationexternal_data_size_thresholdreturn)strr   onnx
ModelProtoboolint)formats   "f/var/www/html/photoedit/myenv/lib/python3.14/site-packages/onnxruntime/quantization/shape_inference.py__annotate__r"      s     r, r,tdoo-4r,TzD(r, r, 	r,
 r, r, r, r, r,  r, "r,  $Jr, #&r, 
r,    c                	   V f   VP                  RR4      p V f   Q hVf   Q R4       h\        P                  ! RR7      ;_uu_ 4       p\        V4      p\	        V \
        P                  4      '       d   T M\
        P                  ! V 4      pVP                   Uu. uF*  pVP                  '       d   VP                  R8X  g   K(  VNK,  	  pp\        V4      ^8X  di   V^ ,          P                  pV^
8:  dO   \        \        V4      V4      P                  4        \
        P                  P!                  V^4      p\#        V4      pV'       g0   \$        P'                  R4       \(        P*                  ! VVVVV4      pV'       Ege   V'       gQ   \-        VR,          4      p V	'       d   \
        P.                  ! VV R	V
VR
R7       M\
        P0                  ! VV 4       Rp\-        VR,          4      p \2        P4                  ! 4       pVVn        \2        P8                  P:                  Vn        \	        V \
        P                  4      '       d`   \?        V 4      '       d   \A        R4      h\C        V 4      w  ppVPE                  \G        V4      \G        V4      4       V PI                  4       p M"V'       d   V	'       d   VPK                  RR4       \2        PL                  ! V VR.R7      p?Tp V'       g   VeQ   \-        VR,          4      p V	'       d   \
        P.                  ! VV R	V
VR
R7       M\
        P0                  ! VV 4       Rp\	        V \
        P                  4      '       d8   \-        \        V4      R,          4      p \
        P.                  ! VV R	V
VR
R7       \-        VR,          4      p\
        PV                  PY                  V V4       \
        P                  ! V4      pRRR4       Xf9   \	        V \
        P                  4      '       d   T M\
        P                  ! V 4      p\[        V4       V	'       d    \
        P.                  ! VVR	V
VVR
R7       R# \
        P0                  ! VV4       R# u upi   \N         dB    \$        PQ                  R4       \$        PQ                  \R        PT                  ! 4       4        ELi ; i  + '       g   i     L; i)a(  Shape inference and model optimization, in preparation for quantization.

Args:
    input_model: Path to the input model file or ModelProto
    output_model_path: Path to the output model file
    skip_optimization: Skip model optimization step if true. This may result in ONNX shape
        inference failure for some models.
    skip_onnx_shape: Skip ONNX shape inference. Symbolic shape inference is most effective
        with transformer based models. Skipping all shape inferences may
        reduce the effectiveness of quantization, as a tensor with unknown
        shape can not be quantized.
    skip_symbolic_shape: Skip symbolic shape inference. Symbolic shape inference is most
        effective with transformer based models. Skipping all shape
        inferences may reduce the effectiveness of quantization, as a tensor
        with unknown shape can not be quantized.
    auto_merge: For symbolic shape inference, automatically merge symbolic dims when
        conflict happens.
    int_max: For symbolic shape inference, specify the maximum value for integer to be
        treated as boundless for ops like slice
    guess_output_rank: Guess output rank to be the same as input 0 for unknown ops
    verbose: Logs detailed info of inference, 0: turn off, 1: warnings, 3: detailed
    save_as_external_data: Saving an ONNX model to external data
    all_tensors_to_one_file: Saving all the external data to one file
    external_data_location: The file location to save the external file
    external_data_size_threshold: The size threshold for external data
Ninput_model_pathzoutput_model_path is required.z
pre.quant.)prefixzai.onnxz&Performing symbolic shape inference...zsymbolic_shape_inferred.onnxTF)r   r   size_thresholdconvert_attributezoptimized.onnxzModelProto has external data not loaded into memory, ORT cannot create session. Please load external data before calling this function. See https://onnx.ai/onnx/repo-docs/ExternalData.html for more information.z7session.optimized_model_external_initializers_file_namezoptimized.onnx.dataCPUExecutionProvider)	providerszYONNX Runtime Model Optimization Failed! Consider rerun with option `--skip_optimization'.zmodel_input.onnxzonnx_shape_inferred.onnx)r   r   locationr'   r(   ).poptempfileTemporaryDirectoryr   
isinstancer   r   loadopset_importdomainlenversionr   r   applyversion_converterconvert_versionr
   loggerinfor   infer_shapesr   
save_modelsaveonnxruntimeSessionOptionsoptimized_model_filepathGraphOptimizationLevelORT_ENABLE_BASICgraph_optimization_levelr   
ValueErrorr   add_external_initializerslistSerializeToStringadd_session_config_entryInferenceSession	Exceptionerror	traceback
format_excshape_inferenceinfer_shapes_pathr	   )r   r   r   r   r   r   r   r   r   r   r   r   r   deprecated_kwargsquant_tmp_dir	temp_pathmodelopsetai_onnx_domainopset_versionopt_model_pathsess_optionexternal_namesexternal_valuessessinferred_model_paths   &&&&&&&&&&&&&,            r!   quant_pre_processr\      s    V '++,>E"""(J*JJ(		$	$L	9	9]'	)+tGGTYYWbMc
 .3-?-?q-?Eu|||W\WcWcgpWp%%-?q~!#*1-55M"))E*:MJPPR..>>ubI>uE"KK@A*77!E ! &!).L"LM(OO#.20G'C*/ IIe[1 -=!=>N5)88:7E47B7Y7Y7j7j4k4??;;(55(i 
 7RR]6^3NO99$~:NPTUdPef"-"?"?"AK )-B88QSh #33KYoXpq  )K
  !).L"LM(OO#.20G'C*/ IIe[1+t77!$}"58J"JK*.,C#?&+ #&i2L&L"M  22;@STII12E_ 
:b })+tGGTYYWbMcU#"&$;+7#	
 			%*+u r~  5o Y1134	5M 
:	9sx   ASQ10Q1Q1	BS7SSA"S.CQ60Q68-Q6%	S/C3S1S6AS>SSSS	)NNFFFFiFr   FFNi   )loggingr-   rK   pathlibr   r   r=   &onnxruntime.tools.symbolic_shape_inferr   #onnxruntime.transformers.onnx_utilsr   r   fusionsr   
onnx_modelr   quant_utilsr	   r
   	getLogger__name__r8   r\    r#   r!   <module>rg      sD          I ^ . ! Y			8	$r, r,r#   