
    
Ng	                    B    d dl mZ d dlZd dlmZ  G d de          ZdS )    )annotationsN)OpRunc                  .    e Zd Zd Zd	dZ	 	 	 	 d
ddZdS )Ifc                    t          j        | ||           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   s      T/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/reference/ops/op_if.pyr   zIf.__init__   sp    tY
3334?**CDDDJ&&DEEEt66OPPP 76    returnboolc                    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`.
        T )r   s    r   need_contextzIf.need_context   s	     tr   Ncondnp.ndarray | np.bool_c                T   |j         dk    r-t          d| j        j        dt	          |           d          |                    d          }|rT|                     d|           |                     ||          }|                     d           t          |          }d	}	nS|                     d
|           | 	                    ||          }|                     d           t          |          }d}	|st          d| j        j        d          t          |          D ]o\  }
}|h|	d	k    r| j        n| j        }|j        }d |j        j        j        D             }t          d|
d|	d||
         dt%          |           d| d          p|                     |          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                    g | ]	}|j         
S r   )name).0is     r   
<listcomp>zIf._run.<locals>.<listcomp>@   s    BBBABBBr   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initss                  r   _runzIf._run   s2    9>> G 3  G  Gz}  C  {D  {D  G  G  G   		! 	II'111++G
+KKGIIl###'NNEFFII'111++G
+KKGIIl###'NNEF 	R 3RRR   e$$ 	 	DAqy)/6)9)9T%%t?OBB)ABBB"Qa Q QF Q QU1X Q Q(.wQ QHMQ Q Q  	  **5111r   )r   r   )NNNN)r   r   )__name__
__module____qualname__r   r   r?   r   r   r   r   r      sa        Q Q Q    '2 '2 '2 '2 '2 '2 '2r   r   )
__future__r   numpynponnx.reference.op_runr   r   r   r   r   <module>rG      sk   
 # " " " " "     ' ' ' ' ' '92 92 92 92 92 92 92 92 92 92r   