o
    g	                     @   sZ   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d Z	e
dkr+e	  dS dS )    N   )fix_output_shapesmake_dim_param_fixedmake_input_shape_fixedc                  C   sh  t jtjt dtj dd} | jdt	ddd | jdt
dd	d | jd
t	ddd | jddd ddd | jdtjdd | jdtjdd |  }|jrS|jst|jsY|jrt|jrd|jrt|jdk st|jr|jrttdd |jD rtd |   td tt	|jjdd}|jrt|j|j|j n	t|j|j|j t| t|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                 S   s   dd |  dD S )Nc                 S   s   g | ]}t |qS  )int).0ir   r   a/var/www/visachat/venv/lib/python3.10/site-packages/onnxruntime/tools/make_dynamic_shape_fixed.py
<listcomp>%       zEmake_dynamic_shape_fixed_helper.<locals>.<lambda>.<locals>.<listcomp>,)split)xr   r   r   <lambda>%   r   z1make_dynamic_shape_fixed_helper.<locals>.<lambda>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                 S   s   g | ]}|d k qS )r   r   )r   valuer   r   r   r   4   r   z3make_dynamic_shape_fixed_helper.<locals>.<listcomp>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modelr   r   r   r!      sj   

r!   __main__)r   r   r%   r/   r1   onnx_model_utilsr   r   r   r!   r"   r   r   r   r   <module>   s   8
