§
    kŠtj(  ã                   óh  — d dl Z d dlZd dlZddlmZ  ej        e¦  «        Zd„ Zedk    �r e¦   «         Z	e	j
        r2e	j        r+e	j        r$e                     d¦  «          ej        ¦   «          e	j
        s+e	j        r$e                     d¦  «          ej        ¦   «          e                     de	j        ¦  «         e                     d	e	j        ¦  «          ee	j        e	j        e	j
        e	j        e	j        e	j        e	j        e	j        e	j        e	j        e	j        e	j        e	j        ¦  «         dS dS )
é    Né   )Úquant_pre_processc                  ó  — t          j        d¬¦  «        } |                      ddd¬¦  «         |                      ddd¬¦  «         |                      d	t          d
d¬¦  «         |                      dt          d
d¬¦  «         |                      dt          d
d¬¦  «         |                      dddd
¬¦  «         |                      ddt          d¬¦  «         |                      dddd
¬¦  «         |                      ddt          d¬¦  «         |                      dddd
¬¦  «         |                      d d!dd
¬¦  «         |                      d"d#d ¬$¦  «         |                      d%d&t          d'¬¦  «         |                      ¦   «         S )(NaÜ  Model optimizer and shape inferencer, in preparation for quantization,
Consists of three optional steps:
1. Symbolic shape inference (best for transformer models).
2. Model optimization.
3. ONNX shape inference.

Model quantization with QDQ format, i.e. inserting QuantizeLinear/DeQuantizeLinear on
the tensor, requires tensor shape information to perform its best. Currently, shape inferencing
works best with optimized model. As a result, it is highly recommended to run quantization
on optimized model with shape information. This is the tool for optimization and shape
inferencing.

Essentially this tool performs the following three (skippable) steps:

1. Symbolic shape inference.
2. Model optimization
3. ONNX shape inference)Údescriptionz--inputTzPath to the input model file)ÚrequiredÚhelpz--outputzPath to the output model filez--skip_optimizationFz°Skip model optimization step if true. It's a known issue that ORT optimization has difficulty with model size greater than 2GB, rerun with this option to get around this issue.)ÚtypeÚdefaultr   z--skip_onnx_shapezå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.z--skip_symbolic_shapezé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.z--auto_mergez:Automatically merge symbolic dims when confliction happensÚ
store_true)r   Úactionr
   z	--int_maxzGmaximum value for integer to be treated as boundless for ops like sliceiÿÿÿ)r   r	   r
   z--guess_output_rankz;guess output rank to be the same as input 0 for unknown opsz	--verbosezHPrints detailed logs of inference, 0: turn off, 1: warnings, 3: detailedr   z--save_as_external_dataz%Saving an ONNX model to external dataz--all_tensors_to_one_filez(Saving all the external data to one filez--external_data_locationz+The file location to save the external file)r   r
   z--external_data_size_thresholdz$The size threshold for external datai   )ÚargparseÚArgumentParserÚadd_argumentÚboolÚintÚ
parse_args)Úparsers    úa/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/onnxruntime/quantization/preprocess.pyÚparse_argumentsr      sF  € ÝÔ$ððñ ô €Fð( ×Ò˜	¨DÐ7UÐÑVÔVÐVØ
×Ò˜
¨TÐ8WÐÑXÔXÐXØ
×ÒØÝØð1ð	 ñ ô ð ð ×ÒØÝØð'ð	 ñ ô ð ð ×ÒØÝØð4ð	 ñ ô ð ð ×ÒØØIØØð	 ñ ô ð ð ×ÒØØVÝØð	 ñ ô ð ð ×ÒØØJØØð	 ñ ô ð ð ×ÒØØWÝØð	 ñ ô ð ð ×ÒØ!Ø4ØØð	 ñ ô ð ð ×ÒØ#Ø7ØØð	 ñ ô ð ð ×ÒØ"Ø:Øð ñ ô ð ð
 ×ÒØ(Ø3ÝØð	 ñ ô ð ð ×ÒÑÔÐó    Ú__main__z9Skipping all three steps, nothing to be done. Quitting...z:ORT model optimization does not support external data yet!zinput model: %szoutput model: %s)r   ÚloggingÚsysÚshape_inferencer   Ú	getLoggerÚ__name__Úloggerr   ÚargsÚskip_optimizationÚskip_onnx_shapeÚskip_symbolic_shapeÚerrorÚexitÚsave_as_external_dataÚinfoÚinputÚoutputÚ
auto_mergeÚint_maxÚguess_output_rankÚverboseÚall_tensors_to_one_fileÚexternal_data_locationÚexternal_data_size_threshold© r   r   ú<module>r0      s…  ðð €€€Ø €€€Ø 
€
€
€
à .Ð .Ð .Ð .Ð .Ð .à	ˆÔ	˜8Ñ	$Ô	$€ð`ð `ð `ðF ˆzÒÑØˆ?ÑÔ€DØÔð  $Ô"6ð ¸4Ô;Sð Ø�ŠÐPÑQÔQÐQØˆŒ‰
Œ
ˆ
àÔ"ð ¨Ô(Bð Ø�ŠÐQÑRÔRÐRØˆŒ‰
Œ
ˆ
à
‡K‚KÐ! 4¤:Ñ.Ô.Ð.Ø
‡K‚KÐ" D¤KÑ0Ô0Ð0ØÐØŒ
ØŒØÔØÔØÔ ØŒØŒØÔØŒØÔ"ØÔ$ØÔ#ØÔ)ñô ð ð ð ð Ðr   