+
    9ik                     |   R t ^ RIt^ RIt^ RIt^ RIHt R tRR R llt]R8X  d   ]! 4       t	]! ]	P                  ]	P                  ]	P                  ]	P                  ]	P                  ]	P                  ]	P                   ]	P"                  ]	P$                  ]	P&                  ]	P(                  ]	P*                  R7       R# R# )	z@Provide entry point to preprocess ONNX model especially for QNN.N)qnnc            	     N   \         P                  ! RR7      p V P                  RRRRR7       V P                  RR	RR
R7       V P                  RRRR7       V P                  RRRR7       V P                  RRR7       V P                  RR\        RR7       V P                  RRRR7       V P                  RRRR7       V P                  RRRRR 7       V P                  R!RRR"R 7       V P                  R#^R$\        RR%R&7       V P                  R'RR(R7       V P                  4       # ))zParse cmdline arguments.z#Arguments for QNN model preprocess.)descriptionz--input_model_pathz-iTzPath to the input ONNX model.)requiredhelpz--output_model_pathz-ozPath to the output ONNX model.z--save_as_external_data
store_truez;Whether the output model would be saved with external data.)actionr   z--all_tensors_to_one_filezgWhether to save all external data in one file or save each tensor to a file named with the tensor name.z--external_data_locationzbFilename of the external file where all tensors are saved. The path is relative to the model path.)r   z--external_data_size_threshold   zQTensors with data size larger than this threshold are converted to external data.)defaulttyper   z!--external_data_convert_attributezKWhether to save all tensors, including attribute tensors, to external data.z--fuse_layernormzLWhether to fuse matched sequences into LayerNormalization nodes if possible.z--inputs_to_make_channel_last+Nz=List of graph input names to be transposed into channel-last.)nargsr
   r   z--outputs_to_make_channel_lastz>List of graph output names to be transposed into channel-last.z--dynamic_input_shapesappendzdModel input name and desired static shape in comma seprated format, for example: 'input' 1,3,256,256)r   r   r   r
   r   z --exclude_initializer_from_inputzBWhether to exclude initializer from input if model.ir_version >= 4)argparseArgumentParseradd_argumentintstr
parse_args)parsers    ^/var/www/html/photoedit/myenv/lib/python3.14/site-packages/onnxruntime/tools/qnn/preprocess.py_parse_argumentsr      s   $$1VWF
,dTHgh
-tdIij !J  
 #v  
 "q   (`	   +Z   [   'L	   (M	    s   *Q       c                   V ^8  d   QhR\         \        P                  ,          \        P                  ,          R\         \        P                  ,          R\
        R\
        R\
        R\         R,          R\        R	\
        R
\        \         ,          R,          R\        \         ,          R,          R\        \        \         \         3,          ,          R,          R\
        R\
        /# )   model_inputmodel_outputfuse_layernormsave_as_external_dataall_tensors_to_one_fileexternal_data_locationNexternal_data_size_thresholdexternal_data_convert_attributeinputs_to_make_channel_lastoutputs_to_make_channel_lastdynamic_input_shapesexclude_initializer_from_inputreturn)	r   pathlibPathonnx
ModelProtoboolr   listtuple)formats   "r   __annotate__r0   \   s     7 7w||#doo57$7 7  	7
 "7  $J7 #&7 &*7 "&cT!17 #'s)d"27 uS#X/$67 %)7 
7r   c                F    \         P                  ! V VVVVVVVVV	V
VR7      # )a  Preprocess ONNX model for QNN.

Args:
    model_input: A path or ONNX ModelProto specifiying the model to be preprocessed.
    model_output: A path specifying where the preprocessed model to be saved.
    fuse_layernorm: A bool specifying whether to fuse the matched sequence into a single LayerNormalization node.
        Defaults to False.
    save_as_external_data: A bool specifying whether to save model with external data. Defaults to False.
    all_tensors_to_one_file: A bool specifying whether to save all external data in one file or save each tensor to
        a file named with the tensor name. This argument is effective only when `save_as_external_data` is True.
        Defaults to False.
    external_data_location: A str specifying where to save the external data. The path is relative to the model
        path. This argument is effective only when `save_as_external_data` is True. Defaults to the model name.
    external_data_size_threshold: An int specifying the threshold of data size for tensors be saved as external
        data. This argument is effective only when `save_as_external_data` is True. Defaults to 1024.
    external_data_convert_attribute: A bool specifying whether to save all tensors including attributes as external
        data. This argument is effective only when `save_as_external_data` is True. Defaults to False.
    inputs_to_make_channel_last: A list of strs specifying graph input names to be transposed into channel-last.
        Defaults to None.
    outputs_to_make_channel_last: A list of strs specifying graph output names to be transposed into channel-last.
        Defaults to None.
    dynamic_input_shapes: A list of tuples specifying model input name to and its static shape in comma seprated
        format, for example: [('input', '1,3,256,256')]. Defaults to None.
    exclude_initializer_from_input: A bool specifying whether to exclude initializer from input. Defaults to False.

Returns:
    A bool indicating whether the model is modified.

r   r   r   r    r!   r"   r#   r$   r%   r&   )r   qnn_preprocess_model)r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   s   &&&&&&&&&&&&r   r3   r3   \   s<    T ##%3 75%A(G$?%A1'E r   __main__r2   )
FFFNr	   FNNNF)__doc__r   r(   r*   ,onnxruntime.quantization.execution_providersr   r   r3   __name__argsinput_model_pathoutput_model_pathr   r   r   r    r!   r"   r#   r$   r%   r&    r   r   <module>r<      s    G    <IX7t zD**"88 $ < <#::%)%F%F(,(L(L$($D$D%)%F%F!66'+'J'J r   