
     Ng	                     l    d dl Z d dlZd dlZd dlZd dlZddlmZmZmZ d Z	e
dk    r e	             dS dS )    N   )fix_output_shapesmake_dim_param_fixedmake_input_shape_fixedc                     t          j        t          j                            t
                     dt          j         d          } |                     dt          dd           |                     dt          dd	           |                     d
t          dd           |                     dd dd           |                     dt          j        d           |                     dt          j        d           |                                 }|j        r|j        sS|j        s|j        rE|j        r|j        r7|j        dk     s,|j        r\|j        rt%          d |j        D                       r7t'          d           |                                  t+          j        d           t/          j        t          |j                            d                              }|j        r!t7          |j        |j        |j                   n t;          |j        |j        |j                   t=          |           t/          j        |t          |j                                                              d S )N:z
                                     Assign a fixed value to a dim_param or input shape
                                     Provide either dim_param and dim_value or input_name and input_shape.)descriptionz--dim_paramFz8Symbolic parameter name. Provide dim_value if specified.)typerequiredhelpz--dim_valuez:Value to replace dim_param with in the model. Must be > 0.z--input_namezGModel input name to replace shape of. Provide input_shape if specified.z--input_shapec                 @    d |                      d          D             S )Nc                 ,    g | ]}t          |          S  )int).0is     f/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnxruntime/tools/make_dynamic_shape_fixed.py
<listcomp>zEmake_dynamic_shape_fixed_helper.<locals>.<lambda>.<locals>.<listcomp>%   s    5551A555    ,)split)xs    r   <lambda>z1make_dynamic_shape_fixed_helper.<locals>.<lambda>%   s    55555 r   zShape to use for input_shape. Provide comma separated list for the shape. All values must be > 0. e.g. --input_shape 1,3,256,256input_modelz%Provide path to ONNX model to update.)r
   r   output_modelz,Provide path to write updated ONNX model to.r   c                     g | ]}|d k     	S )r   r   )r   values     r   r   z3make_dynamic_shape_fixed_helper.<locals>.<listcomp>4   s    =f=f=fEeai=f=f=fr   zInvalid usage.T)strict)!argparseArgumentParserospathbasename__file__make_dynamic_shape_fixed_helper__name__add_argumentstrr   pathlibPath
parse_args	dim_param
input_name	dim_valueinput_shapeanyprint
print_helpsysexitonnxloadr   resolver   graphr   r   saver   )parserargsmodels      r   r&   r&      s   $7H%%RR(G(PRRn  F C%6p     C%6r     V	     55A	     GL?fggg
W\@noooD 
 O'+ N %)N 7;nq6H6HO 7I%)%5 7I9<=f=fUYUe=f=f=f9g9g 7I 	Ic$*22$2??@@AAE~ OU[$.$.IIIIu{DOT=MNNN eIeS*22445566666r   __main__)r    r"   r*   r4   r6   onnx_model_utilsr   r   r   r&   r'   r   r   r   <module>r@      s   
  				  



  ] ] ] ] ] ] ] ] ] ]57 57 57p z##%%%%% r   