
    Bvh	
                    l    d dl mZ 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        yy)    )annotationsN   )fix_output_shapesmake_dim_param_fixedmake_input_shape_fixedc                 4   t        j                  t        j                  j	                  t
               dt        j                   d      } | j                  dt        dd       | j                  dt        dd	       | j                  d
t        dd       | j                  dd dd       | j                  dt        j                  d       | j                  dt        j                  d       | j                         }|j                  r|j                  ss|j                  s|j                  r[|j                  r|j                   rC|j                   dk  s4|j                  rX|j"                  rt%        d |j"                  D              r0t'        d       | j)                          t+        j,                  d       t/        j0                  t        |j2                  j5                  d                  }|j                  r,t7        |j8                  |j                  |j                          n+t;        |j8                  |j                  |j"                         t=        |       t/        j>                  |t        |j@                  j5                                      y )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                \    | j                  d      D cg c]  }t        |       c}S c c}w )N,)splitint)xis     T/RAG/venv/lib/python3.12/site-packages/onnxruntime/tools/make_dynamic_shape_fixed.py<lambda>z1make_dynamic_shape_fixed_helper.<locals>.<lambda>&   s"    51A55s   )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              3  &   K   | ]	  }|d k    yw)r   N ).0values     r   	<genexpr>z2make_dynamic_shape_fixed_helper.<locals>.<genexpr>5   s     <eTd5UQYTds   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   $$77H%
&a(G(P(P'QRnF C%6p   C%6r   V	   5A	   GLL?fg
W\\@noD 
DOOtNNDNNdnnq6HOOT%5%5<eTXTdTd<e9eIIc$**22$2?@AE~~U[[$..$..Iu{{DOOT=M=MN eIIeS**22456    __main__)
__future__r   r   r!   r)   r3   r5   onnx_model_utilsr   r   r   r%   r&   r   r=   r   <module>rA      s:    #  	  
  ] ]57p z#% r=   