
    bIgi                    T    d dl mZ d dlZd dlZd dlmZ d dlmZ d Z	 G d de      Z
y)    )annotationsN)Base)expectc                    |rg S | S )N )xconds     [/var/www/html/answerous/venv/lib/python3.12/site-packages/onnx/backend/test/case/node/if.pycompute_if_outputsr      s    	    c                  B    e Zd Zedd       Zedd       Zedd       Zy)Ifc            
     Z   t         j                  j                  dt         j                  j                  dg      } t         j                  j                  dt         j                  j                  dg      }t        j                  g d      j                  t
        j                        }t        j                  g d      j                  t
        j                        }t         j                  j                  dg dgt         j                  j                  |            }t         j                  j                  dg dgt         j                  j                  |            }t         j                  j                  |gdg | g      }t         j                  j                  |gd	g |g      }t         j                  j                  d
dgdg||      }t        j                  d      j                  t              }	|	r|n|}
t        ||	g|
gdt         j                  j                  dd      g       y )Nthen_out   else_out            r   r   r   r   r   r   Constantinputsoutputsvalue	then_body	else_bodyr   r	   resr   r   then_branchelse_branchr   test_if    r   r   nameopset_imports)onnxhelpermake_tensor_value_infoTensorProtoFLOATnparrayastypefloat32	make_nodenumpy_helper
from_array
make_graphboolr   make_opsetid)r   r   r   ythen_const_nodeelse_const_noder   r   if_noder	   r    s              r
   	export_ifzIf.export_if   s   
 ;;55((..
 ;;55((..
 HH_%,,RZZ8HH_%,,RZZ8++//L##..q1	 0 
 ++//L##..q1	 0 
 KK**{B

	 KK**{B

	 ++''8G!! ( 
 xx{!!$'aQ6E;;33B;<	
r   c            
        t         j                  j                  dt         j                  j                  dg      } t         j                  j                  dt         j                  j                  dg      }t        j                  g d      j                  t
        j                        g}t        j                  g d      j                  t
        j                        g}t         j                  j                  dg dgt         j                  j                  |d	         
      }t         j                  j                  ddgdg      }t         j                  j                  dg dgt         j                  j                  |d	         
      }t         j                  j                  ddgdg      }t         j                  j                  ||gdg | g      }t         j                  j                  ||gdg |g      }	t         j                  j                  ddgdg||	      }
t        j                  d      j                  t              }|r|n|}t        |
|g|gdt         j                  j                  dd      g       y )Nr   r   shaper   r   r   r   r   r   r   SequenceConstructr   r   r9   r   r   r   r	   r    r!   r   test_if_seqr%      r'   )r*   r+   make_tensor_sequence_value_infor-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r   r8   )r   r   r   r9   r:   then_seq_noder;   else_seq_noder   r   r<   r	   r    s                r
   export_if_seqzIf.export_if_seqL   s6   
 ;;>>((..qc ? 
 ;;>>((..qc ? 
 XXo&--bjj9:XXo&--bjj9:++//E##..qt4	 0 
 --
| . 
 ++//E##..qt4	 0 
 --
| . 
 KK**m,k2z
	 KK**m,k2z
	 ++''8G!! ( 
 xx{!!$'aQ6E;;33B;<	
r   c                    t         j                  j                  t         j                  j                  dg      } t         j                  j                  |       }t         j                  j                  t         j                  j                  dg      }t         j                  j                  |      }t         j                  j                  |      }t         j                  j                  d|      }t         j                  j                  t         j                  j                  dg      }t         j                  j                  |      }t         j                  j                  |      }t         j                  j                  d|      }	t        j                  g d      j                  t        j                        g}
t        j                  d      j                  t              }t        |
|      }t         j                  j                  dg dg|      }t         j                  j                  |gd	g |g      }t         j                  j                  d
g dgt         j                   j#                  |
d               }t         j                  j                  ddgdg      }t         j                  j                  ddgdg      }t         j                  j                  |||gdg |	g      }t         j                  j                  ddgdg||      }t%        ||g|gd|gt         j                  j'                  dd      g       y )Nr   r?   optional_emptyelse_optr   r   Optional)r   r   typer   r   r   r   rA   else_seqrB   r   r   r	   sequencer!   test_if_optr%      )r   r   r(   output_type_protosr)   )r*   r+   make_tensor_type_protor-   r.   make_sequence_type_protomake_optional_type_protomake_value_infor/   r0   r1   r2   r7   r   r3   r6   r4   r5   r   r8   )	ten_in_tp	seq_in_tpthen_out_tensor_tpthen_out_seq_tpthen_out_opt_tpr   else_out_tensor_tpelse_out_seq_tpelse_out_opt_tpr   r   r	   r    opt_empty_inr   r;   rG   else_optional_seq_noder   r<   s                       r
   export_if_optionalzIf.export_if_optional   s    KK66""1# 7 
	 KK88C	![[??""1# @ 
 ++>>?QR++>>O;;../?Q![[??""1# @ 
 ++>>?QR++>>O;;..z?KXXo&--bjj9:xx{!!$' D){{,,r,<+=I - 
 KK**L>;XJW	++//E##..qt4	 0 
 --
| . 
 "&!6!6
|j\ "7 "
 KK**m-CDJ	
	 ++''8L!! ( 
 	6E /0;;33B;<	
r   N)returnNone)__name__
__module____qualname__staticmethodr=   rH   ra   r   r   r
   r   r      s@    4
 4
l <
 <
| G
 G
r   r   )
__future__r   numpyr/   r*   onnx.backend.test.case.baser   onnx.backend.test.case.noder   r   r   r   r   r
   <module>rl      s)    #   , .
 
r   