o
    $Th                     @   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   `/home/air/segue/gemini/back/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   