
    h                        S SK Jr  S SKrS SKrS SKrS SKJr  S SKr	S SK
rSSSS.rSS	S
SSSSS.rSSS jjr      SS jrS r\S:X  a  \" 5         gg)    )annotationsN)default_timerfloat16float32float64)ztensor(float16)ztensor(float)ztensor(double)int32int8uint8int16uint16int64uint64)ztensor(int32)ztensor(int8)ztensor(uint8)ztensor(int16)ztensor(uint16)ztensor(int64)ztensor(uint64)c                   0 nU=(       d    0 nU R                  5        GH  n/ nUR                   Hy  nU(       d  UR                  S5        M  [        U[        5      (       a6  XQ;   a  UR                  [        X   5      5        MU  UR                  S5        Mh  UR                  U5        M{     UR                  [        ;   aK  [        R                  R                  " U6 R                  [        UR                     5      X#R                  '   M  UR                  [        ;   aV  [        R                  R                  S[        U5      S9R                  [        UR                     5      X#R                  '   GMX  UR                  S:X  aE  [        R                  R!                  S[        U5      S9R                  S5      X#R                  '   GM  [#        SUR                   S	UR                   35        [$        R&                  " S
5        GM     U$ )N     highsizetensor(bool)   r   boolzunsupported input type z for input )
get_inputsshapeappend
isinstancestrinttype
float_dictnprandomrandastypenameinteger_dictuniformtuplerandintprintsysexit)sesssymbolic_dimsfeeds
input_metar   dims         \/var/www/fran/franai/venv/lib/python3.13/site-packages/onnxruntime/tools/onnxruntime_test.pygenerate_feedsr4   !   su   E!'RMoo'
##CQC%%'LL]%7!89LLOS! $ ??j(%'YY^^U%;%B%B:jooC^%_E//"__,%'YY%6%6DuU|%6%T%[%[Z__-&E//" __.%'YY%6%6quU|%6%L%S%STZ%[E//"+JOO+<K
GXYZHHRL5 (6 L    c                   U=(       d    0 nU(       aK  [        S[        R                  " 5        35        [        S5        [        R                  R                  S5        S nU(       a@  [        R                  " 5       nSUl        [        R                  R                  U 5      Ul        [        R                  " U U[        R                  " 5       S9nUR                  5       n	U(       d  [        X5      nU(       Ga  UR!                  5        GH  n
U
R"                   Vs/ s H  o(       a  UOSPM     nnU
R$                  [&        ;   aK  [(        R*                  R,                  " U6 R/                  [&        U
R$                     5      XZR0                  '   M  U
R$                  [2        ;   aU  [(        R*                  R5                  S[7        U5      S9R/                  [2        U
R$                     5      XZR0                  '   M  U
R$                  S:X  aE  [(        R*                  R9                  S	[7        U5      S
9R/                  S5      XZR0                  '   GME  [        SU
R$                   SU
R0                   35        [        R:                  " S5        GM     [=        5       n[?        U5       H  nURA                  / U5      nM     [=        5       n[        SU	RB                   35        [        SU	RD                   35        [        SU 35        [        SUU-
  S-  U-   S35        U(       a  URG                  5       n[        SU 35        SXQS:  =(       a    W4$ s  snf )Nz7Pausing execution ready for debugger to attach to pid: zPress key to continue.r   T)sess_options	providersr   r   r   r   r   r   zunsupported initializer type z for initializer r   zmodel: z	version: ziterations: zavg latency: z msztrace file written to: r   )$r+   osgetpidr,   stdinreadonnxrtSessionOptionsenable_profilingpathbasenameprofile_file_prefixInferenceSessionget_available_providersget_modelmetar4   get_overridable_initializersr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r-   timerrangerun
graph_nameversionend_profiling)
model_path	num_itersdebugprofiler/   r0   override_initializersr7   r.   metainitializerr2   r   start_ioutputsend
trace_files                     r3   	run_modelrY   C   s    "'RMG		}UV&'		qL,,.(,%+-77+;+;J+G(""!002D
 Dt3  <<>K2=2C2CD2C3CSQ&2CED:-*,))..%*@*G*G
S^ScScHd*e&&'!!\1*,))*;*;ERWL*;*Y*`*` !1!12+&&' !!^3*,))*;*;AE%L*;*Q*X*XY_*`&&'5k6F6F5GGXYdYiYiXjkl ? GEI((2u% 
'C	GDOO$
%&	Idll^
$%	L
$%	MC%K4/9<=S
AB'')
'
|45e].w..7 Es   Mc                    [         R                  " SS9n U R                  SSS9  U R                  SS[        SS	S
9  U R                  SSSS9  U R                  SSSS9  U R                  S0 S SS9  U R	                  5       n[        UR                  UR                  UR                  UR                  UR                  5      u  n  n[        R                  " U5        g )NzSimple ONNX Runtime Test Tool.)descriptionrM   z
model path)helprN   ?r   z"model run iterations. default=1000)nargsr    defaultr\   z--debug
store_truez.pause execution to allow attaching a debugger.)actionr\   z	--profilez'enable chrome timeline trace profiling.z--symbolic_dimsc                D    [        S U R                  S5       5       5      $ )Nc              3  B   #    U  H  oR                  S 5      v   M     g7f)=N)split).0xs     r3   	<genexpr>)main.<locals>.<lambda>.<locals>.<genexpr>   s     ?,QGGCLL,s   ,)dictre   )ss    r3   <lambda>main.<locals>.<lambda>   s    t?!''#,??r5   zComma separated name=value pairs for any symbolic dimensions in the model input. e.g. --symbolic_dims batch=1,seqlen=5. If not provided, the value of 1 will be used for all symbolic dimensions.)r_   r    r\   )argparseArgumentParseradd_argumentr   
parse_argsrY   rM   rN   rO   rP   r/   r,   r-   )parserargs	exit_code_s       r3   mainrw      s    $$1QRF
<8
1   =  
 L?hi
?T	   DT\\[_[m[mnOIq!HHYr5   __main__)N)r/   zdict | None)r   NNNNT)
__future__r   ro   r9   r,   timeitr   rG   numpyr"   onnxruntimer=   r!   r'   r4   rY   rw   __name__ r5   r3   <module>r      s   
 #  	 
 )   !
 H 

?/D< zF r5   