
    sgL                         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mZmZ  G d d      Z G d de      Zy)    N)_keep_floatFloatPowFloatTrueDivFloorDiv
IntTrueDivMaxMinModOpaqueUnaryFn_expOpaqueUnaryFn_logOpaqueUnaryFn_sqrtPowByNaturalRoundDecimal
RoundToIntToFloat
TruncToIntc                   \   e Zd Zed        Zed        Zed        Zed        Zed        Z	ed        Z
ed        Zed        Zed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Z ed        Z!ed        Z"ed        Z#ed         Z$ed!        Z%ed"        Z&ed#        Z'ed$        Z(ed%        Z)y&)'ReferenceAnalysisc                 ,    t        j                  |       S N)sympysympifycdtypes     O/var/www/html/venv/lib/python3.12/site-packages/torch/utils/_sympy/reference.pyconstantzReferenceAnalysis.constant#       }}Q    c                     | |z  S r    abs     r   or_zReferenceAnalysis.or_'       1ur   c                     | |z  S r   r!   r"   s     r   and_zReferenceAnalysis.and_+   r&   r   c                     t        | t        j                        st        |t        j                        rt        j                  | |      S | |k(  S r   )
isinstancer   ExprEqr"   s     r   eqzReferenceAnalysis.eq/   s6    a$
1ejj(A88Aq>!Avr   c                 D    | j                  | j                  ||            S r   )not_r-   )clsr#   r$   s      r   nezReferenceAnalysis.ne5   s    xxq!%%r   c                     | |k  S r   r!   r"   s     r   ltzReferenceAnalysis.lt9   r&   r   c                     | |kD  S r   r!   r"   s     r   gtzReferenceAnalysis.gt=   r&   r   c                     | |k  S r   r!   r"   s     r   lezReferenceAnalysis.leA       Avr   c                     | |k\  S r   r!   r"   s     r   gezReferenceAnalysis.geE   r8   r   c                 ,    t        | t              rJ |  S r   )r*   boolr#   s    r   r/   zReferenceAnalysis.not_I   s    a&&&r	r   c                     t        d|       S )Ng      ?r   xs    r   
reciprocalzReferenceAnalysis.reciprocalN   s    C##r   c                     t        | d      S )N   r   r@   s    r   squarezReferenceAnalysis.squareR       Aq!!r   c                     t        |       S r   )r   rA   r   s     r   trunc_to_intzReferenceAnalysis.trunc_to_intV       !}r   c                 ,    t        j                  |       S r   )r   ceilingrI   s     r   ceil_to_intzReferenceAnalysis.ceil_to_intZ   r   r   c                 ,    t        j                  |       S r   )r   floorrI   s     r   floor_to_intzReferenceAnalysis.floor_to_int^   s    {{1~r   c                 @     t        t        j                        |       S r   )r   r   rP   r@   s    r   rP   zReferenceAnalysis.floorb   s    '{5;;'**r   c                 @     t        t        j                        |       S r   )r   r   rM   r@   s    r   ceilzReferenceAnalysis.ceilf   s    ){5==)!,,r   c                 \    |t         j                  k(  rt        |       S t        d| d      Nz	to_dtype z NYI)torchfloat64r   NotImplementedErrorrI   s     r   to_dtypezReferenceAnalysis.to_dtypej   s,    EMM!1:!IeWD"9::r   c                     t        | |      S r   )r
   rA   ys     r   modzReferenceAnalysis.modp       1ayr   c                     t        |       S r   )absr@   s    r   ra   zReferenceAnalysis.abst   s    1vr   c                     |  S r   r!   r@   s    r   negzReferenceAnalysis.negx   s	    r	r   c                     t        | |      S r   r?   r"   s     r   truedivzReferenceAnalysis.truediv|   rG   r   c                     t        | |      S r   )r   r"   s     r   int_truedivzReferenceAnalysis.int_truediv   s    !Qr   c                     t        | |      S r   )r   r"   s     r   floordivzReferenceAnalysis.floordiv   s    1~r   c                     t        d      )NzTODO: truncdiv)rY   r"   s     r   truncdivzReferenceAnalysis.truncdiv   s    !"233r   c                 B     t        t        j                        | |      S r   )r   operatoraddr"   s     r   rn   zReferenceAnalysis.add       ({8<<(A..r   c                 B     t        t        j                        | |      S r   )r   rm   mulr"   s     r   rq   zReferenceAnalysis.mul   ro   r   c                 B     t        t        j                        | |      S r   )r   rm   subr"   s     r   rs   zReferenceAnalysis.sub   ro   r   c                     t        |       S r   )r   r@   s    r   expzReferenceAnalysis.exp        ##r   c                     t        |       S r   )r   r@   s    r   logzReferenceAnalysis.log   rv   r   c                     t        |       S r   )r   r@   s    r   sqrtzReferenceAnalysis.sqrt   s    !!$$r   c                 .     t        t              | |      S r   )r   r   r"   s     r   powzReferenceAnalysis.pow   s    ${8$Q**r   c                     t        | |      S r   rE   r"   s     r   pow_by_naturalz ReferenceAnalysis.pow_by_natural   rG   r   c                     t        | |      S r   )r	   r"   s     r   minimumzReferenceAnalysis.minimum   r_   r   c                     t        | |      S r   )r   r"   s     r   maximumzReferenceAnalysis.maximum   r_   r   c                     t        |       S r   )r   r#   r   s     r   round_to_intzReferenceAnalysis.round_to_int   rK   r   c                     t        | |      S r   )r   r"   s     r   round_decimalzReferenceAnalysis.round_decimal   rG   r   N)*__name__
__module____qualname__staticmethodr   r%   r(   r-   classmethodr1   r3   r5   r7   r:   r/   rB   rF   rJ   rN   rQ   rP   rT   rZ   r^   ra   rc   re   rg   ri   rk   rn   rq   rs   ru   rx   rz   r|   r~   r   r   r   r   r!   r   r   r   r   "   s            
 & &           $ $ " "         + + - - ; ;
       " "       4 4 / / / / / / $ $ $ $ % % + + " "       " "r   r   c                   L   e Zd Zed        Zed        Zed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zy)PythonReferenceAnalysisc                     |t         j                  u rt        |       S |t         j                  u rt	        |       S |t         j
                  u rt        |       S t        d|       )Nzunrecognized dtype )rW   int64intdoublefloatr<   AssertionErrorr   s     r   r   z PythonReferenceAnalysis.constant   sT    EKKq6Mell"8Oejj 7N #6ug!>??r   c                 ,    t        j                  |       S r   )rW   sym_notr=   s    r   r/   zPythonReferenceAnalysis.not_   r   r   c                     | |z  S r   r!   r"   s     r   ri   z PythonReferenceAnalysis.floordiv   r8   r   c                     | |z  S r   r!   r\   s     r   r^   zPythonReferenceAnalysis.mod   r&   r   c                     | |z  S r   r!   r"   s     r   rk   z PythonReferenceAnalysis.truncdiv   r&   r   c                 p    |t         j                  k(  rt        j                  |       S t        d| d      rV   )rW   rX   	sym_floatrY   rI   s     r   rZ   z PythonReferenceAnalysis.to_dtype   s1    EMM!??1%%!IeWD"9::r   c                     t        d      )Nz!exp is not valid shape sympy exprr   r@   s    r   ru   zPythonReferenceAnalysis.exp       @AAr   c                     t        d      )Nz!log is not valid shape sympy exprr   r@   s    r   rx   zPythonReferenceAnalysis.log   r   r   c                 ,    t        j                  |       S r   )rW   	_sym_sqrtr@   s    r   rz   zPythonReferenceAnalysis.sqrt   s    q!!r   c                 .    t        j                  | |      S r   )rW   sym_minr"   s     r   r   zPythonReferenceAnalysis.minimum       }}Q""r   c                 .    t        j                  | |      S r   )rW   sym_maxr"   s     r   r   zPythonReferenceAnalysis.maximum   r   r   c                 ,    t        j                  |       S r   )mathrP   rI   s     r   rQ   z$PythonReferenceAnalysis.floor_to_int   s    zz!}r   c                 ,    t        j                  |       S r   )r   rT   rI   s     r   rN   z#PythonReferenceAnalysis.ceil_to_int   s    yy|r   c                 >    t        t        j                  |             S r   )r   r   rP   r@   s    r   rP   zPythonReferenceAnalysis.floor   s    TZZ]##r   c                 >    t        t        j                  |             S r   )r   r   rT   r@   s    r   rT   zPythonReferenceAnalysis.ceil  s    TYYq\""r   c                     | |z  S r   r!   r"   s     r   re   zPythonReferenceAnalysis.truediv  r&   r   c                     | |z  S r   r!   r"   s     r   r|   zPythonReferenceAnalysis.pow
  s    !tr   c                     | |z  S r   r!   r"   s     r   r~   z&PythonReferenceAnalysis.pow_by_natural  s    
 !tr   c                     t        |       S r   roundr   s     r   r   z$PythonReferenceAnalysis.round_to_int  s    Qxr   c                     t        | |      S )N)ndigitsr   r"   s     r   r   z%PythonReferenceAnalysis.round_decimal  s    Q""r   N)r   r   r   r   r   r/   ri   r^   rk   rZ   ru   rx   rz   r   r   rQ   rN   rP   rT   re   r|   r~   r   r   r!   r   r   r   r      s   @ @           ; ;
 B B B B " " # # # #     $ $ # #         # #r   r   )r   rm   r   rW   torch.utils._sympy.functionsr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r!   r   r   <module>r      sF           4X" X"|[#/ [#r   