Ë
    P/æjC  ã                   ó   — d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ g d¢Z ed¬	«       G d
„ de«      «       Z ed¬	«      	 	 ddededededeeeeef   f   f
d„«       Z ed¬	«      dededefd„«       Zy)é    )ÚDictÚTuple)Úcompatibility)ÚGraph)ÚGraphModule)ÚSubgraphMatcher)ÚModule)ÚHolderModuleÚlift_subgraph_as_moduleÚcompare_graphsF)Úis_backward_compatiblec                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )r
   zy
    HolderModule is used to copy all the attributes from original module to submodules
    that uses the attributes
    c                 óv   •— t         ‰| �  «        |j                  «       D ]  \  }}| j                  ||«       Œ y )N)ÚsuperÚ__init__ÚitemsÚ
add_module)ÚselfÚdÚkÚvÚ	__class__s       €ú_/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torch/fx/passes/utils/common.pyr   zHolderModule.__init__   s5   ø€ Ü‰ÑÔØ—G‘G“Iò 	"‰DˆAˆqØ�O‰O˜A˜qÕ!ñ	"ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__)r   s   @r   r
   r
      s   ø„ ñ÷
"ð "r   r
   ÚgmÚsubgraphÚ	comp_nameÚ
class_nameÚreturnc                 óÂ  — t        i «      }i }|j                  D ]µ  }|j                  dvrŒ|j                  }t	        |t
        «      sJ ‚|j                  d«      }|}	| }
|dd D ]A  }t        |	|«      s|	j                  |t        i «      «       t        |	|«      }	t        |
|«      }
ŒC |d   }t        |
|«      }|› d|› �||<   t        |	||«       Œ· t        |||«      |fS )aw  
    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_attrú.Néÿÿÿÿ)r
   ÚnodesÚopÚtargetÚ
isinstanceÚstrÚ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ÐØ�^‰^ò 1ˆØ�4‰4Ð2Ñ2Øà—‘ˆÜ˜&¤#Ô&Ð&Ð&Ø"ŸL™L¨Ó-ÐØˆØˆà% c rÐ*ò 	-ˆDÜ˜4 Ô&Ø—‘ ¤l°2Ó&6Ô7ä˜4 Ó&ˆDÜ˜g tÓ,‰Gð	-ð +¨2Ñ.ˆÜ˜G ^Ó4ˆ	à/8¨k¸¸6¸(Ð,CÐ! &Ñ)ä��n iÕ0ð-1ô0 �y (¨JÓ7Ð9RÐRÐRr   ÚleftÚrightc                 ó\   — t        | dd¬«      }|j                  |«      }t        |«      dkD  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)r<   r=   ÚmatcherÚmatchess       r   r   r   T   s/   € ô ˜d°ÈÔN€GØ�m‰m˜EÓ"€Gäˆw‹<˜!ÑÐr   N)Ú r   )Útypingr   r   Útorch.fx._compatibilityr   Útorch.fx.graphr   Útorch.fx.graph_moduler   Ú#torch.fx.passes.utils.matcher_utilsr   Útorch.nnr	   Ú__all__r
   r.   r   Úboolr   © r   r   ú<module>rO      sÖ   ðç å 1Ý  å -Ý ?Ý ò H€ñ  eÔ,ô	"�6ó 	"ó -ð	"ñ  eÔ,ð Ø#ñ	4SØð4Sàð4Sð ð4Sð ð	4Sð
 ˆ;˜˜S #˜X™Ð&Ñ'ò4Só -ð4Sñn  eÔ,ð˜ð  uð °ò ó -ñr   