
    g	                     `    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)    N   )fix_output_shapesmake_dim_param_fixedmake_input_shape_fixedc                  R   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                  s}|j                  s|j                  re|j                  r|j                   rM|j                   dk  s>|j                  rb|j"                  r&t%        |j"                  D cg c]  }|dk  	 c}      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 c c}w )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     _/var/www/openai/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   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value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UYUeUe=fUeEeaiUe=f9gIIc$**22$2?@AE~~U[[$..$..Iu{{DOOT=M=MN eIIeS**22456! >gs   J$__main__)r   r   r#   r-   r/   onnx_model_utilsr   r   r   r   r         r   <module>r<      s7   
  	  
  ] ]57p z#% r;   