
    Yj	                     X    d Z ddlmZ ddlmZ  eh d          Z G d de          ZdS )z 
Implements ONNX's backend API.
    )
BackendRep)
RunOptions>   logidlog_severity_levellog_verbosity_levelonly_execute_path_to_fetchesc                       e Zd ZdZd Zd ZdS )OnnxRuntimeBackendRepz
    Wraps an :class:`onnxruntime.InferenceSession` to implement ONNX's
    :class:`onnx.backend.base.BackendRep` interface for running predictions.
    c                     || _         dS )zG
        :param session: :class:`onnxruntime.InferenceSession`
        N)_session)selfsessions     \/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/onnxruntime/backend/backend_rep.py__init__zOnnxRuntimeBackendRep.__init__    s          c                 z  
 t                      }|                                D ]j\  }}|t          v rt          |||            t	          ||          r:t          d| dd                    t          t                                         kt          |t                    ri }t          | j                                                  D ]\  }}||         ||j        <   | j                            d||          
t          
t                    r
S d | j                                        D             }	
fd|	D             S | j                                        }t!          |          dk    r t          dt!          |           d	          |d
         j        |i}| j                            d||          S )a  
        Computes the prediction.
        See :meth:`onnxruntime.InferenceSession.run`.

        :param inputs: a list of input arrays (one per model input) or a single
            array when the model has exactly one input
        :param kwargs: only a safe subset of :class:`onnxruntime.RunOptions` attributes are
            accepted; see ``_ALLOWED_RUN_OPTIONS`` for the list
        :return: list of output arrays
        zRunOptions attribute 'z<' is not permitted via the backend API. Allowed attributes: z, Nc                     g | ]	}|j         
S  )name).0os     r   
<listcomp>z-OnnxRuntimeBackendRep.run.<locals>.<listcomp>E   s    LLL1LLLr   c                      g | ]
}|         S r   r   )r   r   outss     r   r   z-OnnxRuntimeBackendRep.run.<locals>.<listcomp>F   s    <<<tT
<<<r      zModel expect z inputsr   )r   items_ALLOWED_RUN_OPTIONSsetattrhasattrRuntimeErrorjoinsorted
isinstancelist	enumerater   
get_inputsr   runget_outputslen)r   inputskwargsoptionskvinpsiinpoutput_namesr   s             @r   r'   zOnnxRuntimeBackendRep.run&   s    ,,LLNN 	 	DAq(((A&&&&!$$ "UQ U U+/99V<P5Q5Q+R+RU U   fd## 	:D#DM$<$<$>$>?? + +3!'SX=$$T499D$%% =LL0I0I0K0KLLL<<<<|<<<<-**,,C3xx1}}"#D3s88#D#D#DEEEFK(D=$$T4999r   N)__name__
__module____qualname____doc__r   r'   r   r   r   r
   r
      s<         
     &: &: &: &: &:r   r
   N)r6   onnx.backend.baser   onnxruntimer   	frozensetr   r
   r   r   r   <module>r:      s   
  ) ( ( ( ( ( " " " " " "
 !y    2: 2: 2: 2: 2:J 2: 2: 2: 2: 2:r   