ó
    Eñiq  ã                   óä   • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  / SQr
\" SS9 " S	 S
\	5      5       r\" SS9  SS\S\S\S\S\\\\\4   4   4
S jj5       r\" SS9S\S\S\4S j5       rg)é    )Úcompatibility)ÚGraph)ÚGraphModule)ÚSubgraphMatcher)ÚModule)ÚHolderModuleÚlift_subgraph_as_moduleÚcompare_graphsF)Úis_backward_compatiblec                   ó,   ^ • \ rS rSrSrU 4S jrSrU =r$ )r   é   zm
HolderModule is used to copy all the attributes from original module to submodules
that uses the attributes
c                 óv   >• [         TU ]  5         UR                  5        H  u  p#U R                  X#5        M     g )N)ÚsuperÚ__init__ÚitemsÚ
add_module)ÚselfÚdÚkÚvÚ	__class__s       €ÚY/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/fx/passes/utils/common.pyr   ÚHolderModule.__init__   s,   ø€ Ü‰ÑÔØ—G‘G–I‰DˆAØ�O‰O˜AÖ!ò ó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      s   ø† ñ÷
"ó "r   r   ÚgmÚsubgraphÚ	comp_nameÚ
class_nameÚreturnc                 ó   • [        0 5      n0 nUR                   HÔ  nUR                  S;  a  M  UR                  n[	        U[
        5      (       d  [        S[        U5       35      eUR                  S5      nUn	U n
USS  HD  n[        X›5      (       d  U	R                  U[        0 5      5        [        X›5      n	[        X«5      n
MF     US   n[        X¬5      nU SU 3XW'   [        XœU5        MÖ     [        XAU5      U4$ )a[  
Create a GraphModule for subgraph, which copies the necessary attributes from the original parent graph_module.

Args:
    gm (GraphModule): parent graph module

    subgraph (Graph): a valid subgraph that contains copied nodes from the parent graph

    comp_name (str): name for the new component

    class_name (str): name for the submodule

)Úcall_moduleÚget_attrzExpected str target, got Ú.Néÿÿÿÿ)r   ÚnodesÚopÚtargetÚ
isinstanceÚstrÚAssertionErrorÚtypeÚsplitÚhasattrr   ÚgetattrÚsetattrr   )r#   r$   r%   r&   Ú	submoduleÚorig_to_split_fqn_mappingÚnr/   Útarget_name_partsÚcurrÚorig_gmÚnameÚleaf_node_nameÚ	leaf_nodes                 r   r	   r	      s  € ô6 ˜RÓ €IØ02ÐØ�^Œ^ˆØ�4‰4Ð2Ó2Ùà—‘ˆÜ˜&¤#×&Ñ&Ü Ð#<¼TÀ&»\¸NÐ!KÓLÐLØ"ŸL™L¨Ó-ÐØˆØˆà% c rÓ*ˆDÜ˜4×&Ñ&Ø—‘ ¤l°2Ó&6Ô7ä˜4Ó&ˆDÜ˜gÓ,ŠGñ +ð +¨2Ñ.ˆÜ˜GÓ4ˆ	à/8¨k¸¸6¸(Ð,CÐ!Ñ)ä� iÖ0ñ/ ô2 �y¨JÓ7Ð9RÐRÐRr   ÚleftÚrightc                 óV   • [        U SSS9nUR                  U5      n[        U5      S:„  $ )zß
Return True if two graphs are identical, i.e they
    - have the same number of outputs in the same order
    - have the same number of inputs in the same order
    - have the same set of nodes, and identical connectivity
T)Úmatch_outputÚmatch_placeholderr   )r   ÚmatchÚlen)rA   rB   ÚmatcherÚmatchess       r   r
   r
   S   s/   € ô ˜d°ÈÑN€GØ�m‰m˜EÓ"€Gäˆw‹<˜!ÑÐr   N)Ú r   )Útorch.fx._compatibilityr   Útorch.fx.graphr   Útorch.fx.graph_moduler   Ú#torch.fx.passes.utils.matcher_utilsr   Útorch.nnr   Ú__all__r   r1   ÚtupleÚdictr	   Úboolr
   r   r   r   Ú<module>rT      sÕ   ðõ 2Ý  Ý -Ý ?Ý ò H€ñ  eÑ,ô	"�6ó 	"ó -ð	"ñ  eÑ,ð Ø#ñ	5SØð5Sàð5Sð ð5Sð ð	5Sð
 ˆ;˜˜S #˜X™Ð&Ñ'ô5Só -ð5Sñp  eÑ,ð˜ð  uð °ó ó -ñr   