§
    ŠŠtjš  ã                   ó(  — 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 )é    )Úcompatibility)ÚGraph)ÚGraphModule)ÚSubgraphMatcher)ÚModule)ÚHolderModuleÚlift_subgraph_as_moduleÚcompare_graphsF)Úis_backward_compatiblec                   óB   ‡ — e Zd ZdZdeeedz  f         ddfˆ 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
    ÚdNÚreturnc                 ó¨   •— t          ¦   «                              ¦   «          |                     ¦   «         D ]\  }}|                      ||¦  «         Œd S )N)ÚsuperÚ__init__ÚitemsÚ
add_module)Úselfr   ÚkÚvÚ	__class__s       €úZ/var/www/html/CA-Chatbot/venv/lib/python3.11/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__ÚdictÚstrr   r   Ú__classcell__)r   s   @r   r   r      sc   ø€ € € € € ðð ð
"˜$˜s F¨T¡MÐ1Ô2ð "°tð "ð "ð "ð "ð "ð "ð "ð "ð "ð "r   r   Ú r   ÚgmÚsubgraphÚ	comp_nameÚ
class_namer   c                 ó@  — t          i ¦  «        }i }|j        D ]ó}|j        dvrŒ|j        }t	          |t
          ¦  «        st          dt          |¦  «        › �¦  «        ‚|                     d¦  «        }|}	| }
|dd…         D ]U}t          |	|¦  «        s#|	 
                    |t          i ¦  «        ¦  «         t          |	|¦  «        }	t          |
|¦  «        }
ŒV|d         }t          |
|¦  «        }|› d|› �||<   t          |	||¦  «         Œôt          |||¦  «        |fS )a™  
    Create a GraphModule for subgraph, which copies the necessary attributes
    from the original parent graph_module.

    Args:
        gm (GraphModule): parent graph module

        subgraph (:class:`torch.fx.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Ú
isinstancer   Ú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	      sQ  € õ: ˜RÑ Ô €IØ02ÐØŒ^ð 1ð 1ˆØŒ4Ð2Ð2Ð2Øà”ˆÝ˜&¥#Ñ&Ô&ð 	MÝ Ð!K½TÀ&¹\¼\Ð!KÐ!KÑLÔLÐLØ"Ÿ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   )Útorch.fx._compatibilityr   Útorch.fx.graphr   Útorch.fx.graph_moduler   Ú#torch.fx.passes.utils.matcher_utilsr   Útorch.nnr   Ú__all__r   r   Útupler   r	   Úboolr
   © r   r   ú<module>rP      s„  ðØ 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø  Ð  Ð  Ð  Ð  Ð  Ø -Ð -Ð -Ð -Ð -Ð -Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø Ð Ð Ð Ð Ð ð HÐ
GÐ
G€ð € eÐ,Ñ,Ô,ð	"ð 	"ð 	"ð 	"ð 	"�6ñ 	"ô 	"ñ -Ô,ð	"ð € eÐ,Ñ,Ô,ð Ø#ð	7Sð 7SØð7Sàð7Sð ð7Sð ð	7Sð
 ˆ;˜˜S #˜XœÐ&Ô'ð7Sð 7Sð 7Sñ -Ô,ð7Sðt € eÐ,Ñ,Ô,ð˜ð  uð °ð ð ð ñ -Ô,ðð ð r   