
    h3                         S SK Jr  S SKJrJrJrJrJrJrJ	r	  S SK
r
S SKrS SKJs  Jr  S SKJrJrJr   " S S5      r " S S5      rS	\S
\\   S\S\S\	\\S4      4
S jr " S S5      r " S S5      rg)    )
namedtuple)AnyDictNewTypeOptionalSequenceTupleTypeN)
IR_VERSION
ModelProto	NodeProtoc                   `    \ rS rSr% Sr\" S\5      r\" S5      r\\	S'   \" S5      r
\\	S'   Srg	)

DeviceType   z
Describes device type.
_Typer   CPU   CUDA N)__name__
__module____qualname____firstlineno____doc__r   intr   r   __annotations__r   __static_attributes__r       K/var/www/fran/franai/venv/lib/python3.13/site-packages/onnx/backend/base.pyr   r      s1     GS!EqC(D%r   r   c                   *    \ rS rSrSrS\SS4S jrSrg)Device   zn
Describes device type and device id
syntax: device_type:device_id(optional)
example: 'CPU', 'CUDA', 'CUDA:1'
devicereturnNc                     UR                  S5      n[        [        US   5      U l        SU l        [        U5      S:  a  [        US   5      U l        g g )N:r   r   )splitgetattrr   type	device_idlenr   )selfr#   optionss      r   __init__Device.__init__!   sI    ,,s#J
3	w<! _DN r   )r*   r)   )r   r   r   r   r   strr.   r   r   r   r   r!   r!      s    -s -t -r   r!   typenamefield_namesargskwargsr$   .c                    ^ [        U5       VVs0 s H  u  pEXT_M	     snnmUR                  SS5        [        X/UQ70 UD6nS[        S[        S[        4U4S jjnXvl        U$ s  snnf )NrenameTr,   keyr$   c                 h   > [        U[        5      (       a  TU   n[        [        U 5      U ]  U5      $ N)
isinstancer0   superr)   __getitem__)r,   r7   field_names_maps     r   getitemnamedtupledict.<locals>.getitem1   s0    c3!#&CT$Z2377r   )	enumerate
setdefaultr   r   r<   )	r1   r2   r3   r4   indatar>   r=   s	           @r   namedtupledictrE   )   su     )2+(>?(>qt(>?O
h%h=d=f=D8c 8 8 8
 K @s   A%c                   8    \ rS rSrSrS\S\S\\S4   4S jrSrg	)

BackendRep:   z
BackendRep is the handle that a Backend returns after preparing to execute
a model repeatedly. Users will then pass inputs to the run function of
BackendRep to retrieve the corresponding results.
inputsr4   r$   .c                     g)zAbstract function.r9   r   )r,   rI   r4   s      r   runBackendRep.runA   s    r   r   N)	r   r   r   r   r   r   r	   rK   r   r   r   r   rG   rG   :   s)    #  sCx r   rG   c                   H   \ rS rSrSr\ SS\S\S\S\	4S jj5       r
\ SS\S\S\S\\   4S jj5       r\ SS\S	\S\S\S\\S
4   4
S jj5       r\  SS\S	\S\S\\\\R&                  \\S
4   4         S\\\4   S\\\S
4      4S jj5       r\S\S\	4S j5       rSrg)BackendF   a  
Backend is the entity that will take an ONNX model with inputs,
perform a computation, and then return the output.

For one-off execution, users can use run_node and run_model to obtain results quickly.

For repeated execution, users should use prepare, in which the Backend
does all of the preparation work for executing the model repeatedly
(e.g., loading initializers), and returns a BackendRep handle.
modelr#   r4   r$   c                     g)NTr   clsrP   r#   r4   s       r   is_compatibleBackend.is_compatibleR   s    
 r   c                 B    [         R                  R                  U5        g r9   )onnxcheckercheck_modelrR   s       r   prepareBackend.prepareY   s    
 	  'r   rI   .c                 T    U R                   " X40 UD6nUc   eUR                  U5      $ r9   )rZ   rK   )rS   rP   rI   r#   r4   backends         r   	run_modelBackend.run_modela   s2     ++e6v6"""{{6""r   Nnodeoutputs_infoc                     SU;   aL  [         R                  " 5       n[        Ul        SUS   0Ul        [
        R                  R                  X5        g[
        R                  R                  U5        g)aX  Simple run one operator and return the results.
Args:
    outputs_info: a list of tuples, which contains the element type and
    shape of each output. First element of the tuple is the dtype, and
    the second element is the shape. More use case can be found in
    https://github.com/onnx/onnx/blob/main/onnx/backend/test/runner/__init__.py
opset_version N)	c_checkerCheckerContextr   
ir_versionopset_importsrW   rX   
check_node)rS   r`   rI   r#   ra   r4   special_contexts          r   run_nodeBackend.run_nodei   sb    " f$'668O)3O&-/1H,IO)LL##D:  LL##D)r   c                     g)zv
Checks whether the backend is compiled with particular device support.
In particular it's used in the testing suite.
Tr   )rS   r#   s     r   supports_deviceBackend.supports_device   s     r   r   )r   )r   N)r   r   r   r   r   classmethodr   r0   r   boolrT   r   rG   rZ   r	   r^   r   r   numpydtyper   r   rk   rn   r   r   r   r   rN   rN   F   sn   	 .3(+?B	  .3(+?B	*	  ;@##(+#58#LO#	sCx# # 
 PT  	
 xekk5c?.J(KLM sCx. 
%S/	" 4 S T  r   rN   )collectionsr   typingr   r   r   r   r   r	   r
   rr   onnx.checkerrW   onnx.onnx_cpp2py_export.checkeronnx_cpp2py_exportrX   re   r   r   r   r   r!   r0   rE   rG   rN   r   r   r   <module>ry      s    # F F F   3 3 2 2 - - (69EH	%S/"	 	D Dr   