o
    ei                     @   s`  U d dl mZ d dl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d	ed
edefd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j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dej!deeef fddZ"eddde
ddfddZ#dS )    )Callable)AnyN)compatibility)GraphModule)default_matchingextract_attrs_for_loweringlift_lowering_attrs_to_nodesF)is_backward_compatiblenametarget_versionreturnc                 C   s   | S )zDefault matching method )r
   r   r   r   e/var/www/addictedbytheproject.nl/epg/venv/lib/python3.10/site-packages/torch/fx/passes/param_fetch.pyr      s   r      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                 C   s   i }t | |d< t| tv rAtt|  \}}}|| jk r/td| dt |  d| j d|D ]}t| ||| j||< q1|S tt |  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attrr   r   r   r   :   s   
r   	fx_modulec                 C   sX   t |  }| jjD ]}|jdkr)t||j tr!t||j  q
t	||j |_
q
dS )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'   )r,   
submodulesnoder   r   r   r   U   s   
r   )$collections.abcr   typingr   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   r.   r#   tuplelist__annotations__Moduler   r   r   r   r   r   <module>   s@    	



.