a
    d                     @   s`  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eed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ej eeef dddZ!eddeddddZ"dS )    )GraphModule)AnyCallableDictListTupleTypeN)compatibility)default_matchingextract_attrs_for_loweringlift_lowering_attrs_to_nodesF)Zis_backward_compatible)nametarget_versionreturnc                 C   s   | S )zDefault matching method
     )r   r   r   r   d/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torch/fx/passes/param_fetch.pyr
      s    r
      weightbias)r   r   kernel_sizestridepaddingdilationgroupsZpadding_mode   )r   r   Zrunning_meanZrunning_varZeps)r   r   r   r   Zreturn_indicesZ	ceil_modeZinplacemodule_fetch_book)modr   c                 C   s   i }t | |d< t| tv rtt|  \}}}|| jk r^td| dt |  d| j d|D ]}t| ||| j||< qbntt |  d|S )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versionZparam_to_fetchZmatching_methodattrr   r   r   r   !   s    
$r   )	fx_moduler   c                 C   sX   t |  }| jjD ]>}|jdkrt||j trBt||j  qt	||j |_
qdS )zoRecursively traverse all `fx_module` nodes and fetch the module's attributes if the node is a leaf module.
    Zcall_moduleN)dictZnamed_modulesgraphnodesop
isinstancetargetr   r   r   r#   )r&   Z
submodulesnoder   r   r   r   7   s    
r   )#Ztorch.fx.graph_moduler   typingr   r   r   r   r   r   r   Ztorch.nnnnZtorch.fx._compatibilityr	   __all__strintr
   modulesZlinearZLinearconvZConv2dZ	batchnormZBatchNorm2dZpoolingZAdaptiveAvgPool2dZ	MaxPool2dZ
activationZReLUr   __annotations__Moduler   r   r   r   r   r   <module>   s,    	



.