U
    h
                     @   sN   d dl Z d dlZd dlZejdd ddlmZmZ dd ZedkrJe  dS )	    Nz%(levelname)s:  %(message)s)format   )"check_model_can_use_ort_mobile_pkgusability_checkerc                  C   s  t jdt jd} | jdddtjt d | jddd	d
dgd	dd | jddtjd |  }t	
d}|jdkr|t	j n<|jd	kr|t	j n$|jd
kr|t	j n|t	j tj|jd|d}t|j|j| |d |r|d n
|d d S )NzAnalyze an ONNX model to determine how well it will work in mobile scenarios, and whether
        it is likely to be able to use the pre-built ONNX Runtime Mobile Android or iOS package.)descriptionformatter_classz--config_pathzbPath to required operators and types configuration used to build the pre-built ORT mobile package.F)helprequiredtypedefaultz--log_leveldebuginfowarningerrorzLogging level)choicesr   r   
model_pathzPath to ONNX model to check)r   r
   check_usability)Zskip_optimizeloggera  Run `python -m onnxruntime.tools.convert_onnx_models_to_ort ...` to convert the ONNX model to ORT format. By default, the conversion tool will create an ORT format model with saved optimizations which can potentially be applied at runtime (with a .with_runtime_opt.ort file extension) for use with NNAPI or CoreML, and a fully optimized ORT format model (with a .ort file extension) for use with the CPU EP.a
  As NNAPI or CoreML may provide benefits with this model it is recommended to compare the performance of the <model>.with_runtime_opt.ort model using the NNAPI EP on Android, and the CoreML EP on iOS, against the performance of the <model>.ort model using the CPU EP.zNFor optimal performance the <model>.ort model should be used with the CPU EP. )argparseArgumentParserArgumentDefaultsHelpFormatteradd_argumentpathlibPathr   Zget_default_config_path
parse_argslogging	getLoggerZ	log_levelsetLevelDEBUGINFOWARNINGERRORr   Zanalyze_modelr   Z	run_checkZconfig_pathr   )parserargsr   Ztry_eps r$   W/tmp/pip-unpacked-wheel-socb9apf/onnxruntime/tools/check_onnx_model_mobile_usability.pyr      sJ     
  



r   __main__)	r   r   r   basicConfigZmobile_helpersr   r   r   __name__r$   r$   r$   r%   <module>   s   4