U
    T?h	                     @   sV   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rRe	  dS )    N   )fix_output_shapesmake_dim_param_fixedmake_input_shape_fixedc                  C   sn  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r|js|js|jr|jr|jr|jdk s|jr|jrtdd |jD rtd |   td tt	|jjdd}|jr:t|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   \/var/www/html/venv/lib/python3.8/site-packages/onnxruntime/tools/make_dynamic_shape_fixed.py
<listcomp>%   s     zEmake_dynamic_shape_fixed_helper.<locals>.<lambda>.<locals>.<listcomp>,)split)xr   r   r   <lambda>%       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   s     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_argsZ	dim_paramZ
input_nameZ	dim_valueZinput_shapeanyprint
print_helpsysexitonnxloadr   resolver   graphr   r   saver   )parserargsmodelr   r   r   r!      sx          
r!   __main__)r   r   r%   r+   r-   Zonnx_model_utilsr   r   r   r!   r"   r   r   r   r   <module>   s   8