a
    Ž¥»a"  ã                	   @   sj  d Z ddlZddl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 g d¢Ze	eeeeedf eeef egef f edœd	d
„Zedƒe
jƒZedƒe
jƒZe
jde
jde
jdiZe
je
jeeef dœdd„Zdeeee ee eeddœdd„Zeeedf eeef eedœdd„ZejD ]<Ze d¡�r<�q(eeeƒZeeƒeƒe ƒ e< e !e¡ �q(dS )a;  This module exists since the `torch.testing` exposed a lot of stuff that shouldn't have been public. Although this
was never documented anywhere, some other internal FB projects as well as downstream OSS projects might use this. Thus,
we don't internalize without warning, but still go through a deprecation cycle.
é    N)ÚAnyÚCallableÚDictÚOptionalÚTupleÚUnioné   )Ú_dtype_getters)ÚrandÚrandnÚassert_allclose.)ÚinstructionsÚreturnc                    s   t t dœ‡ fdd„}|S )N)Úfnr   c                    s<   ˆ j ‰dˆ› d�‰t ˆ ¡tttdœ‡ ‡‡‡fdd„ƒ}|S )Nztorch.testing.z:() is deprecated and will be removed in a future release. )ÚargsÚkwargsr   c                     sD   ˆ | i |¤Ž}t ˆƒr$ˆˆ| ||ƒnˆ}ˆ|  ¡ }t |t¡ |S )N)ÚcallableÚstripÚwarningsÚwarnÚFutureWarning)r   r   Úreturn_valueÚtailÚmsg)r   Úheadr   Úname© úS/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/torch/testing/_deprecated.pyÚinner_wrapper   s
    z=warn_deprecated.<locals>.outer_wrapper.<locals>.inner_wrapper)Ú__name__Ú	functoolsÚwrapsr   )r   r   ©r   )r   r   r   r   Úouter_wrapper   s
    z&warn_deprecated.<locals>.outer_wrapper)r   )r   r#   r   r"   r   Úwarn_deprecated   s    r$   zUse torch.rand instead.zUse torch.randn instead.)çü©ñÒMbP?r%   )g-Cëâ6?çñhãˆµøä>)r&   g:Œ0âŽyE>)ÚactualÚexpectedr   c                 C   s8   t  | jd¡\}}t  |jd¡\}}t||ƒt||ƒfS )N)ç        r)   )Ú_DTYPE_PRECISIONSÚgetÚdtypeÚmax)r'   r(   Zactual_rtolZactual_atolZexpected_rtolZexpected_atolr   r   r   Ú_get_default_rtol_and_atol3   s    r.   TÚ )r'   r(   ÚrtolÚatolÚ	equal_nanr   r   c                 C   sx   t | tjƒst | ¡} t |tjƒs2tj|| jd�}|d u rP|d u rPt| |ƒ\}}tjj| ||||dddd|pnd d�
 d S )N)r,   TF)r0   r1   r2   Zcheck_deviceZcheck_dtypeZcheck_strideZcheck_is_coalescedr   )Ú
isinstanceÚtorchÚTensorZtensorr,   r.   ZtestingZassert_close)r'   r(   r0   r1   r2   r   r   r   r   r   >   s$    
ör   )r   r   r   r   r   c                 C   s   d| › d|› d�S )NzThis call to z(...) can be replaced with Ú.r   )r   r   r   r   r   r   r   Ú_dtype_getter_instructions\   s    r7   Ú_)NNTr/   )"Ú__doc__r    r   Útypingr   r   r   r   r   r   r4   r/   r	   Ú__all__Ústrr$   r
   r   Úfloat16Úfloat32Úfloat64r*   r5   Úfloatr.   Úboolr   r7   r   Ú
startswithÚgetattrr   ÚglobalsÚappendr   r   r   r   Ú<module>   sD    8ý    úù&

