§
     ²Åj¡  ã                   ó8  — 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dS )é    )Ú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                 ó¨   •— t          ¦   «                              ¦   «          |                     ¦   «         D ]\  }}|                      ||¦  «         Œd S )N)ÚsuperÚ__init__ÚitemsÚ
add_module)ÚselfÚdÚkÚvÚ	__class__s       €úMC:\Projects\Historical\venv\Lib\site-packages\torch/fx/passes/utils/common.pyr   zHolderModule.__init__   sU   ø€ Ý‰Œ×ÒÑÔÐØ—G’G‘I”Ið 	"ð 	"‰DˆAˆqØ�OŠO˜A˜qÑ!Ô!Ð!Ð!ð	"ð 	"ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__)r   s   @r   r
   r
      sB   ø€ € € € € ðð ð
"ð "ð "ð "ð "ð "ð "ð "ð "r   r
   Ú r   ÚgmÚsubgraphÚ	comp_nameÚ
class_nameÚreturnc                 ó  — t          i ¦  «        }i }|j        D ]Ö}|j        dvrŒ|j        }t	          |t
          ¦  «        sJ ‚|                     d¦  «        }|}	| }
|dd…         D ]U}t          |	|¦  «        s#|	                     |t          i ¦  «        ¦  «         t          |	|¦  «        }	t          |
|¦  «        }
ŒV|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      s7  € õ6 ˜RÑ Ô €IØ02ÐØŒ^ð 1ð 1ˆØŒ4Ð2Ð2Ð2Øà”ˆÝ˜&¥#Ñ&Ô&Ð&Ð&Ð&Ø"ŸLšL¨Ñ-Ô-ÐØˆØˆà% c r cÔ*ð 	-ð 	-ˆDÝ˜4 Ñ&Ô&ð 8Ø—’ ¥l°2Ñ&6Ô&6Ñ7Ô7Ð7å˜4 Ñ&Ô&ˆDÝ˜g tÑ,Ô,ˆGˆGà*¨2Ô.ˆÝ˜G ^Ñ4Ô4ˆ	à/8Ð,CÐ,C¸6Ð,CÐ,CÐ! &Ñ)å��n iÑ0Ô0Ð0Ð0å�y (¨JÑ7Ô7Ð9RÐRÐRr   ÚleftÚrightc                 óv   — t          | dd¬¦  «        }|                     |¦  «        }t          |¦  «        dk    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   S   s:   € õ ˜d°ÈÐNÑNÔN€GØ�mŠm˜EÑ"Ô"€Gåˆw‰<Œ<˜!ÒÐr   N)r    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Ð 1Ð 1Ð 1Ð 1Ð 1Ø  Ð  Ð  Ð  Ð  Ð  Ø -Ð -Ð -Ð -Ð -Ð -Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø Ð Ð Ð Ð Ð ð HÐ
GÐ
G€ð € eÐ,Ñ,Ô,ð	"ð 	"ð 	"ð 	"ð 	"�6ñ 	"ô 	"ñ -Ô,ð	"ð € eÐ,Ñ,Ô,ð Ø#ð	4Sð 4SØð4Sàð4Sð ð4Sð ð	4Sð
 ˆ;˜˜S #˜XœÐ&Ô'ð4Sð 4Sð 4Sñ -Ô,ð4Sðn € eÐ,Ñ,Ô,ð˜ð  uð °ð ð ð ñ -Ô,ðð ð r   