
    Vh                     J   U d dl mZmZ d dlZd dlmZ d dlmZ d dlm	Z	 g dZ
 ed      ded	ed
efd       Zej
                  j                  j                  j                   dddgefej
                  j                  j"                  j$                  dg defej
                  j                  j&                  j(                  dg defej
                  j                  j*                  j,                  dg efej
                  j                  j*                  j.                  dg defej
                  j                  j0                  j2                  ddgefiZeeeeee   eeegef   f   f   ed<    ed      dej@                  d
eeef   fd       Z! ed      de	d
dfd       Z"y)    )AnyCallableN)compatibility)GraphModule)default_matchingextract_attrs_for_loweringlift_lowering_attrs_to_nodesF)is_backward_compatiblenametarget_versionreturnc                     | S )zDefault matching method )r   r   s     K/home/dcms/DCMS/lib/python3.12/site-packages/torch/fx/passes/param_fetch.pyr   r      s	     K       weightbias)r   r   kernel_sizestridepaddingdilationgroupspadding_mode   )r   r   running_meanrunning_vareps)r   r   r   r   return_indices	ceil_modeinplacemodule_fetch_bookmodc           	         i }t        j                  |       |d<   t        |       t        v rt        t        |          \  }}}|| j                  k  r2t        d| dt        j                  |        d| j                   d      |D ]"  }t        |  ||| j                              ||<   $ |S t        t        j                  |        d      )zIf `mod` is in `module_fetch_book`, fetch the mod's attributes that in the `module_fetch_book`
    after checking module's version is compatible with the `module_fetch_book`.
    r   zFetcher version z try to fetch z	 version zl, please upgrade the module_fetch_book, open an issue and @842974287 or report a bug to AIACC team directly.z is not in the module_fetch_book yet, please add it to the module_fetch_book, open an issue and @842974287 or report a bug to AIACC team directly.)torchtypenametyper"   _versionRuntimeErrorgetattr)r#   attrs_for_loweringversionparam_to_fetchmatching_methodattrs         r   r   r   9   s    
 *,!&!4vCy%%3DT#Y3O0S\\!"7)>%..:M9NiX[XdXdWe f: : 
 # 	YD'.sOD#,,4W'Xt$	Y  ~~c"# $6 6
 	
r   	fx_modulec                 2   t        | j                               }| j                  j                  D ]e  }|j                  dk(  st        ||j                     t              rt        ||j                            It        ||j                           |_
        g y)zjRecursively traverse all `fx_module` nodes and fetch the module's attributes if the node is a leaf module.call_moduleN)dictnamed_modulesgraphnodesop
isinstancetargetr   r	   r   r+   )r0   
submodulesnodes      r   r	   r	   T   sy     i--/0J%% 77m#*T[[1;?,Z-DE*Dt{{++'r   )#typingr   r   r%   torch.nnnntorch.fx._compatibilityr   torch.fx.graph_moduler   __all__strintr   moduleslinearLinearconvConv2d	batchnormBatchNorm2dpoolingAdaptiveAvgPool2d	MaxPool2d
activationReLUr"   r3   r'   tuplelist__annotations__Moduler   r	   r   r   r   <module>rT      s         1 - e,3    - 
HH""Q6(:<L$M	HH  			
 	# 
HH**	@-
 
HH..B8H0I	HH&&	W)
 
HH$$q9+7G&H7S 4eCcHc3Z_4M$MNNO > e,BII $sCx.  -4 e,K D  -r   