Ë
    Q/æjÊ  ã                   óˆ  — d Z ddlZddlZddlmZmZmZ ddlZddlm	Z
m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mZmZm Z m!Z!m"Z"  ejF                  e$«      Z% ejL                  d«      d„ «       Z'h d£Z(ejR                  fd	„Z*ejR                  d
œdeejV                  ef   deejX                  e
f   fd„Z-y)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ÚDictÚUnion)ÚBooleanÚBooleanAtomé   )Ú	CeilToIntÚCleanDivÚFloatPowÚFloatTrueDivÚFloorDivÚ
FloorToIntÚIdentityÚ
IntTrueDivÚ!IsNonOverlappingAndDenseIndicatorÚMaxÚMinÚModÚModularIndexingÚPowByNaturalÚ	PythonModÚRoundDecimalÚ
RoundToIntÚToFloatÚTruncToFloatÚ
TruncToIntÚWherec                  ó  — i t         j                  d“t         j                  d“t         j                  d“t         j                  d“t         j
                  d“t         j                  d“t         j                  d“t         j                  d“t         j                  d	“t        d
“t        d“t        d“t        d“t        d“t        d“t         j                   d“t         j"                  d“i t$        d“t&        d“t         j(                  d“t*        d“t,        d“t         j*                  d“t         j.                  d“t         j0                  d“t         j2                  d“t         j4                  d“t         j6                  d“t4        d“t6        d“t8        d“t         j:                  j<                  j>                  j@                  d“t         jB                  d“tD        d“¥tF        dtH        di¥} dD ]  }|| tK        t         |«      <   Œ | S ) NÚor_Úand_ÚeqÚneÚltÚgtÚleÚgeÚnot_Úint_truedivÚtruedivÚfloordivÚtruncÚwhereÚaddÚmulÚpowÚpow_by_naturalÚmodÚabsÚlogÚexpÚminimumÚmaximumÚmodular_indexingÚexpr_cond_pairÚ	piecewiseÚidentityÚ&is_non_overlapping_and_dense_indicatorÚround_decimal)	Ú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   ÚAbsr3   r4   r   r   r   Ú	functionsÚ
elementaryr9   ÚExprCondPairÚ	Piecewiser   r   r   Úgetattr)ÚHANDLERSÚnames     ú\/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torch/utils/_sympy/interp.pyÚhandlersr\   3   sZ  € ð.Ü�‰�%ð.ä�	‰	�6ð.ô 	�‰�$ð.ô 	�‰�$ð	.ô
 	�‰�$ð.ô 	�‰�$ð.ô 	�‰�$ð.ô 	�‰�$ð.ô 	�	‰	�6ð.ô 	�Mð.ô 	�ið.ô 	�*ð.ô 	�*ð.ô 	�gð.ô 	ˆwð.ô  	�	‰	�5ð!.ô" 	�	‰	�5ñ#.ô$ 	�%ð%.ô& 	Ð&ð'.ô4 	�	‰	Ð#ð5.ô6 	ˆUð7.ô8 	�5ð9.ô@ 	�	‰	�5ðA.ôB 	�	‰	�5ðC.ôD 	�	‰	�5ðE.ôF 	�	‰	�5ðG.ôH 	�	‰	�9ðI.ôJ 	�	‰	�9ðK.ôL 	ˆYðM.ôN 	ˆYðO.ôP 	Ð+ðQ.ôR 	�‰×"Ñ"×,Ñ,×9Ñ9Ð;KðS.ôT 	�‰˜ðU.ôV 	�*ñW.ôX 	*Ð+SÜ�oñ[.€Hð^ Vò .ˆØ)-ˆ”œ Ó%Ò&ð.ð €Oó    >   r-   r.   r   r    r6   r5   c                 ó  — t        |t        j                  «      rOt        |j                  d   t        j                  j
                  j                  «      r| j                  |d   «      S t        |t        «      r#| j                  |d   t        j                  «      S t        dt        j                  dt        j                  dt        dt         dt"        di}|j%                  |j&                  «      x}� t)        | |«      g |¢|‘­Ž S t+        |j&                  d«      r|j&                  j,                  }nt/        «       |j&                     }t)        | |«      }	 |t0        v r_t3        |«      dkD  sJ ‚ ||d   |d   «      }t5        dt3        |«      «      D ]  } ||||   «      }Œ t6        j9                  d	|||«       |S  ||Ž }	t6        j9                  d	|||	«       |	S # t:        $ r t6        j=                  d
||«       ‚ w xY w)Nr   r   Útrunc_to_intÚfloor_to_intÚceil_to_intÚround_to_intÚ_torch_handler_nameé   z%s(%s) -> %szfailed while executing %s(%s))Ú
isinstancerF   rR   ÚargsÚcoreÚnumbersÚHalfÚsqrtr   Úto_dtypeÚtorchÚfloat64r   ÚfloorÚceilingr   r	   r   ÚgetÚfuncrX   Úhasattrrc   r\   ÚASSOCIATIVE_OPSÚlenÚranger3   ÚdebugÚ	ExceptionÚwarning)
Úanalysisrf   ÚexprÚindex_dtypeÚINDEX_DTYPE_HANDLERSÚhandler_nameÚhandlerÚaccÚiÚrs
             r[   Ú_run_sympy_handlerr‚   r   sÅ  € ä�$œŸ	™	Ô"¤zØ�	‰	�!‰”e—j‘j×(Ñ(×-Ñ-ô(ð �}‰}˜T !™WÓ%Ð%Ü�$œÔ Ø× Ñ   a¡¬%¯-©-Ó8Ð8ô 	�NÜ�‰�^Ü�‰�}Ü�NÜ�=Ü�NðÐð -×0Ñ0°·±Ó;Ð;ˆÐHØ.Œw�x Ó.ÐB°ÐB°kÒBÐBäˆt�y‰yÐ/Ô0Ø—y‘y×4Ñ4‰ä“z $§)¡)Ñ,ˆÜ�h Ó-€GðØœ?Ñ*Ü�t“9˜q’=Ð �=Ù˜$˜q™' 4¨¡7Ó+ˆCÜ˜1œc $›iÓ(ò ,�Ù˜c 4¨¡7Ó+‘ð,ä�I‰I�n l°D¸#Ô>ØˆJá˜�ˆAÜ�I‰I�n l°D¸!Ô<ØˆHøÜò Ü�‰Ð3°\À4ÔHØðús   ÅA&G Ç G Ç"H©r{   Úenvrz   c                óÆ  — d }t        |t        «      rt        j                  }nUt        |t        j
                  «      rt        j                  }n*t        |t        j                  «      rt        j                  }|�| j                  ||«      S t        |t        j                  «      r||   S t        | |j                  D �cg c]  }t        | ||«      ‘Œ c}||¬«      S c c}w )Nrƒ   )re   r   rl   ÚboolrF   ÚIntegerÚint64ÚNumberÚdoubleÚconstantÚSymbolr‚   rf   Úsympy_interp)ry   r„   rz   r{   ÚdtypeÚargs         r[   r�   r�   £   s±   € ð €EÜ�$œÔ$Ü—
‘
‰Ü	�Dœ%Ÿ-™-Ô	(Ü—‘‰Ü	�Dœ%Ÿ,™,Ô	'Ü—‘ˆàÐØ× Ñ   uÓ-Ð-Ü	�Dœ%Ÿ,™,Ô	'Ø�4‰yÐô ØØ59·Y±YÖ?¨cŒ�h  SÕ	)Ò?ØØô	ð ùâ?s   Ã C
).Ú__doc__Ú	functoolsÚloggingÚtypingr   r   r   rF   Úsympy.logic.boolalgr   ÚSympyBooleanr   rl   rT   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú	getLoggerÚ__name__r3   Ú	lru_cacher\   rs   rˆ   r‚   rŒ   ÚExprr�   © r]   r[   ú<module>r›      sÈ   ðñó Û ß #Ñ #ã ß Dã ÷÷ ÷ ÷ ÷ õ ð2 €g×Ñ˜Ó!€ð €×Ñ�TÓñ8ó ð8òv F€ð :?¿¹ó .ðl —‘òà	ˆe�l‰l˜CÐÑ	 ðð �—
‘
˜LÐ(Ñ
)ôr]   