
    hz
                     Z    S r SSKrSSKrSSKr\R
                  " S5      rSrS rS r	S r
g)z/Helper classes or functions for onnxrt adaptor.    Nneural_compressorl        c                     X-  nSnS[        X2-  5      -  nSU[        U5      -
  -  nUS-  n[        SU U SUS S3S	S
9  g)z0Progress bar for cases where tqdm can't be used.   # d   zProgress: [z] z.2f% )endN)intlenprint)totaliprogress
bar_lengthbarspaces
percentages          i/var/www/fran/franai/venv/lib/python3.13/site-packages/onnxruntime/quantization/neural_compressor/util.pysimple_progress_barr       s\    yHJ
J)*
*CJS)*FCJ	M#vhbC(8
:C    c                     / nU HA  n[        US5      (       d
   U S35       eUR                  U :X  d  M0  UR                  U5        MC     [        U5      S:  a  US   $ g)z/Helper function to find item by name in a list.namez' should have a 'name' attribute definedr   N)hasattrr   appendr   )r   	item_listitemsitems       r   find_by_namer    *   sb    EtV$$V.U&VV$99LL  5zA~Qxr   c                 L   SSK n[        U [        R                  5      (       Gd]  [        R
                  R                  S5      (       d   [        R                  S5        [        S5        [        XR                  5      (       a  U R                  UR                  L aE  U R                  5       R                  5       R                  UR                   5      R#                  5       $ U R                  UR$                  L aE  U R                  5       R                  5       R                  UR&                  5      R#                  5       $ U R                  5       R                  5       R#                  5       $  [        R(                  " U 5      $ U $ ! [*         a     S[-        U 5       S35       ef = f)zConvert to numpy ndarrays.r   NtorchzxPlease install torch to enable subsequent data type check and conversion, or reorganize your data format to numpy array.z!The input data for onnx model is z6, which is not supported to convert to numpy ndarrays.)r"   
isinstancenpndarray	importlibutil	find_specloggererrorexitTensordtypebfloat16detachcputofloat32numpychalfcfloatarray	Exceptiontype)datar"   s     r   to_numpyr:   7   s5   dBJJ''~~''00LLA GdLL))zzU^^+{{}((*--emm<BBDDzzU[[({{}((*--ell;AACC;;=$$&,,..xx~%   7T
|Cyzus   ,F F#)__doc__r&   loggingr3   r$   	getLoggerr)   MAXIMUM_PROTOBUFr   r    r:    r   r   <module>r@      s<   & 6   			.	/  D
r   