
    sg                     Z   U d dl mZ d dlmZmZmZmZmZmZ d dl	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.                  j0                  dg defe	j                  j$                  j2                  j4                  dg efe	j                  j$                  j2                  j6                  dg defe	j                  j$                  j8                  j:                  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)    )GraphModule)AnyCallableDictListTupleTypeN)compatibility)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     N/var/www/html/venv/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   !   s    
 *,!&!4vCy%%3DT#Y3O0S\\!!1'.X[I\H]]fgjgsgsft uI  I J J # 	YD'.sOD#,,4W'Xt$	Y  ennS12 3E E F 	Fr   	fx_modulec                 2   t        | j                               }| j                  j                  D ]e  }|j                  dk(  st        ||j                     t              rt        ||j                            It        ||j                           |_
        g y)zoRecursively 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/   )r4   
submodulesnodes      r   r   r   7   s{     i--/0J%% ^77m#*T[[1;?,Z-DE*DZPTP[P[E\*]'^r   )#torch.fx.graph_moduler   typingr   r   r   r   r   r	   r)   torch.nnnntorch.fx._compatibilityr
   __all__strintr   moduleslinearLinearconvConv2d	batchnormBatchNorm2dpoolingAdaptiveAvgPool2d	MaxPool2d
activationReLUr&   __annotations__Moduler   r   r   r   r   <module>rV      s   - 9 9   1
\ e,3    - 
HH""Q6(:<L$M	HH  	giy# 
HH**Q0hjz,{	HH..B8H0I	HH&&	Z\l) 
HH$$q9+7G&HS 4eCcHc3Z_4M$MNNO  e,BII $sCx.  -* e,
^K 
^D 
^ -
^r   