
    Si!                        S SK Jr  S SKrS SKrS SKJrJr   " S S\R                  5      r\S:X  a  \R                  " 5         gg)    )annotationsN)checkerutilsc                  $    \ rS rSrS rSS jrSrg)TestFunction   c                  ^^ [         R                  " U5        U R                  [        UR                  5      [        U5      5        U H3  mU R                  [        UU4S jUR                   5       S 5      5        M5     g )Nc              3  p   >#    U  H+  nUR                   T:X  d  M  UR                  T:X  d  M'  Uv   M-     g 7f)N)namedomain).0ffunc_domainfunctions     V/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/test/function_test.py	<genexpr>4TestFunction._verify_function_set.<locals>.<genexpr>   s7      !:A66X- 23((k2I !:s   66	6)r   check_modelassertEquallen	functionsassertIsNotNonenext)selfextracted_modelfunction_setr   r   s      `@r   _verify_function_set!TestFunction._verify_function_set   si    O,_667\9JK$H  !0!:!:
 	 %    c                    Sn[         R                  R                  SS5      /n[         R                  R                  SS5      [         R                  R                  US5      /nSnSS/nS/n[         R                  R                  S	SS/S/5      /n[         R                  R	                  UUUUUU5      nS
n	S/n
S/n[         R                  R                  SS/S/5      /n[         R                  R	                  UU	U
UUU5      nSnSS/nS/n[         R                  R                  S
S/S/US9[         R                  R                  S
S/S/US9[         R                  R                  SSS/S/US9/n[         R                  R	                  UUUUUU5      n[         R                  R                  USS/S/US9n[         R                  R                  S	SS/S/5      n[         R                  R                  S	SS/S/5      n[         R                  R                  U	S/S/US9n[         R                  R                  SS/S/5      n[         R                  R                  S	SS/S/5      n[         R                  R                  USS/S/US9n[         R                  R                  USS/S/US9nSnSn[         R                  R                  SS5      [         R                  R                  SS5      /n[         R                  R                  SS/S9n[         R                  R                  UUUUUUUU/U[         R                  R                  SUS 9[         R                  R                  SUS 9[         R                  R                  SUS 9/[         R                  R                  SUS 9[         R                  R                  SUS 9[         R                  R                  SUS 9[         R                  R                  SUS 9/5      nUUS!XU/S".n [         R                  R                  " U40 U D6n![        R                  " U!5        [        R                  " U!5      R                  / S#QS/5      n"U R                  U"0 U5        [        R                  " U!5      R                  / S#QS/5      n#U R                  U#U1U5        [        R                  " U!5      R                  / S#QS/5      n$U R                  U$XIU1U5        [        R                  " U!5      R                  / S#QS/5      n%U R                  U%XIU1U5        [        R                  " U!5      R                  / S#Q/ S$Q5      n&U R                  U&XIU1U5        g%)&a  #   1. build a model with graph below. extract models with output combinations
#   2. validate extracted models' local functions
#
# model graph:
#      i0                    i1                 i2
#      |   __________________|__________________/_________
#      |  |                  |             |   /          |
#      |  |                  |             |  /           |
#   func_add        func_identity          add         identity
#    |  ___\___________\____________________|_________    |
#    | |    \           \                   |  _______|___|
#    | |     \           \                  | |       |   |
#    add     function_nested_identity_add   add     function_nested_identity_add
#     |                 |                    |              |
#     |                 |                    |              |
#   o_func_add      o_all_func0           o_no_func     o_all_func1
#
# where function_nested_identity_add is a function that is defined with functions:
#       a               b
#       |               |
#   func_identity   func_identity
#             \       /
#             func_add
#                |
#                c
#
local       func_addabcAddfunc_identityIdentityfunc_nested_identity_adda1)r   b1i0i1t0i2t2
o_func_addt1t3	o_no_funco_all_func0o_all_func1graph_with_imbedded_functions         )	elem_typeshape)r   
type_proto&test_extract_model_with_local_function)
ir_versionopset_importsproducer_namer   )r/   r0   r2   )r7   r4   r8   r9   N)onnxhelpermake_opsetid	make_nodemake_functionmake_tensor_type_proto
make_graphmake_value_info
make_modelr   r   r   	Extractorextract_modelr   )'r   r   func_opset_importsfunc_nested_opset_importsfunc_add_namefunc_add_inputsfunc_add_outputsfunc_add_nodesr%   func_identity_namefunc_identity_inputsfunc_identity_outputsfunc_identity_nodesr*   func_nested_identity_add_namefunc_nested_identity_add_inputs func_nested_identity_add_outputsfunc_nested_identity_add_nodesr,   node_func_add	node_add0	node_add1node_func_identitynode_identity	node_add2node_func_nested0node_func_nested1
graph_namerB   rC   tensor_type_protographmetamodelextracted_with_no_functionextracted_with_add_functionextracted_with_o_all_function0extracted_with_o_all_function1extracted_with_o_all_function2s'                                          r   rA   3TestFunction.test_extract_model_with_local_function   s   : "kk66r2>?KK$$R,KK$$[!4%
! #*5++//SzC5IJ;;,,
 - #u!$#{{44Z#NO11 !
 )C%+.*',/5(KK!!/C54&!UKK!!/C54&!UKK!!*tTlSE+!V*
&
 $(;;#<#<)+,*%$
  --D$<$ . 
 KK))%$vF	KK))%$~N	![[22{ 3 
 --j4&4&IKK))%$}M	 KK11)4LO	 2 
 !KK11)4LO	 2 
 5

KK$$R,KK$$Wa0
 !KK>>STRU>V&&"!!	 ++BS+T++BS+T++BS+T ++$1B ,  ++%2C ,  ++&3D ,  ++&3D , #
D %*E'3KL	
 &&u55E"%*__U%;%I%I&
" 	!!"<b+N&+ooe&<&J&J'
# 	!!'-+	
 */)?)M)M*
& 	!!*0MN	
 */)?)M)M*
& 	!!*0MN	
 */)?)M)ME*
& 	!!*0MN	
r    N)returnNone)__name__
__module____qualname____firstlineno__r   rA   __static_attributes__rq   r   r   r   r      s    B
r   r   __main__)

__future__r   unittestrE   r   r   TestCaser   rt   mainrq   r   r   <module>r~      s@    #   R
8$$ R
j zMMO r   