
    i                         % S SK Jr  S SKJrJrJrJrJr  S SK	r	S SK
Jr  \\	R                  \\\\\\	R$                  \	R&                  \	R(                  \	R*                  S4   r0 r\\\\4   \\	R0                  R2                  \	R0                  R4                  4   4   \S'   0 r\\\\4   \4   \S'   S\	R:                  R<                  S\	R:                  R>                  S	\S
\\\	R@                  RB                  \	R:                  R>                  4   4S jr"S\	R:                  R<                  S\#\\$\   4   S
\\\\	R:                  R<                  \	R:                  R>                  4      4S jr%S\	R:                  R<                  S
\\\\	R:                  R<                  \	R:                  R>                  4      4S jr&S\	R:                  R<                  S
\\\\	R:                  R<                  \	R:                  R>                  4      4S jr'S\	R:                  R<                  S
\\\\	R:                  R<                  \	R:                  R>                  4      4S jr(S\	R:                  R<                  S\\	R:                  R>                  /S4   S
S4S jr)g)    )FunctionType)CallableDictListTupleUnionN)HigherOrderOperator_cache_ops_dict_cache_fake_ops_dictgraph_modulenode	arg_indexreturnc                 .   UR                   U   n[        U[        R                  R                  5      (       d   eUR
                  S:X  d   e[        UR                  [        5      (       d   eU R                  UR                  5      nUR                  XA4$ )Nget_attr)	args
isinstancetorchfxNodeoptargetstrget_submodule)r   r   r   submod_node	submodules        [/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/executorch/exir/graph_module.py_get_submoduler   '   s     ))I&Kk588==1111>>Z'''k((#....**;+=+=>Iy..    op_to_submodule_arg_indexc           
          / nU R                   R                   HU  nUR                  S:w  a  M  U H:  nUR                  ULa  M  X    H  nUR	                  [        XU5      5        M      M<     MW     U$ )a@  
Returns a list of submodules used for control flow operations
that are in the given toplevel graph (does not look
into submodules). Specifically, the returned value is a list containing
tuples of (name of the submodule that's stored in the graph module, the
submodule itself, and the fx node that uses this submodule).
call_function)graphnodesr   r   appendr   )r   r    control_flow_submodulesr   r   is         r   _get_control_flow_submodulesr(   3   ss     !""((77o%+B{{"$.2'..~lRS/TU 3 ,	 ) #"r   c           	          [        U [        R                  R                  R                  SS/[        R                  R                  R
                  S/[        R                  R                  R                  S/05      $ )ag  
Returns a list of submodules used for control flow operations
(torch.ops.higher_order.cond/map/scan) that are in the given toplevel graph (does not look
into submodules). Specifically, the returned value is a list containing
tuples of (name of the submodule that's stored in the graph module, the
submodule itself, and the fx node that uses this submodule).
      r   )r(   r   opshigher_ordercondmap_implscanr   s    r   get_control_flow_submodulesr2   L   s`     (II""''!QII""++aSII""''!	
 r   c                     [        U [        R                  R                  R                  SS/[        R                  R                  R
                  SS/05      $ )ai  
Returns a list of submodules used for control flow operations
(torch.ops.higher_order.cond/while_loop) that are in the given toplevel graph (does not look
into submodules). Specifically, the returned value is a list containing
tuples of (name of the submodule that's stored in the graph module, the
submodule itself, and the fx node that uses this submodule).
r*   r+   r   )r(   r   r,   r-   r.   
while_loopr1   s    r   get_cond_while_submodulesr5   `   sK     (II""''!QII""--1v	
 r   c                 d    [        U [        R                  R                  R                  S/05      $ )a  
Returns a list of submodules used for scan operations
(torch.ops.higher_order.scan) that are in the given toplevel graph (does not look
into submodules). Specifically, the returned value is a list containing
tuples of (name of the submodule that's stored in the graph module, the
submodule itself, and the fx node that uses this submodule).

For scan, the combine_fn submodule is at argument index 0.
The scan operator signature is: scan(combine_fn, init, xs, additional_inputs)
r   )r(   r   r,   r-   r0   r1   s    r   get_scan_submodulesr7   s   s0     (II""''!	
 r   gmnode_opc                 ~   [        U [        R                  R                  5      (       d   S[	        U 5       35       eU /nU(       aq  UR                  S5      nUR                  R                   H  nU" U5        M     [        U5       VVs/ s H  u  pVnUPM
     nnnUR                  U5        U(       a  Mp  ggs  snnf )z9Traverse the graph module and apply node_op to each node.zExpected GraphModule, got r   N)
r   r   r   GraphModuletypepopr#   r$   r2   extend)r8   r9   queuecurrent_graph_moduler   _r   r&   s           r   bfs_trace_with_node_processrB      s    
 b%((..//X3MdSUhZ1XX/DE
$yy|(..44DDM 5
 $??S#T#
#Ta #T 	  #
 	,- %
#
s   B9)*typesr   functiontypingr   r   r   r   r   r   
torch._opsr	   Tensorr   intfloatboolcomplexdtypedevicememory_formatlayout	LeafValuer
   _ops
OpOverloadOpOverloadPacket__annotations__r   r   r;   r   nnModuler   dictlistr(   r2   r5   r7   rB    r   r   <module>rZ      sp   + 5 5  * 	LL		KK	LL		LL

	$  	#s(OU5::00%**2M2MMNN  9; d5c?H45 :	/((&&	/.3hhmm	/HK	/
3./	/#((&&##$7c$BC# 
%UXX))588==8
9:#2((&&	%UXX))588==8
9:(((&&	%UXX))588==8
9:&((&&	%UXX))588==8
9:*..'/0E'F.	.r   