
    ΅i                         S r SSKrSSKrSSKJr  SSKrSSKJrJ	r	  SSK
r
SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$  \RJ                  " \&5      r'\RP                  S 5       r)1 Skr*\
RV                  4S	 jr,\-" 5       r.\
RV                  SS
.S\/\R`                  \4   S\Rb                  \-  4S jjr2g)a  
This is a simple interpreter for Sympy expressions that dispatches to
classes following the torch._inductor.virtualized calling convention.
For directness, the interpreter takes the handler directly rather than
consulting the TLS.  It does not use most of the methods on the full
handler; only those with corresponding Sympy expressions.  To see an example
of a full handler, see torch.utils._sympy.value_ranges.ValueRangeAnalysis.
    N)Any)BooleanBooleanAtom   )BitwiseFn_bitwise_andBitwiseFn_bitwise_orBitwiseFn_bitwise_xor	CeilToIntCleanDivFloatPowFloatTrueDivFloorDiv
FloorToIntIdentity
IntTrueDiv!IsNonOverlappingAndDenseIndicatorMaxMinModModularIndexingOpaqueUnaryFn_log2PowByNatural	PythonModRoundDecimal
RoundToIntToFloatTruncToFloat
TruncToIntWherec                  8   0 [         R                  S_[         R                  S_[         R                  S_[         R                  S_[         R
                  S_[         R                  S_[         R                  S_[         R                  S_[         R                  S	_[        S
_[        S_[        S_[        S_[        S_[        S_[         R                   S_[         R"                  S_0 [$        S_[&        S_[         R(                  S_[*        S_[,        S_[         R*                  S_[         R.                  S_[         R0                  S_[         R2                  S_[         R4                  S_[         R6                  S_[4        S_[6        S_[8        S_[         R:                  R<                  R>                  R@                  S_[         RB                  S_[D        S_E[F        S[H        S[J        S [L        S![N        S"[P        S#0En S$ H  nX[S        [         U5      '   M     U $ )%Nor_and_eqneltgtlegenot_int_truedivtruedivfloordivtruncwhereaddmulpowpow_by_naturalmod
python_modabslogexpminimummaximummodular_indexingexpr_cond_pair	piecewiseidentity&is_non_overlapping_and_dense_indicatorround_decimallog2bitwise_and
bitwise_orbitwise_xor)	cossintansinhcoshtanhasinacosatan)*sympyOrAndEqNeLtGtLeGeNotr   r   r   r   r   r   AddMulr   r   Powr   r   Absr6   r7   r   r   r   	functions
elementaryr<   ExprCondPair	Piecewiser   r   r   r   r   r   r	   getattr)HANDLERSnames     S/home/james-whalen/.local/lib/python3.13/site-packages/torch/utils/_sympy/interp.pyhandlersrc   7   sh   3%3		63 	$3 	$	3
 	$3 	$3 	$3 	$3 			63 	M3 	i3 	*3 	*3 	g3 	w3  			5!3" 			5#3$ 	%%3& 	&'34 			#536 	U738 	<93@ 			5A3B 			5C3D 			5E3F 			5G3H 			9I3J 			9K3L 	YM3N 	YO3P 	+Q3R 	"",,99;KS3T 	U3V 	*W3X 	*+SoF}l}e3Hl V)-%& V O    >   r/   r0   r!   r"   r9   r8   c                 (   [        U[        R                  5      (       aT  [        UR                  S   [        R                  R
                  R                  5      (       a  U R                  US   5      $ [        U[        5      (       a#  U R                  US   [        R                  5      $ [        S[        R                  S[        R                  S[        S[         S["        S0nUR%                  UR&                  5      =nb  [)        X5      " / UQUP76 $ UR&                  [        R*                  L aK  UR,                  (       a:  [/        U S5      (       a)  U R1                  U5      n[2        R5                  SX5        U$ [/        UR&                  S	5      (       a  UR&                  R6                  nO[9        5       UR&                     n[)        X5      n U[:        ;   ai  [=        U5      S::  a  [?        S
5      eU" US   US   5      n[A        S[=        U5      5       H  n	U" XU	   5      nM     [2        R5                  SXQU5        U$ U" U6 n[2        R5                  SXQU5        U$ ! [B         a    e [D         a    [2        RG                  SXQ5        e f = f)Nr   r   trunc_to_intfloor_to_intceil_to_intround_to_intsym_sumzsym_sum(%s) -> %s_torch_handler_namezassociative op needs >1 args   z%s(%s) -> %szfailed while executing %s(%s))$
isinstancerM   rY   argscorenumbersHalfsqrtr   to_dtypetorchfloat64r   floorceilingr   r
   r   getfuncr_   rW   
is_integerhasattrrj   r6   debugrk   rc   ASSOCIATIVE_OPSlenAssertionErrorrangeNotImplementedError	Exceptionwarning)
analysisrn   exprindex_dtypeINDEX_DTYPE_HANDLERShandler_namerhandleraccis
             rb   _run_sympy_handlerr   }   s   $		""z		!ejj((--( ( }}T!W%%$    a%--88 	N^}N=N -00;;Hx.BBkBB yyEII$//gh	6R6RT"		%t/tyy/00yy44z$)),h-G?*4yA~$%CDD$q'47+C1c$i(c7+ )IInl#>JAIInl!<H  3\Hs   A2I% I% %,Jr   missing_handlerenvr   c                Z   S n[        U[        5      (       a  [        R                  nO_[        U[        R
                  5      (       a  [        R                  nO/[        U[        R                  5      (       a  [        R                  nUb  U R                  X%5      $ [        U[        R                  5      (       a;  UR                  U[        5      =n[        La  U$ U(       a  U" U5      $ [        U5      e[        U UR                   Vs/ s H  n[!        U UUUUS9PM     snUUS9$ s  snf )Nr   )r   )rm   r   rt   boolrM   Integerint64NumberdoubleconstantSymbolrx   _nilKeyErrorr   rn   sympy_interp)r   r   r   r   r   dtyper   args           rb   r   r      s    E$$$

	D%--	(	(	D%,,	'	'  --	D%,,	'	't$$AT1H"4((4.   yy		
 ! ' / !		
 	 		
s   
D(
)3__doc__	functoolsloggingtypingr   rM   sympy.logic.boolalgr   SympyBooleanr   rt   r[   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	getLogger__name__r6   cacherc   r}   r   r   objectr   dictr   Exprr    rd   rb   <module>r      s        D       : ! ? ?D F :? 7t x *	ellC	 * **|
#*rd   