o
    °ƒðj¼  ã                   @   s0   d Z ddlmZ ddlmZ G dd„ deƒZdS )z 
Implements ONNX's backend API.
é    )Ú
BackendRep)Ú
RunOptionsc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚOnnxRuntimeBackendRepzr
    Computes the prediction for a pipeline converted into
    an :class:`onnxruntime.InferenceSession` node.
    c                 C   s
   || _ dS )zG
        :param session: :class:`onnxruntime.InferenceSession`
        N)Ú_session)ÚselfÚsession© r   ú¡/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/onnxruntime/backend/backend_rep.pyÚ__init__   s   
zOnnxRuntimeBackendRep.__init__c           
         sî   t ƒ }| ¡ D ]\}}t||ƒrt|||ƒ qt|tƒrSi }t| j ¡ ƒD ]\}}|| ||j	< q%| j 
d||¡‰ tˆ tƒr@ˆ S dd„ | j ¡ D ƒ}	‡ fdd„|	D ƒS | j ¡ }t|ƒdkrhtdt|ƒ› d�ƒ‚|d j	|i}| j 
d||¡S )	z`
        Computes the prediction.
        See :meth:`onnxruntime.InferenceSession.run`.
        Nc                 S   s   g | ]}|j ‘qS r   )Úname)Ú.0Úor   r   r	   Ú
<listcomp>-   s    z-OnnxRuntimeBackendRep.run.<locals>.<listcomp>c                    s   g | ]}ˆ | ‘qS r   r   )r   r   ©Úoutsr   r	   r   .   s    é   zModel expect z inputsr   )r   ÚitemsÚhasattrÚsetattrÚ
isinstanceÚlistÚ	enumerater   Ú
get_inputsr   ÚrunÚget_outputsÚlenÚRuntimeError)
r   ÚinputsÚkwargsÚoptionsÚkÚvÚinpsÚiÚinpÚoutput_namesr   r   r	   r      s&   
€


zOnnxRuntimeBackendRep.runN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   r	   r      s    r   N)r)   Úonnx.backend.baser   Úonnxruntimer   r   r   r   r   r	   Ú<module>   s   