o
    wiS
                     @  sD   d dl mZ d dlmZ d dlmZ erd dlZG dd deZdS )    )annotations)TYPE_CHECKING)OpRunNc                   @  s2   e Zd Zdd ZdddZ				ddd
dZdS )Ifc                 C  sF   t | || d| jvrtdd|vrtdd| jvr!tdd S )Nopsetsz&run_params must contains key 'opsets'.verbosez'run_params must contains key 'verbose'.existing_functionsz2run_params must contains key 'existing_functions'.)r   __init__
run_paramsKeyError)self	onnx_noder
    r   U/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/onnx/reference/ops/op_if.pyr	      s   

zIf.__init__returnboolc                 C  s   dS )zTells the runtime if this node needs the context
        (all the results produced so far) as it may silently access
        one of them (operator Loop).
        The default answer is `False`.
        Tr   )r   r   r   r   need_context   s   zIf.need_contextNcondnp.ndarray | np.bool_c                 C  s2  |j dkrtd| jjdt| d|d}|r4| d| | j||d}| d t|}d	}	n| d
| | j	||d}| d t|}d}	|sXt
d| jjdt|D ]7\}
}|d u r|	d	krk| jn| j}|j}dd |jjjD }t
d|
d|	d||
 dt| d| dq\| |S )N   zOperator If (zC) expects a single element as condition, but the size of 'cond' is .r   z  -- then> {%r})
attributesz
  -- then<thenz  -- else> {%r}z
  -- else<elsez) does not have any output.c                 S  s   g | ]}|j qS r   )name).0ir   r   r   
<listcomp>C   s    zIf._run.<locals>.<listcomp>zOutput z	 (branch=z, name=z) is None, available inputs=z, initializers=)size
ValueErrorr   r   lenitem_log_run_then_branchtuple_run_else_branchRuntimeError	enumeratethen_branchelse_branchoutput_namesobjgraphinitializersorted_check_and_fix_outputs)r   r   contextr)   r(   r   cond_outputsfinalbranchr   fbrnamesinitsr   r   r   _run!   sD   




zIf._run)r   r   )NNNN)r   r   )__name__
__module____qualname__r	   r   r9   r   r   r   r   r      s    
	r   )	
__future__r   typingr   onnx.reference.op_runr   numpynpr   r   r   r   r   <module>   s   