§
    1�Åj’  ã                  óè   — d dl mZ d dlmZ d dlmZmZmZ d dlZ	d dl
mc mZ d dl	mZmZmZ er
d dlmZ d dlZ G d„ d¦  «        Z G d	„ d
¦  «        Zdd„Z G d„ d¦  «        Z G d„ d¦  «        ZdS )é    )Úannotations)Ú
namedtuple)ÚTYPE_CHECKINGÚAnyÚNewTypeN)Ú
IR_VERSIONÚ
ModelProtoÚ	NodeProto)ÚSequencec                  ól   — e Zd ZU dZ ede¦  «        Z ed¦  «        Zded<    ed¦  «        Z	ded<   dS )Ú
DeviceTypezDescribes device type.Ú_Typer   ÚCPUé   ÚCUDAN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úintr   r   Ú__annotations__r   © ó    úBC:\Projects\Historical\venv\Lib\site-packages\onnx/backend/base.pyr   r      s[   € € € € € € Ø Ð àˆG�G˜SÑ!Ô!€EØ��q‘”€CÐÐÐÑØ�%˜‘(”(€DÐÐÐÑÐÐr   r   c                  ó   — e Zd ZdZdd„ZdS )	ÚDevicezyDescribes device type and device id
    syntax: device_type:device_id(optional)
    example: 'CPU', 'CUDA', 'CUDA:1'
    ÚdeviceÚstrÚreturnÚNonec                óÜ   — |                      d¦  «        }t          t          |d         ¦  «        | _        d| _        t          |¦  «        dk    rt          |d         ¦  «        | _        d S d S )Nú:r   r   )ÚsplitÚgetattrr   ÚtypeÚ	device_idÚlenr   )Úselfr   Úoptionss      r   Ú__init__zDevice.__init__!   s]   € Ø—,’,˜sÑ#Ô#ˆÝ�J¨°¬
Ñ3Ô3ˆŒ	ØˆŒÝˆw‰<Œ<˜!ÒÐÝ  ¨¤™_œ_ˆDŒNˆNˆNð Ðr   N)r   r   r   r    )r   r   r   r   r*   r   r   r   r   r      s2   € € € € € ðð ð
-ð -ð -ð -ð -ð -r   r   Útypenamer   Úfield_namesúSequence[str]Úargsr   Úkwargsr   útype[tuple[Any, ...]]c                ó¢   ‡— d„ t          |¦  «        D ¦   «         Š|                     dd¦  «         t          | |g|¢R i |¤Ž}d	ˆfd„}||_        |S )
Nc                ó   — i | ]\  }}||“Œ	S r   r   )Ú.0ÚiÚns      r   ú
<dictcomp>z"namedtupledict.<locals>.<dictcomp>,   s   € Ð?Ð?Ð?¡  1�q˜!Ð?Ð?Ð?r   ÚrenameTr(   r   Úkeyr   c                óž   •— t          |t          ¦  «        r‰|         }t          t          | ¦  «        | ¦  «                             |¦  «        S ©N)Ú
isinstancer   Úsuperr%   Ú__getitem__)r(   r8   Úfield_names_maps     €r   Úgetitemznamedtupledict.<locals>.getitem1   sC   ø€ Ý�c�3ÑÔð 	'Ø! #Ô&ˆCÝ•T˜$‘Z”Z Ñ&Ô&×2Ò2°3Ñ7Ô7Ð7r   )r(   r   r8   r   r   r   )Ú	enumerateÚ
setdefaultr   r=   )r+   r,   r.   r/   Údatar?   r>   s         @r   ÚnamedtupledictrC   )   sƒ   ø€ ð @Ð?­	°+Ñ(>Ô(>Ð?Ñ?Ô?€Oà
×Ò�h Ñ%Ô%Ð%Ý�h Ð=¨dÐ=Ð=Ð=°fÐ=Ð=€Dð8ð 8ð 8ð 8ð 8ð 8ð
 €DÔØ€Kr   c                  ó   — e Zd ZdZd	d„ZdS )
Ú
BackendRepzÐ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.
    Úinputsr   r/   r   útuple[Any, ...]c                ó   — dS )zAbstract function.r:   r   )r(   rF   r/   s      r   ÚrunzBackendRep.run@   s   € àˆwr   N)rF   r   r/   r   r   rG   )r   r   r   r   rI   r   r   r   rE   rE   :   s2   € € € € € ðð ð
ð ð ð ð ð r   rE   c                  óœ   — e Zd ZdZe	 ddd„¦   «         Ze	 ddd„¦   «         Ze	 ddd„¦   «         Ze	 	 ddd„¦   «         Zed d„¦   «         Z	dS )!ÚBackenda®  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.
    r   Úmodelr	   r   r   r/   r   r   Úboolc                ó   — dS )NTr   ©ÚclsrL   r   r/   s       r   Úis_compatiblezBackend.is_compatibleP   s	   € ð ˆtr   úBackendRep | Nonec                óD   — t           j                             |¦  «         d S r:   )ÚonnxÚcheckerÚcheck_modelrO   s       r   ÚpreparezBackend.prepareZ   s   € õ 	Œ× Ò  Ñ'Ô'Ð'Øˆtr   rF   rG   c                óR   —  | j         ||fi |¤Ž}|€J ‚|                     |¦  «        S r:   )rW   rI   )rP   rL   rF   r   r/   Úbackends         r   Ú	run_modelzBackend.run_modele   s=   € ð �#”+˜e VÐ6Ð6¨vÐ6Ð6ˆØÐ"Ð"Ð"Ø�{Š{˜6Ñ"Ô"Ð"r   NÚnoder
   Úoutputs_infoú4Sequence[tuple[numpy.dtype, tuple[int, ...]]] | Noneúdict[str, Any]útuple[Any, ...] | Nonec                óê   — d|v rOt          j        ¦   «         }t          |_        d|d         i|_        t
          j                             ||¦  «         nt
          j                             |¦  «         dS )a6  Simple run one operator and return the results.

        Args:
            node: The node proto.
            inputs: Inputs to the node.
            device: The device to run on.
            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
            kwargs: Other keyword arguments.
        Úopset_versionÚ N)Ú	c_checkerÚCheckerContextr   Ú
ir_versionÚopset_importsrT   rU   Ú
check_node)rP   r[   rF   r   r\   r/   Úspecial_contexts          r   Úrun_nodezBackend.run_nodem   sm   € ð0 ˜fÐ$Ð$Ý'Ô6Ñ8Ô8ˆOÝ)3ˆOÔ&Ø-/°¸Ô1HÐ,IˆOÔ)ÝŒL×#Ò# D¨/Ñ:Ô:Ð:Ð:åŒL×#Ò# DÑ)Ô)Ð)àˆtr   c                ó   — dS )z…Checks whether the backend is compiled with particular device support.
        In particular it's used in the testing suite.
        Tr   )rP   r   s     r   Úsupports_devicezBackend.supports_device�   s	   € ð
 ˆtr   )r   )rL   r	   r   r   r/   r   r   rM   )rL   r	   r   r   r/   r   r   rR   )
rL   r	   rF   r   r   r   r/   r   r   rG   )r   N)r[   r
   rF   r   r   r   r\   r]   r/   r^   r   r_   )r   r   r   rM   )
r   r   r   r   ÚclassmethodrQ   rW   rZ   ri   rk   r   r   r   rK   rK   E   sê   € € € € € ðð ð ð ðð ð ð ñ „[ðð ð ðð ð ð ñ „[ðð à;@ð#ð #ð #ð #ñ „[ð#ð ð
 ð ðð ð ð ñ „[ððB ðð ð ñ „[ðð ð r   rK   )
r+   r   r,   r-   r.   r   r/   r   r   r0   )Ú
__future__r   Úcollectionsr   Útypingr   r   r   Úonnx.checkerrT   Úonnx.onnx_cpp2py_export.checkerÚonnx_cpp2py_exportrU   rc   r   r	   r
   Úcollections.abcr   Únumpyr   r   rC   rE   rK   r   r   r   ú<module>ru      sy  ðð #Ð "Ð "Ð "Ð "Ð "à "Ð "Ð "Ð "Ð "Ð "Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2àð Ø(Ð(Ð(Ð(Ð(Ð(à€L€L€Lðð ð ð ð ñ ô ð ð-ð -ð -ð -ð -ñ -ô -ð -ðð ð ð ð"ð ð ð ð ñ ô ð ðOð Oð Oð Oð Oñ Oô Oð Oð Oð Or   