o
    *ѹg2                     @   sV  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlZd dl Zd dl!Zd dl"Zddl#m$Z$ ddl%m&Z&m'Z'm(Z( 	 g eeeeeeee	e
eeeeeeeeeeeeeeeeeeeee eR Z)dZ*dd Z+d	ej,fd
dZ-h dZ.h dZ/ej01 re/h dO Z/h dZ2ej01 re23d e23d e	4ddd Z5e	4ddd Z6e	4ddd Z7ddgdd e)D  Z8e9da:e
;d< Z<h dZ=e9dd >e?ej@e= d!ZAd"d# ZBd$eCfd%d&Z3ejDG d'd( d(ZEd8d*d+ZFejDG d,d- d-ZG	 d8d.d/ZHd8d0d1ZIe*D ]ZJe3eJ qeB  d2d3 ZKe	4dd4d5 ZLd6d7 ZMdS )9    N)Optional   )getfile)NestedUserFunctionVariableUserFunctionVariableUserMethodVariable)Z	functorchZ
fx2trt_ossZnetworkxZnumpyZ	omegaconfZonnxZonnxruntimeZonnx_tfZpandasZsklearntabulateZ
tensorflowZtensorrtZ	torch2trtZtqdmtreeZtvmZxarrayc                 C   s   t dd| S )Nz__init__.py$ )resub)s r   [/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/site-packages/torch/_dynamo/skipfiles.py_strip_init_py   s   r   mc                 C   s
   t | jS N)r   __file__)r   r   r   r   _module_dir   s   
r   >   ztorch._constrain_as_sizeztorch._constrain_as_valueztorch._tensor._convert>   ztorch._export.db.examplesztorch._export.wrappersz1torch.ao.quantization.quantizer.xnnpack_quantizerz$torch.ao.quantization.pt2e.qat_utilsz1torch.ao.quantization.pt2e.representation.rewriteztorch._dynamo.external_utilsz%torch.ao.quantization.pt2e.eval_utilsztorch.optimztorch._higher_order_ops.condztorch._functorch.deprecatedztorch._functorch.apisz torch.ao.quantization.pt2e.utils>   z(torch.distributed.tensor.parallel._utilsztorch.distributed._tensor.apiz'torch.distributed.tensor.parallel.stylez%torch.distributed._tensor.device_meshztorch.distributed.device_meshz;torch.distributed.algorithms._checkpoint.checkpoint_wrapperz6torch.distributed.tensor.parallel._data_parallel_utils>   ztorch.utils._content_storeztorch.autograd.functionztorch.utils._contextlibztorch.utils._pytreeztorch.fx._pytreeztorch._dynamo.comptimeztorch.distributionsztorch.cuda.amp.autocast_modeztorch.fx.passes.shape_propztorch.amp.autocast_modeztorch.testingztorch.sparseztorch._tensorztorch._dynamo.polyfillztorch._inductor.test_operatorsz,torch._dynamo._trace_wrapped_higher_order_opztorch.utils._foreach_utilsztorch.nnztorch._refsztorch._primsztorch.randomztorch.ao.nnztorch._decompztorch.distributedz)torch.distributed._functional_collectivesc                  C   sD   t  } tD ]}|dd\}}t|}t||}| |j q| S )N.r   )setFUNC_INLINELISTrsplit	importlibimport_modulegetattradd__code__)
inlinelistfmodule_namefn_namer   fnr   r   r   get_func_inlinelist   s   

r#   c                  C   :   t  } tD ]}| tt|tdd  dd  q| S Nztorch.r   /)r   LEGACY_MOD_INLINELISTr   r   torchlenreplacer   r   r   r   r   get_legacy_mod_inlinelist      (r,   c                  C   r$   r%   )r   MOD_INLINELISTr   r   r(   r)   r*   r+   r   r   r   get_mod_inlinelist   r-   r/   z<frozen importlibz<__array_function__ internals>c                 C   s   g | ]}t |qS r   )r   ).0r   r   r   r   
<listcomp>  s    r1   zmatch nothing^ztorch._inductor.config>   ztorchrec/distributedz5caffe2/torch/fb/sparsenn/pooled_embeddings_modules.pyztorchrec/fb/distributedz.*(|)c                   C   s$   t ddtt jt dad S )Nz^(r2   r3   )r   compilejoinmapescape	SKIP_DIRSSKIP_DIRS_REr   r   r   r   _recompile_re  s   $r:   import_namec                 C   sj   t | tjrt| jS t | tsJ ddlm} || }|s d S |j}|d u r)d S t	
t| t  d S )Nr   )	find_spec)
isinstancetypes
ModuleTyper   __name__strimportlib.utilr<   originr8   appendr   r:   )r;   r<   Zmodule_specrC   r   r   r   r     s   

r   c                   @   s"   e Zd ZU eed< ee ed< dS )
SkipResultskippedreasonN)r@   
__module____qualname__bool__annotations__r   rA   r   r   r   r   rE   *  s   
 rE   Fc                    s    du r	t ddS t fddt D rt ddS |r%t r%t ddS tr3tt r3t dd	S tt r?t dd
S t ddS )zShould skip this file?NTzfilename is Nonec                 3       | ]}  |V  qd S r   
startswithr0   dfilenamer   r   	<genexpr>4      zcheck_file.<locals>.<genexpr>Fz1inlined according skipfiles.LEGACY_MOD_INLINELISTz*inlined according skipfiles.MOD_INLINELISTz,skipped according skipfiles.FBCODE_SKIP_DIRSz%skipped according skipfiles.SKIP_DIRSzinlined by default)	rE   anyr,   is_torch_inline_allowed	is_fbcoderJ   FBCODE_SKIP_DIRS_REmatchr9   )rR   is_inlined_callr   rQ   r   
check_file0  s(   


r[   c                   @   s<   e Zd ZU ee ed< ee ed< eed< eej ed< dS )FunctionInfopy_objnamerR   codeN)	r@   rH   rI   r   objectrK   rA   r>   CodeTyper   r   r   r   r\   I  s
   
 r\   c                 C   s   t | tttfr(z|  }W n ty   d }Y nw t||  |  | 	 }n.t | t
jr8td | j| j| }nt | t
jt
jfrMt| | jt| | j}n	t| d t| d }|jt v ratddS |rw|jdkrmtddS |jdkrwtddS t|j|S )NFz+inlined according skipfiles.FUNC_INLINELISTZpatched_initTzpatched init cannot be inlined.Z__torch_function__z!allow inlining __torch_function__)r=   r   r   r   Zget_functionNotImplementedErrorr\   get_nameget_filenameget_coder>   ra   co_nameco_filenameFunctionType
MethodTyper@   r   r   r_   r#   rE   r^   r[   rR   )objrZ   r]   fir   r   r   check_verboses  s6   




rl   c                 C   s   t | |jS r   )rl   rF   )rj   rZ   r   r   r   check  s   rm   c                    s   t  fddt D S )Nc                 3   rL   r   rM   rO   rQ   r   r   rS     rT   z*is_torch_inline_allowed.<locals>.<genexpr>)rU   r/   rQ   r   rQ   r   rV     s   rV   c                  C   s   dd l } t| jS )Nr   )Ztorch._dynamor   Z_dynamo)r(   r   r   r   
dynamo_dir  s   
rn   c                 C   s   |  t rdS |  ttS )NF)rN   rn   r   r(   rQ   r   r   r   is_torch  s   ro   )F)N_collections_abc_weakrefsetabccollections
contextlibcopycopyregdataclassesenum	functoolsr   inspect	linecacheloggingmultiprocessingoperatoros	posixpathrandomr   	selectorssignaltempfile	threadingtokenize	tracebackr>   typingZunittestweakrefr   r(   Ztorch._inductor.test_operatorsZtorch.distributedZtorch.utils._content_storeutilsr   Zvariables.functionsr   r   r   ZBUILTIN_SKIPLISTZTHIRDPARTY_SKIPLISTr   r?   r   r   r'   ZdistributedZis_availabler.   r   	lru_cacher#   r,   r/   r8   r4   r9   r   rW   ZFBCODE_SKIP_DIRSr5   r6   r7   rX   r:   rA   	dataclassrE   r[   r\   rl   rm   _namerV   rn   ro   r   r   r   r   <module>   s    ,	
$	





	
 

"
!
