U
    Mh=                     @   s   d dl Z d dlZd dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ G dd dZG dd deZdS )    N)_keep_floatFloatPowFloatTrueDivFloorDiv
IntTrueDivModOpaqueUnaryFn_expOpaqueUnaryFn_logOpaqueUnaryFn_sqrtPowByNaturalRoundDecimal
RoundToIntToFloat
TruncToIntc                   @   s  e Zd Zedd Zedd Zedd Zedd Zed	d
 Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd  Zed!d" Zed#d$ Zed%d& Zed'd( Zed)d* Zed+d, Zed-d. Zed/d0 Zed1d2 Zed3d4 Zed5d6 Zed7d8 Z ed9d: Z!ed;d< Z"ed=d> Z#ed?d@ Z$edAdB Z%edCdD Z&edEdF Z'edGdH Z(edIdJ Z)dKS )LReferenceAnalysisc                 C   s
   t | S N)sympyZsympifycdtype r   N/var/www/html/venv/lib/python3.8/site-packages/torch/utils/_sympy/reference.pyconstant"   s    zReferenceAnalysis.constantc                 C   s   | |B S r   r   abr   r   r   or_&   s    zReferenceAnalysis.or_c                 C   s   | |@ S r   r   r   r   r   r   and_*   s    zReferenceAnalysis.and_c                 C   s,   t | tjst |tjr$t| |S | |kS r   )
isinstancer   ExprEqr   r   r   r   eq.   s    zReferenceAnalysis.eqc                 C   s   |  | ||S r   )not_r!   )clsr   r   r   r   r   ne4   s    zReferenceAnalysis.nec                 C   s   | |k S r   r   r   r   r   r   lt8   s    zReferenceAnalysis.ltc                 C   s   | |kS r   r   r   r   r   r   gt<   s    zReferenceAnalysis.gtc                 C   s   | |kS r   r   r   r   r   r   le@   s    zReferenceAnalysis.lec                 C   s   | |kS r   r   r   r   r   r   geD   s    zReferenceAnalysis.gec                 C   s   t | trt|  S r   )r   boolAssertionErrorr   r   r   r   r"   H   s    zReferenceAnalysis.not_c                 C   s
   t d| S )Ng      ?r   xr   r   r   
reciprocalM   s    zReferenceAnalysis.reciprocalc                 C   s
   t | dS )N   r   r-   r   r   r   squareQ   s    zReferenceAnalysis.squarec                 C   s   t | S r   )r   r.   r   r   r   r   trunc_to_intU   s    zReferenceAnalysis.trunc_to_intc                 C   s
   t | S r   )r   ceilingr3   r   r   r   ceil_to_intY   s    zReferenceAnalysis.ceil_to_intc                 C   s
   t | S r   )r   floorr3   r   r   r   floor_to_int]   s    zReferenceAnalysis.floor_to_intc                 C   s   t tj| S r   )r   r   r7   r-   r   r   r   r7   a   s    zReferenceAnalysis.floorc                 C   s   t tj| S r   )r   r   r5   r-   r   r   r   ceile   s    zReferenceAnalysis.ceilc                 C   s&   |t jkrt| S td| dd S Nz	to_dtype z NYI)torchfloat64r   NotImplementedErrorr3   r   r   r   to_dtypei   s    
zReferenceAnalysis.to_dtypec                 C   s
   t | |S r   )r   r.   yr   r   r   modo   s    zReferenceAnalysis.modc                 C   s   t | S r   )absr-   r   r   r   rB   s   s    zReferenceAnalysis.absc                 C   s   |  S r   r   r-   r   r   r   negw   s    zReferenceAnalysis.negc                 C   s
   t | |S r   r,   r   r   r   r   truediv{   s    zReferenceAnalysis.truedivc                 C   s
   t | |S r   )r   r   r   r   r   int_truediv   s    zReferenceAnalysis.int_truedivc                 C   s
   t | |S r   )r   r   r   r   r   floordiv   s    zReferenceAnalysis.floordivc                 C   s   t dd S )NzTODO: truncdiv)r=   r   r   r   r   truncdiv   s    zReferenceAnalysis.truncdivc                 C   s   t tj| |S r   )r   operatoraddr   r   r   r   rI      s    zReferenceAnalysis.addc                 C   s   t tj| |S r   )r   rH   mulr   r   r   r   rJ      s    zReferenceAnalysis.mulc                 C   s   t tj| |S r   )r   rH   subr   r   r   r   rK      s    zReferenceAnalysis.subc                 C   s   t | S r   )r   r-   r   r   r   exp   s    zReferenceAnalysis.expc                 C   s   t | S r   )r	   r-   r   r   r   log   s    zReferenceAnalysis.logc                 C   s   t | S r   )r
   r-   r   r   r   sqrt   s    zReferenceAnalysis.sqrtc                 C   s   t t| |S r   )r   r   r   r   r   r   pow   s    zReferenceAnalysis.powc                 C   s
   t | |S r   r1   r   r   r   r   pow_by_natural   s    z ReferenceAnalysis.pow_by_naturalc                 C   s   t | |S r   )r   ZMinr   r   r   r   minimum   s    zReferenceAnalysis.minimumc                 C   s   t | |S r   )r   ZMaxr   r   r   r   maximum   s    zReferenceAnalysis.maximumc                 C   s   t | S r   )r   r   r   r   r   r   round_to_int   s    zReferenceAnalysis.round_to_intc                 C   s
   t | |S r   )r   r   r   r   r   round_decimal   s    zReferenceAnalysis.round_decimalN)*__name__
__module____qualname__staticmethodr   r   r   r!   classmethodr$   r%   r&   r'   r(   r"   r/   r2   r4   r6   r8   r7   r9   r>   rA   rB   rC   rD   rE   rF   rG   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rT   rU   r   r   r   r   r   !   s   



































r   c                   @   s   e Zd Zedd Zedd Zedd Zedd Zed	d
 Zedd Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd  Zed!d" Zed#d$ Zed%d& Zed'd( Zd)S )*PythonReferenceAnalysisc                 C   sH   |t jkrt| S |t jkr$t| S |t jkr6t| S td| d S )Nzunrecognized dtype )r;   Zint64intdoublefloatr)   r*   r   r   r   r   r      s    


z PythonReferenceAnalysis.constantc                 C   s
   t | S r   )r;   Zsym_notr+   r   r   r   r"      s    zPythonReferenceAnalysis.not_c                 C   s   | | S r   r   r   r   r   r   rF      s    z PythonReferenceAnalysis.floordivc                 C   s   | | S r   r   r?   r   r   r   rA      s    zPythonReferenceAnalysis.modc                 C   s   | | S r   r   r   r   r   r   rG      s    z PythonReferenceAnalysis.truncdivc                 C   s&   |t jkrt| S td| dd S r:   )r;   r<   r^   r=   r3   r   r   r   r>      s    
z PythonReferenceAnalysis.to_dtypec                 C   s   t dd S )Nz!exp is not valid shape sympy exprr*   r-   r   r   r   rL      s    zPythonReferenceAnalysis.expc                 C   s   t dd S )Nz!log is not valid shape sympy exprr_   r-   r   r   r   rM      s    zPythonReferenceAnalysis.logc                 C   s
   t | S r   )r;   Z	_sym_sqrtr-   r   r   r   rN      s    zPythonReferenceAnalysis.sqrtc                 C   s   t | |S r   )r;   Zsym_minr   r   r   r   rQ      s    zPythonReferenceAnalysis.minimumc                 C   s   t | |S r   )r;   Zsym_maxr   r   r   r   rR      s    zPythonReferenceAnalysis.maximumc                 C   s
   t | S r   )mathr7   r3   r   r   r   r8      s    z$PythonReferenceAnalysis.floor_to_intc                 C   s
   t | S r   )r`   r9   r3   r   r   r   r6      s    z#PythonReferenceAnalysis.ceil_to_intc                 C   s   t t| S r   )r^   r`   r7   r-   r   r   r   r7      s    zPythonReferenceAnalysis.floorc                 C   s   t t| S r   )r^   r`   r9   r-   r   r   r   r9     s    zPythonReferenceAnalysis.ceilc                 C   s   | | S r   r   r   r   r   r   rD     s    zPythonReferenceAnalysis.truedivc                 C   s   | | S r   r   r   r   r   r   rO   	  s    zPythonReferenceAnalysis.powc                 C   s   | | S r   r   r   r   r   r   rP     s    z&PythonReferenceAnalysis.pow_by_naturalc                 C   s   t | S r   roundrS   r   r   r   rT     s    z$PythonReferenceAnalysis.round_to_intc                 C   s   t | |dS )N)ndigitsra   r   r   r   r   rU     s    z%PythonReferenceAnalysis.round_decimalN)rV   rW   rX   rY   r   r"   rF   rA   rG   r>   rL   rM   rN   rQ   rR   r8   r6   r7   r9   rD   rO   rP   rT   rU   r   r   r   r   r[      sP   



















r[   )r`   rH   r   r;   Ztorch.utils._sympy.functionsr   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r[   r   r   r   r   <module>   s   @ 