Ë
    P/æjôÓ ã                   óR  — U d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlmZ ddlmZ ddlmZmZ ddl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$ ddl%m&Z& ddl'Z'ddl(Z'ddl)m*c mZ+ dd	l,m-Z. dd
l/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9m:Z: ddl'm;Z;m<Z<m=Z= ddl>m?Z?m@Z@mAZA ddlBmCZC ddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZL ddlMmNZN ddlOmPZP ddlQmRZRmSZSmTZTmUZU ddlVmWZW ddlXmYZYmZZZ ddl[m\Z\ ddl]m^Z^ ddl_m`c maZb ddlcmdZdmeZemfZf ddl8mgZg e$rddlhmiZi eZjeZk ejØ                  em«      ZnddloZoddlpmqZq ddlrmsZsmtZt  G d„ deu«      Zv G d„ d eu«      Zwe'jð                  jò                  jô                  Zzg d!¢Z{d"Z|d#Z}d$„ Z~d%„ Z ed«      d&e e€   fd'„«       Z� G d(„ d)eu«      Z‚d&eƒfd*„Z„e#e'jz                  e…f   Z†d+ee†   d&ee†   fd,„Z‡d¼d-e#e'jz                  e…f   d.ee…   d&e…fd/„Zˆe#e'jz                  e'jx                  e'jv                  e…e‰eƒf   ZŠd-eŠd&eƒfd0„Z‹d-e#e…e=f   d&eƒfd1„ZŒd2Z�e&eŽd3<   d4e#e'jv                  eƒf   d&eƒfd5„Z�d½d6„Z�d7„ Z‘d8e'jT                  �j$                  fd9„Z“d:e'jT                  �j$                  d&eƒfd;„Z”d4e�d&e�fd<„Z•d4e�d&e�fd=„Z–d4eo�j.                  d&eo�j.                  fd>„Z˜d-e#eƒe;f   d&eƒfd?„Z™d@„ ZšdAe#e=e'�j6                  f   d&eeo�j8                     fdB„Z�dAe#e=eo�j.                  e'�j6                  f   d&e eo�j<                     fdC„ZŸdAe#e=e'�j6                  f   d&eƒfdD„Z dE„ Z¡d&eeo�j<                     fdF„Z¢dG„ Z£ edH¬I«       G dJ„ dK«      «       Z¤ edH¬I«       G dL„ dM«      «       Z¥ edH¬I«       G dN„ dO«      «       Z¦ edH¬I«       G dP„ dQ«      «       Z§d¾dR„Z¨dS„ Z©dT„ ZªdUe#eƒe;f   d&eƒfdV„Z«dW„ Z¬dX„ Z­dY„ Z®dZ„ Z¯d[eo�j<                  d\e…d]e…fd^„Z°d_„ Z±d¿d`ee…   daee…   fdb„Z²ddcœd`ee…   daee…   fdd„Z³d-e'jz                  dee'jz                  d&dfdf„Z´dÀdge…fdh„Zµdi„ Z¶dj„ Z·dk„ Z¸dl„ Z¹dm„ ZºdHdnœdo„Z»dp„ Z¼ G dq„ dre«      Z½ edH¬I«       G ds„ dt«      «       Z¾ edH¬I«       G du„ dve¾«      «       Z¿ edH¬I«       G dw„ dxe¾«      «       ZÀe#e¿eÀdf   ZÁ edH¬I«       G dy„ dze¾«      «       ZÂd{„ ZÃd|„ ZÄd&eƒfd}„ZÅ edH¬I«       G d~„ d«      «       ZÆ edH¬I«       G d€„ d�eÆ«      «       ZÇ edH¬I«       G d‚„ dƒeÇ«      «       ZÈ edH¬I«       G d„„ d…eÈ«      «       ZÉdAe#e…e=e‰e<eƒe;f   d&eƒfd†„ZÊeIfZË ed‡«      dˆ„ «       ZÌd‰„ ZÍdŠ„ ZÎd‹„ ZÏdUeo�j.                  d&eo�j.                  fdŒ„ZÐd�e'jv                  d&e'jz                  fdŽ„ZÑi d�e�j¤                  “d�e�j¦                  “d‘e�j¨                  “d’e�jª                  “d“e�j¬                  “d”e�j®                  “d•e�j°                  “d–eÙ“d—eÚ“d˜e�j¶                  “d™e�j¶                  “dše�j¸                  “d›e�jº                  “dœe�j¼                  “d�eÎ“dže�j¾                  “dŸe�jÀ                  “e�j¾                  e�j¼                  e�jÀ                  eÑe�jÂ                  e�jÂ                  e�jÄ                  e�jº                  e�jº                  e�j                  d œ
¥Zãd¼d¡„Zä edH¬I«       G d¢„ d£«      «       Zå G d¤„ d¥eq«      Zæ G d¦„ d§eæ«      Zç G d¨„ d©eç«      Zè G dª„ d«eq«      Zé G d¬„ d­«      Zê e�jÖ                  «       Zì edH¬I«       G d®„ d¯«      «       Zí G d°„ d±«      Zîd²„ Zïd³„ Zð G d´„ dµe'jT                  �jâ                  «      Zòd¶„ Zód·„ Zô G d¸„ d¹eo�jê                  �j                   jâ                  «      Zödº„ Z÷d»„ Zøy)Áa¡  
``torch.fx.experimental.symbolic_shapes`` provides interfaces for interacting with
our symbolic shapes reasoning system that is used heavily in torch.compile.  Although
this is not generally considered public API, when writing framework code in PyTorch
as well as extensions to PyTorch (e.g., in custom operator implementations), you may
need to make use of these APIs to setup dynamic shapes support appropriately.
é    N)Údefaultdict)Úcontextmanager)Ú	dataclassÚfield)ÚEnum)ÚAnyÚcastÚCallableÚDictÚIterableÚListÚOptionalÚSequenceÚSetÚTupleÚTypeÚUnionÚTYPE_CHECKING)Ú	TypeAlias)Ú_config)ÚFakeTensorMetaÚShapeEnvEventÚrecord_shapeenv_eventÚreplay_shape_env_eventsÚshape_env_check_state_equal)ÚSymNodeÚSymTypes)Útrace_structuredÚ
structured)ÚSymBoolÚSymFloatÚSymInt)Ú
ShapeGuardÚSourceÚTracingContext)Úis_traceable_wrapper_subclass)ÚApplicationÚFloorDivÚModÚ	PythonModÚ!IsNonOverlappingAndDenseIndicatorÚCleanDivÚ
FloorToIntÚ	CeilToInt)Ú	try_solve)Úint_oo)Úbound_sympyÚSymPyValueRangeAnalysisÚValueRangesÚValueRangeError©ÚSingletonInt)Úformat_frameÚCapturedTraceback)Úsignpost_event)Úis_sparse_any)ÚSymTÚmake_symbolÚsymbol_is_type)Ú
LazyString)ÚTensorPropertySource)Ú
StrPrinter)Ú
precedenceÚ
PRECEDENCEc                   ó>   ‡ — e Zd ZU ej                  ed<   ˆ fd„Zˆ xZS )ÚGuardOnDataDependentSymNodeÚcondc                 ó,   •— t        ‰| �  |Ž  || _        y ©N)ÚsuperÚ__init__rE   )ÚselfrE   ÚargsÚ	__class__s      €úh/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torch/fx/experimental/symbolic_shapes.pyrI   z$GuardOnDataDependentSymNode.__init___   s   ø€ Ü‰Ñ˜$ÑØˆ�	ó    )Ú__name__Ú
__module__Ú__qualname__ÚsympyÚExprÚ__annotations__rI   Ú__classcell__©rL   s   @rM   rD   rD   \   s   ø… Ø
�*‰*Ó÷ð rN   rD   c                   ó   — e Zd Zy)ÚPendingUnbackedSymbolNotFoundN©rO   rP   rQ   © rN   rM   rX   rX   c   ó   „ ØrN   rX   )Úhas_symbolic_sizes_stridesÚcreate_contiguousÚShapeEnvÚis_concrete_intÚ	guard_intÚguard_floatÚguard_scalarÚcanonicalize_bool_exprÚhint_intÚSYMPY_INTERPÚfree_symbolsÚis_symbol_binding_fx_nodeÚis_concrete_boolÚis_nested_intÚSHAPEENV_EVENT_KEYÚCURRENT_NODE_KEYÚhas_free_symbolsÚsym_eqÚSymbolicContextÚStatelessSymbolicContextÚStatefulSymbolicContextÚSubclassSymbolicContextÚstatically_known_trueÚguard_size_obliviousÚcheck_consistentÚcompute_unbacked_bindingsÚConvertIntKeyÚrebind_unbackedÚresolve_unbacked_bindingsÚis_accessor_nodeÚshapeenv_eventÚcurrent_nodec                 ób   — t         j                  d| j                  | j                  «       «       y )Nzlru_cache_stats %s: %s)ÚlogÚdebugrO   Úcumulative_cache_info)Ú	wrapped_fs    rM   Úlog_lru_cache_statsr�   y   s"   € Ü‡I�IÐ&¨	×(:Ñ(:¸I×<[Ñ<[Ó<]Õ^rN   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó  •‡‡‡‡—  t        j                  ‰«      | «      Š‰j                  ŠdŠdŠˆˆˆfd„}ˆˆˆˆfd„}|‰_        |‰_        t        j                  t        j                  «      rt        j                  t        ‰«       ‰S )Nr   c                  ó°   •— ‰j                  «       } t        j                  ‰| j                  z   ‰| j                  z   | j
                  | j                  «      S rG   )Ú
cache_infoÚ	functoolsÚ
_CacheInfoÚhitsÚmissesÚmaxsizeÚcurrsize)ÚcurÚ	prev_hitsÚprev_missesr€   s    €€€rM   r   z7lru_cache.<locals>.inner.<locals>.cumulative_cache_info‰   sJ   ø€ Ø×&Ñ&Ó(ˆCÜ×'Ñ'Ø˜CŸH™HÑ$Ø˜cŸj™jÑ(Ø—‘Ø—‘ó	ð rN   c                  óp   •— ‰j                  «       } ‰| j                  z  Š‰| j                  z  Š ‰«        y rG   )r…   rˆ   r‰   )rŒ   Úold_cache_clearr�   rŽ   r€   s    €€€€rM   Únew_cache_clearz1lru_cache.<locals>.inner.<locals>.new_cache_clear’   s3   ø€ à×&Ñ&Ó(ˆCØ˜Ÿ™Ñ!ˆIØ˜3Ÿ:™:Ñ%ˆKÙÕrN   )r†   Ú	lru_cacheÚcache_clearr   r}   ÚisEnabledForÚloggingÚDEBUGÚatexitÚregisterr�   )Úfr   r‘   r�   r�   rŽ   r€   rŠ   s      @@@@€rM   Úinnerzlru_cache.<locals>.inner   sr   ü€ Ø0”I×'Ñ'¨Ó0°Ó3ˆ	Ø#×/Ñ/ˆØˆ	Øˆö	÷	ð !0ˆ	ÔØ*?ˆ	Ô'Ü×ÑœGŸM™MÔ*Ü�O‰OÔ/°Ô;ØÐrN   rZ   )rŠ   rš   s   ` rM   r’   r’   ~   s   ø€ ôð@ €LrN   Úreturnc            	      óò  — dd l } dd l} dd l} dd l} t        j
                  t           | j                  j                  j                  | j                  j                  j                  | j                  j                  | | j                  j                  | j                  j                  | j                   j"                  | j                   j$                  g	}|D �ch c]  }t'        j(                  |«      ’Œ c}S c c}w ©Nr   )Útorch._inductor.sizevarsÚtorch._library.fake_implÚtorch._subclasses.meta_utilsÚtorch._subclasses.fake_tensorÚsysÚmodulesrO   ÚfxÚexperimentalÚ	recordingÚsym_nodeÚinterpreterÚ	_inductorÚsizevarsÚ_libraryÚ	fake_implÚ_subclassesÚ
meta_utilsÚfake_tensorÚinspectÚgetfile)ÚtorchÚmodsÚms      rM   Úuninteresting_filesrµ   £   s®   € ã#Û#Û'Û(ä�‰”HÑØ�‰×Ñ×'Ñ'Ø�‰×Ñ×&Ñ&Ø�‰×ÑØØ�‰× Ñ Ø�‰× Ñ Ø×Ñ×$Ñ$Ø×Ñ×%Ñ%ð
€Dð )-Ö- 1ŒG�O‰O˜AÕÒ-Ð-ùÒ-s   ÃC4c                   ó   — e Zd Zy)ÚConstraintViolationErrorNrY   rZ   rN   rM   r·   r·   ¼   r[   rN   r·   c                 ó   — | j                   S rG   )Ú_has_symbolic_sizes_strides)Úelems    rM   r\   r\   ¿   s   € Ø×+Ñ+Ð+rN   Úshapec                 ó„   — dg}t        | d d «      D ]  }|j                  ||d   z  «       Œ t        t        |«      «      S )Né   éÿÿÿÿ)ÚreversedÚappendÚlist)r»   ÚstridesÚdims      rM   r]   r]   Ä   sH   € Ø˜€GÜ˜˜c˜r˜
Ó#ò *ˆØ�‰�s˜W R™[Ñ(Õ)ð*ä”˜Ó!Ó"Ð"rN   ÚaÚfallbackc                 ó    — t        | t        j                  «      r| j                  j	                  |«      S t        | «      t        u sJ | «       ‚| S )zò
    Retrieve the hint for an int (based on the underlying real values as observed
    at runtime).  If no hint is available (e.g., because data dependent shapes),
    if fallback is not None, use that instead (otherwise raise an error).
    )Ú
isinstancer²   r"   ÚnodeÚrequire_hintÚtypeÚint)rÄ   rÅ   s     rM   rd   rd   Ê   sA   € ô �!”U—\‘\Ô"Ø�v‰v×"Ñ" 8Ó,Ð,Ü�‹7”c‰>Ð˜1Óˆ>Ø€HrN   c                 óX   — t        | t        «      r| j                  j                  «       S y©NT)rÇ   r   rÈ   Úhas_hint©rÄ   s    rM   rÎ   rÎ   ×   s    € Ü�!”XÔØ�v‰v�‰Ó Ð ØrN   c                 óÜ   — t        | t        t        f«      sJ ‚t        | t        «      ryt        | j                  j                  t
        j                  j                  j                  «      ryy)zº Utility to check if underlying object
    in SymInt is concrete value. Also returns
    true if integer is passed in.

    Args:
        a (SymInt or int): Object to test if it int
    TF)	rÇ   r"   rË   rÈ   ÚexprrR   ÚcoreÚnumbersÚIntegerrÏ   s    rM   r_   r_   Ü   sM   € ô �aœ&¤#˜Ô'Ð'Ð'ä�!”SÔØä�!—&‘&—+‘+œuŸz™z×1Ñ1×9Ñ9Ô:ØàrN   zsympy.logic.boolalg.BooleanÚSympyBooleanrÑ   c                 ó    — t        | t        j                  «      r| j                  j	                  dd«      S t        | t
        «      sJ | «       ‚| S )a¸  
    Perform a guard on a symbolic boolean expression in a size oblivious way.
    This is typically used when a non-oblivious test would result in a guard
    on a data dependent value of which we don't know the value of at compile time.
    When a guard is tested this way, we may diverge in behavior from how regular
    PyTorch semantics would treat it.  For more information, see
    https://github.com/pytorch/pytorch/pull/118579
    Ú r   )rÇ   r²   r    rÈ   rs   Úbool©rÑ   s    rM   rs   rs   ó   sC   € ô �$œŸ™Ô&Ø�y‰y×-Ñ-¨b°!Ó4Ð4ä˜$¤Ô%Ð+ tÓ+Ð%ØˆrN   c                 óŒ  ‡ ‡— t         j                  t         j                  t        t        f}t        ‰ t         j                  «      r›t        ‰t         j                  «      sJ ‚t        j                  ‰j                  «       ‰ j                  «       k(  ˆ ˆfd„«       t        ‰j                  ‰ j                  «      D ]"  \  }}t        j                  ||k(  ˆ ˆfd„«       Œ$ yt        ‰ |«      rWt        ‰ t        «      sFt        ‰|«      rt        ‰t        «      rJ ‰› d‰ › �«       ‚t        j                  ‰‰ k(  ˆ ˆfd„«       yyy)zÙ
    Test that two "meta" values (typically either Tensor or SymInt) have
    the same values, e.g., after retracing.  If we don't understand the
    quantities in question, we'll just skip the consistency check.
    c                  ó<   •— ‰j                   › d‰ j                   › d�S ©Nú != z (old != new)©r»   ©ÚnewÚolds   €€rM   ú<lambda>z"check_consistent.<locals>.<lambda>  s   ø€ ¸¿	¹	°{À$ÀsÇyÁyÀkÐQ^Ð5_€ rN   c                  ó<   •— ‰j                   › d‰ j                   › d�S rÜ   rÞ   rß   s   €€rM   râ   z"check_consistent.<locals>.<lambda>  s   ø€ ¨C¯I©I¨;°d¸3¿9¹9¸+À]Ð)S€ rN   rÝ   c                  ó   •— ‰› d‰ › d�S rÜ   rZ   rß   s   €€rM   râ   z"check_consistent.<locals>.<lambda>  s   ø€ ¨C¨5°°S°E¸Ð)G€ rN   N)r²   r"   r!   rË   ÚfloatrÇ   ÚTensorÚ_checkrÃ   Úzipr»   rØ   )rà   rá   Úscalar_typesÚiÚjs   ``   rM   rt   rt     só   ù€ ô —L‘L¤%§.¡.´#´uÐ=€Lä�#”u—|‘|Ô$Ü˜#œuŸ|™|Ô,Ð,Ð,Ü�‰�S—W‘W“Y #§'¡'£)Ñ+Ô-_Ô`ô
 ˜Ÿ	™	 3§9¡9Ó-ò 	U‰DˆAˆqÜ�L‰L˜˜a™Ô!SÕTñ	Uô 
�C˜Ô	&¬z¸#¼tÔ/DÜ˜#˜|Ô,´ZÀÄTÔ5JÐ]ÈsÈeÐSWÐX[ÐW\ÐL]Ó]ÐJÜ�‰�S˜C‘ZÔ!GÕHð 0EÐ	&rN   c                 ó�   — |€y |j                  «       D ��ci c]"  \  }}| j                  j                  ||«      |“Œ$ c}}S c c}}w rG   )ÚitemsÚunbacked_renamingsÚget)Ú	shape_envÚbindingsÚkÚvs       rM   rx   rx     sP   € ØÐØð —N‘NÓ$÷áˆAˆqð 	×$Ñ$×(Ñ(¨¨AÓ.°Ñ1óð ùó s   —'AÚnc                 ó  — ddl m} |j                  dk(  ryt        | |j                  j                  d«      «      x}�rÏ|j                  «       D �]º  \  }}t        j                  ||«      }t        |t        «      r'|j                  |u rt        j                  d|||«       ŒT|j                  j                  }t        |t         j"                  «      rút%        |j&                  «      dk(  râ|j&                  d   d   dk(  rÍt        |j&                  d   d   x}	t         j(                  «      r¡t        |	j*                  x}
t         j,                  «      r{| j.                  |
   j1                  t3        dd«      «      rS|	j4                  dk(  rD|j&                  d   d	k(  r2t7        t!        j(                  |
d«      «      }||k(  sJ |› d
|› �«       ‚|
}t        |t         j,                  «      sJ ‚||k7  s
J |› d�«       ‚| j9                  ||«       �Œ½ yy)aÿ  
    Suppose we are retracing a pre-existing FX graph that previously had
    fake tensor propagation (and therefore unbacked SymInts).  When we retrace,
    we re-propagate fake tensors, which results in new unbacked SymInts.
    When this happens, we need to tell the shape environment about the equivalence
    of the old and new unbacked SymInts.  Pass us the old torch.fx.Node (which
    has the old binding information) and the new result (which we can extract the
    new unbacked SymInts out from).
    r   )Ú_tensor_versionÚplaceholderNÚunbacked_bindingsz4rebind_unbacked: discard _tensor_version %s %s -> %sé   r½   ©r   TrÝ   z possible memo disaster)Útorch._dynamo.tensor_version_oprö   Úoprx   Úmetarï   rí   ÚpytreeÚkey_getrÇ   rË   Útargetr}   ÚinforÈ   rÑ   rR   Ú	PiecewiseÚlenrK   ÚEqÚlhsÚSymbolÚvar_to_rangeÚissubsetr3   ÚrhsÚ'_sympy_cast_symbool_to_symint_guardlessÚ_rename_unbacked_to)rð   rô   Úresultrö   rñ   Úraw_u0ÚpathÚu1Úraw_u1ÚeqÚ
new_raw_u1Úrepackeds               rM   rw   rw   "  sÍ  € õ @ð 	‡t�tˆ}ÒØä,¨Y¸¿¹¿
¹
ÐCVÓ8WÓXÐX€xÑXØ$ŸN™NÓ,ó 	:‰LˆF�DÜ—‘ ¨Ó-ˆBô ˜"œcÔ" q§x¡x°?Ñ'BÜ—‘ÐOÐQWÐY]Ð_aÔbØØ—W‘W—\‘\ˆFô ˜6¤5§?¡?Ô3Ü�F—K‘KÓ  AÒ%Ø—‘˜A‘˜qÑ! QÒ&Ü §¡¨Q¡°Ñ!2Ð2˜2´E·H±HÔ=Ü¨¯©Ð/˜:´·±Ô>Ø×&Ñ& zÑ2×;Ñ;¼KÈÈ1Ó<MÔNØ—‘˜!’Ø—‘˜A‘ )Ò+ô CÄ5Ç8Á8ÈJÐXYÓCZÓ[�Ø 6Ò)ÐD¨h¨Z°t¸F¸8Ð+DÓDÐ)ð $�Ü˜f¤e§l¡lÔ3Ð3Ð3ð ˜VÒ#ÐG¨ xÐ/FÐ%GÓGÐ#à×)Ñ)¨&°&Ö9ñ?	:ð YrN   rÈ   c           
      óì  — | j                   dk(  rOt        | j                  d   j                  j	                  d«      t
        j                  «      r| j                  dv ry| j                   dk(  �r†| j                  t
        j                  j                  j                  t
        j                  j                  j                  j                  t
        j                  j                  j                  j                  t
        j                  j                  j                  t
        j                  j                  j                  j                  t
        j                  j                  j                  j                  t
        j                  j                  j                  t
        j                  j                  j                  j                  t
        j                  j                  j                  j                  f	v ryy)NÚcall_methodr   Úexample_value)ÚsizeÚstrideÚstorage_offsetÚitemTÚcall_functionF)rü   rÇ   rK   rý   rï   r²   ræ   r   ÚopsÚatenÚsym_sizeÚdefaultrË   Ú
sym_strideÚsym_storage_offsetÚ	sym_numel©rÈ   s    rM   ry   ry   X  s(  € ð 	�‰�=Ò Ü�t—y‘y ‘|×(Ñ(×,Ñ,¨_Ó=¼u¿|¹|ÔLØ�K‰KÐGÑGàØ‡w�w�/Ó! d§k¡kÜ�	‰	�‰×ÑÜ�	‰	�‰×Ñ×'Ñ'Ü�	‰	�‰×Ñ×#Ñ#Ü�	‰	�‰×!Ñ!Ü�	‰	�‰×!Ñ!×)Ñ)Ü�	‰	�‰×!Ñ!×%Ñ%Ü�	‰	�‰×)Ñ)Ü�	‰	�‰×)Ñ)×1Ñ1Ü�	‰	�‰× Ñ ×(Ñ(ð
6ñ 
'ð ØrN   c           	      ó¬  — t        | t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  f«      s| S t        | t        j                  t        j                  t        j
                  f«      r)t        j                  j                  j                  | «      } t        | «      S )a†   Canonicalize a boolean expression by transforming it into a lt / le
    inequality and moving all the non-constant terms to the rhs.
    We canonicalize And / Ors / Not via cnf and then canonicalize their subexpr
    recursively
    nb. sympy.Rel.canonical is not good enough https://github.com/sympy/sympy/issues/25924

    Args:
        expr (sympy.Expr): Expression to canonicalize
    )rÇ   rR   ÚRelÚAndÚOrÚNotr  ÚNeÚlogicÚboolalgÚto_cnfÚ_canonicalize_bool_expr_implrÙ   s    rM   rc   rc   n  s}   € ô  �dœUŸY™Y¬¯	©	´5·8±8¼U¿Y¹YÌÏÉÔRW×RZÑRZÐ[Ô\Øˆä�$œŸ™¤E§H¡H¬e¯i©iÐ8Ô9Ü�{‰{×"Ñ"×)Ñ)¨$Ó/ˆÜ'¨Ó-Ð-rN   c                 óÜ  — t        | t        j                  t        j                  f«      r& t	        | «      t        t        | j                  «      Ž S t        j                  t        j                  t        j                  t        j                  i}t        | t        |j                  «       «      «      r(| j                  | j                  z
  }|t	        | «         }nnt        | t        j                  t        j                  t        j                   t        j"                  f«      sJ ‚| j                  | j                  z
  }t	        | «      }d„ }d}t%        |«      }t        |t        j&                  «      rfg }g }|j                  D ].  } ||«      r|j)                  | «       Œ|j)                  |«       Œ0 t        j&                  |Ž }t        j&                  |Ž }n ||«      r| d}} |||«      S )zƒ
    After canonicalization, we are guaranteed to have eliminated Ge/Gt relations
    (rewriting them to Le/Lt, respectively).
    c                 óˆ   — | j                   xs5 t        | t        j                  «      xr | j                  d   j                   S r�   )Úis_negativerÇ   rR   ÚMulrK   ©Úts    rM   Úis_negz,_canonicalize_bool_expr_impl.<locals>.is_neg–  s/   € Ø�}‰}ÒT¤¨A¬u¯y©yÓ!9Ò!S¸a¿f¹fÀQ¹i×>SÑ>SÐTrN   r   )rÇ   rR   r&  r'  rÊ   Úmaprc   rK   ÚGtÚLtÚGeÚLeÚtupleÚkeysr  r	  r  r)  Ú_reduce_to_lowest_termsÚAddrÀ   )	rÑ   Úoppositer	  r3  r4  r  ÚposÚnegÚterms	            rM   r-  r-  …  sl  € ô
 �$œŸ™¤E§H¡HÐ-Ô.ØŒt�D‹zœ3Ô5°t·y±yÓAÐBÐBä—‘œ%Ÿ(™(¤E§H¡H¬e¯h©hÐ7€HÜ�$œ˜hŸm™m›oÓ.Ô/Ø�h‰h˜Ÿ™Ñ!ˆØ”T˜$“ZÑ ‰ä˜$¤§¡¬5¯8©8´U·X±X¼u¿x¹xÐ HÔIÐIÐIØ�h‰h˜Ÿ™Ñ!ˆÜ�‹JˆòUð €CÜ
! #Ó
&€CÜ�#”u—y‘yÔ!ØˆØˆØ—H‘Hò 	!ˆDÙ�dŒ|Ø—
‘
˜D˜5Õ!à—
‘
˜4Õ ð		!ô
 �i‰i˜ˆoˆÜ�i‰i˜ˆo‰Ù	�Œà�4˜ˆSˆÙˆS�#‹;ÐrN   c                 ó  — d„ }t        | t        j                  «      r^| j                  }t	        j
                  t        j                  t        ||«      «      }|D �cg c]  }||z  ‘Œ	 }}t        j                  |Ž S |  || «      z  S c c}w )z—
    Eliminates any integer factor from a given expression.
    E.g., 6x + 4y reduces to 3x + 2y.

    Useful when an expression is == or != to 0.
    c           
      óR  — t        | t        j                  «      rt        t	        | «      «      S t        | t        j
                  «      rZt        j                  | j                  D �cg c]1  }t        |t        j                  «      sŒt        t	        |«      «      ‘Œ3 c}«      S yc c}w ©Nr½   )	rÇ   rR   rÔ   ÚabsrË   r1  ÚmathÚprodrK   )ÚxÚargs     rM   Úinteger_coefficientz4_reduce_to_lowest_terms.<locals>.integer_coefficient²  sk   € Ü�aœŸ™Ô'Ü”s˜1“v“;ÐÜ˜œ5Ÿ9™9Ô%Ü—9‘9°q·v±vÖ`°ÄÈCÔQV×Q^ÑQ^ÕA_œc¤# c£(�mÒ`ÓaÐaàùò as   Á&B$ÂB$)	rÇ   rR   r=  rK   r†   ÚreducerF  Úgcdr5  )rÑ   rJ  ÚatomsÚfactorrH  s        rM   r<  r<  «  sz   € òô �$œŸ	™	Ô"Ø—	‘	ˆÜ×!Ñ!¤$§(¡(¬CÐ0CÀUÓ,KÓLˆØ%*Ö+ ��V“Ð+ˆÐ+Ü�y‰y˜%Ð Ð àÑ)¨$Ó/Ñ/Ð/ùò ,s   ÁBc                 ó$  — t        | t        t        f«      sJ ‚t        | t        «      ryt        | j                  j                  t
        j                  j                  j                  t
        j                  j                  j                  f«      ryy)z½ Utility to check if underlying object
    in SymBool is concrete value. Also returns
    true if integer is passed in.
    Args:
        a (SymBool or bool): Object to test if it bool
    TF)
rÇ   r    rØ   rÈ   rÑ   rR   r*  r+  ÚBooleanTrueÚBooleanFalserÏ   s    rM   rh   rh   Ã  sb   € ô �aœ'¤4˜Ô)Ð)Ð)ä�!”TÔØä�!—&‘&—+‘+¤§¡× 3Ñ 3× ?Ñ ?ÄÇÁ×ATÑAT×AaÑAaÐbÔcØàrN   c                 ón   — t        | t        j                  «      xr | j                  j	                  «       S rG   )rÇ   r²   r"   rÈ   ri   ©Úss    rM   ri   ri   Ô  s%   € Ü�aœŸ™Ó&ÒA¨1¯6©6×+?Ñ+?Ó+AÐArN   Úvalc              #   óð  K  — t        | t        «      r%t        | «      r| j                  j                  –— y y t        | t
        j                  «      r| –— y t        | t        t        t        f«      ry t        | t        t        f«      r| D ]  }t        |«      E d {  –—†  Œ y t        | «      r"t        | j                  «       «      E d {  –—†  y t        | t        j                   «      rdt        | j                  «       «      E d {  –—†  t        | j#                  «       «      E d {  –—†  t        | j%                  «       «      E d {  –—†  y | €y t'        d| › dt)        | «      › �«      ‚7 ŒÏ7 Œ¢7 Œh7 ŒI7 Œ*­w)Nz&cannot extract sympy expressions from ú )rÇ   r   Úis_symbolicrÈ   rÑ   rR   ÚBasicrË   rå   rØ   r:  rÁ   Ú_iterate_exprsr:   r  r²   ræ   r  r  ÚAssertionErrorrÊ   )rU  rT  s     rM   rZ  rZ  ×  s#  è ø€ Ü�#”xÔ ô �sÔØ—(‘(—-‘-Óð ä	�CœŸ™Ô	%Ø‹	Ü	�Cœ#œu¤dÐ+Ô	,ØÜ	�Cœ%¤˜Ô	'Øò 	)ˆAÜ% aÓ(×(Ñ(ñ	)ä	�sÔ	Ü! #§(¡(£*Ó-×-Ñ-Ü	�CœŸ™Ô	&Ü! #§(¡(£*Ó-×-Ð-Ü! #§*¡*£,Ó/×/Ð/Ü! #×"4Ñ"4Ó"6Ó7×7Ñ7Ø	ˆØäÐEÀcÀUÈ!ÌDÐQTËIÈ;ÐWÓXÐXð )øà-øà-øØ/øØ7úsZ   ‚BE6ÂE,Â.E6ÃE.Ã;E6ÄE0Ä E6Ä(E2Ä) E6Å	E4Å
#E6Å.E6Å0E6Å2E6Å4E6c                 óº   — | €
t        «       S t        | «      }	 t        |«      } |j                  j
                  d„ |D «       Ž S # t        $ r t        «       cY S w xY w)Nc              3   ó4   K  — | ]  }|j                   –— Œ y ­wrG   )rf   ©Ú.0Úes     rM   ú	<genexpr>zfree_symbols.<locals>.<genexpr>ù  s   è ø€ Ò*G¸a¨1¯>­>Ñ*Gùó   ‚)ÚsetrZ  ÚnextÚStopIterationrf   Úunion)rU  ÚitrÚ
first_exprs      rM   rf   rf   ï  s_   € Ø
€{Ü‹uˆÜ
˜Ó
€CðÜ˜#“Yˆ
ð )ˆ:×"Ñ"×(Ñ(Ñ*GÀ3Ô*GÐHÐHøô ò Ü‹uŠðús   ™A ÁAÁAc                 ó:   — t        d„ t        | «      D «       «       S )z)Faster version of bool(free_symbols(val))c              3   ó4   K  — | ]  }|j                   –— Œ y ­wrG   )Ú	is_numberr^  s     rM   ra  z#has_free_symbols.<locals>.<genexpr>ý  s   è ø€ Ò< 1�1—;•;Ñ<ùrb  )ÚallrZ  ©rU  s    rM   rl   rl   û  s   € äÑ<¬°sÓ(;Ô<Ó<Ð<Ð<rN   c                 ó”   — t        | «      D �ch c]/  }t        |t        j                  t        j                  f«      sŒ.|’Œ1 c}S c c}w rG   )rf   r=   r;   ÚUNBACKED_INTÚUNBACKED_FLOAT)rH  rT  s     rM   Úfree_unbacked_symbolsrq     s5   € ä# A“Öf�!¬.¸¼T×=NÑ=NÔPT×PcÑPcÐ<dÕ*eŠAÒfÐfùÒfs
   Ž/A¾Ac                 ó   — d| j                   v rÀt        | j                   d   t        j                  «      r™t        | j                   d   j                  j
                  t        j                  «      r^| j                  dk(  s,t        | j                   d   j                  j
                  «      r#| j                   d   j                  j
                  S y )NrU  r÷   )
rý   rÇ   r²   r"   rÈ   rÑ   rR   r  rü   rq  r#  s    rM   rg   rg     s�   € à�—‘ÑÜ�4—9‘9˜UÑ#¤U§\¡\Ô2Ü�4—9‘9˜UÑ#×(Ñ(×-Ñ-¬u¯|©|Ô<Ø	�‰�MÒ	!Ô%:¸4¿9¹9ÀUÑ;K×;PÑ;P×;UÑ;UÔ%Và�y‰y˜Ñ×$Ñ$×)Ñ)Ð)ØrN   c                 óÜ   — i }| j                   D ]Z  }t        |«      sŒ|j                  d   j                  j                  |vsŒ5|||j                  d   j                  j                  <   Œ\ |S )NrU  )Únodesrg   rý   rÈ   rÑ   )ÚgraphÚrrÈ   s      rM   Úfind_symbol_binding_fx_nodesrw    se   € Ø
€Aà—‘ò 1ˆÜ$ TÕ*¨t¯y©y¸Ñ/?×/DÑ/D×/IÑ/IÐQRÒ/RØ,0ˆAˆd�i‰i˜Ñ×#Ñ#×(Ñ(Ò)ð1ð €HrN   T©Úfrozenc                   ó(   — e Zd Zdefd„Zdedefd„Zy)rv   r›   c                  ó   — y)Nz#.cast_symbool_to_symint_guardless()rZ   ©rJ   s    rM   Ú__str__zConvertIntKey.__str__  s   € Ø4rN   Úbc                 ó   — t        |«      S )zGet the int value from bool)Ú cast_symbool_to_symint_guardless)rJ   r~  s     rM   rï   zConvertIntKey.get  s   € ä/°Ó2Ð2rN   N)rO   rP   rQ   Ústrr}  rØ   rË   rï   rZ   rN   rM   rv   rv     s!   „ ð5˜ó 5ð3�Tð 3˜cô 3rN   rv   c                   ó4   — e Zd ZU eed<   defd„Zdedefd„Zy)ÚCallMethodKeyÚnamer›   c                 ó"   — d| j                   › d�S )Nú.z()©r„  r|  s    rM   r}  zCallMethodKey.__str__(  s   € Ø�4—9‘9�+˜RÐ Ð rN   Úoc                 ó8   —  t        || j                  «      «       S )zCall the method on object)Úgetattrr„  ©rJ   rˆ  s     rM   rï   zCallMethodKey.get+  s   € à$Œw�q˜$Ÿ)™)Ó$Ó&Ð&rN   N©rO   rP   rQ   r�  rT   r}  r   rï   rZ   rN   rM   rƒ  rƒ  $  s&   … à
ƒIð!˜ó !ð'�Sð '˜Sô 'rN   rƒ  c                   ó4   — e Zd ZU eed<   defd„Zdedefd„Zy)ÚInnerTensorKeyÚ
inner_namer›   c                 ó    — d| j                   › �S ©Nr†  )r�  r|  s    rM   r}  zInnerTensorKey.__str__4  s   € Ø�4—?‘?Ð#Ð$Ð$rN   rˆ  c                 ó.   — t        || j                  «      S )zGet the inner tensor attribute)rŠ  r�  r‹  s     rM   rï   zInnerTensorKey.get7  s   € ä�q˜$Ÿ/™/Ó*Ð*rN   NrŒ  rZ   rN   rM   rŽ  rŽ  0  s&   … àƒOð%˜ó %ð+�Sð +˜Sô +rN   rŽ  c                   ó4   — e Zd ZU eed<   defd„Zdedefd„Zy)ÚDivideByKeyÚdivisorr›   c                 ó"   — d| j                   › d�S )Nz.__floordiv__(ú)©r•  r|  s    rM   r}  zDivideByKey.__str__@  s   € Ø §¡˜~¨QÐ/Ð/rN   rˆ  c                 ó    — || j                   z  S )zDivide object by divisorr˜  r‹  s     rM   rï   zDivideByKey.getC  s   € à�D—L‘LÑ Ð rN   N)rO   rP   rQ   rË   rT   r�  r}  rï   rZ   rN   rM   r”  r”  <  s&   … àƒLð0˜ó 0ð!�Sð !˜Sô !rN   r”  c           	      ó  ‡ ‡‡— ‰ €y‰ j                   }t        |«      Š‰�rë|s&t        j                  d|«       |j	                  «        	 ddt
        t        j                  t        j                  f   fˆˆˆ fd„Š ‰|d«      }|s\‰rZt        |t        j                  «      r)t        |j                  «       |j                  «       f«      nd}t!        d‰› d|› d	|› d
�«      ‚|��&|j#                  «       D �]  }t        j$                  ||«      }t        j$                  ||«      }	t        |	t&        «      sŒAt        |	j(                  j*                  x}
t        j                  «      sŒrt        |t&        «      r[|j(                  j*                  x}|
k7  r@t        |t        j                  «      r‰ j-                  |
|«       ŒÊ‰ j/                  |
|«       ŒÝt        |t&        «      rŒî‰ j/                  |
t        j0                  |«      «       �Œ |S y)aŽ  
    After having run fake tensor propagation and producing example_value
    result, traverse example_value looking for freshly bound unbacked
    symbols and record their paths for later.  It is an error if
    we have allocated an unbacked SymInt but it cannot be found in
    example_value.  (NB: this means if you have a multi-output
    function, you must call this on the tuple of tensor output, you
    cannot wait!)

    The peek parameter lets you check out what the bindings are without
    changing the affected list.  This is primarily useful for ensuring
    unbacked_var_to_val is promptly populated when propagate_real_tensors is on.
    Nzcompute_unbacked_bindings %sr›   c           
      óÌ  •— i }t        | t        t        f«      rVt        t	        | «      «      D ]=  }|j                   ‰| |   |t        j                  |«      fz   |�||   nd ¬«      «       Œ? |S t        | «      rM| j                  «       \  }}|D ]3  }t        | |«      }|j                   ‰||t        |«      fz   «      «       Œ5 |S t        | t        j                  «      �r|j                   ‰| j                  «       |t        d«      fz   | j                   �| j                   j                  «       nd ¬«      «       |j                   ‰| j#                  «       |t        d«      fz   | j                   �| j                   j#                  «       nd ¬«      «       |j                   ‰| j%                  «       |t        d«      fz   | j                   �| j                   j%                  «       nd ¬«      «       |S t        | t        j&                  t        j(                  f«      r`t        | j*                  j,                  x}	t.        j0                  «      r0|	‰v r,|||	<   |�‰j3                  |	|«       ‰j5                  |	«       |S t        | t        j&                  «      rìt        | j*                  j,                  x}	t.        j6                  «      r¼t	        |	j8                  «      dk(  r¤t        |	j8                  d   x}
t.        j:                  «      r{t        |	j8                  d   x}t.        j0                  «      rR|‰v rN|t=        t?        |
«      «      fz   ||	<   |�‰j3                  |	|t?        |
«      z  «       ‰j5                  |«       |S t        | t        j@                  «      rÄt        | j*                  j,                  x}	t.        jB                  «      r”t        |	jD                  t.        j0                  «      rp|	jF                  dk(  ra|	jD                  ‰v rS|tI        «       fz   ||	jD                  <   |�‰j3                  |	t?        |«      «       ‰j5                  |	jD                  «       |S )N)Úrealr  r  r  rù   r   r½   )%rÇ   r:  rÁ   Úranger  Úupdaterþ   ÚSequenceKeyr&   Ú__tensor_flatten__rŠ  rŽ  r²   ræ   r  rƒ  Úreal_tensorr  r  r"   r!   rÈ   Ú_exprrR   r  Úset_unbacked_var_to_valÚremover1  rK   rÔ   r”  rË   r    r  r  r	  rv   )rÄ   r  rœ  rv  rê   ÚattrsÚ_ÚattrÚsubrT  r  r	  Úfree_unbacked_symbols_with_pathÚpendingrð   s               €€€rM   r©  zBcompute_unbacked_bindings.<locals>.free_unbacked_symbols_with_path_  s¡  ø€ ð ˆAÜ˜!œe¤T˜]Ô+Üœs 1›v›ò �AØ—H‘HÙ7Ø˜a™D $¬&×*<Ñ*<¸QÓ*?Ð)AÑ"AØ,0Ð,<  a¢À$ôõðð` ˆHôS /¨qÔ1à×/Ñ/Ó1‘��qØ!ò �DÜ! ! TÓ*�CØ—H‘HÙ7¸¸TÄ^ÐTXÓEYÐD[Ñ=[Ó\õððL ˆHôC ˜AœuŸ|™|Õ,Ø—‘Ù3ØŸ™› $¬-¸Ó*?Ð)AÑ"AØ56·]±]Ð5N˜QŸ]™]×/Ñ/Ô1ÐTXôôð —‘Ù3ØŸ™›
 D¬M¸(Ó,CÐ+EÑ$EØ78·}±}Ð7P˜QŸ]™]×1Ñ1Ô3ÐVZôôð —‘Ù3Ø×(Ñ(Ó*¨D´MÐBRÓ4SÐ3UÑ,UØ?@¿}¹}Ð?X˜QŸ]™]×9Ñ9Ô;Ð^bôôðh ˆHôU ˜1œuŸ|™|¬U¯^©^Ð<Ô=Ü A§F¡F§L¡LÐ0˜q´%·,±,Ô?Ø˜‘Là��!‘ØÐ#Ø×5Ñ5°a¸Ô>Ø—‘˜qÔ!ðF ˆHô9 ˜1œeŸl™lÔ+Ü A§F¡F§L¡LÐ0˜q´%·)±)Ô<Ü˜Ÿ™“K 1Ò$Ü a§f¡f¨Q¡iÐ/˜s´·±Ô?Ü a§f¡f¨Q¡iÐ/˜s´·±Ô>Ø˜7‘Nð œ{¬3¨s«8Ó4Ð6Ñ6��!‘ØÐ#Ø×5Ñ5°a¸ÄÀSÃÑ9IÔJØ—‘˜sÔ#ð" ˆHô ˜1œeŸm™mÔ,Ü A§F¡F§L¡LÐ0˜q´%·(±(Ô;ä˜qŸu™u¤e§l¡lÔ3Ø—E‘E˜Q’JØ—E‘E˜WÑ$à¤=£?Ð"4Ñ4��!—%‘%‘ØÐ#Ø×5Ñ5°a¼¸T»ÔCØ—‘˜qŸu™uÔ%àˆHrN   rZ   r×   zPending unbacked symbols z not in returned outputs rW  zÛ.
Did you accidentally call new_dynamic_size() or item() more times than you needed to in your fake implementation?
For more help, see https://docs.google.com/document/d/1RWrH-3wLEpzR9kCS6gGBNen_-Fs-8PVbWWFE5AcgeWE/editrG   )Úpending_fresh_unbacked_symbolsrc  r}   r  Úclearr   rR   r  rþ   ÚKeyPathrÇ   r²   ræ   Úreprr  r  rX   Úvaluesrÿ   r   rÈ   rÑ   r  Ú_eliminate_unbackedÚsympify)rð   r  Úold_example_valueÚpeekÚfsÚsymbol_to_pathÚextraÚkeypathÚold_symÚnew_symÚnew_sÚold_sr©  rª  s   `           @@rM   ru   ru   H  sÐ  ú€ ð ÐØØ	×	1Ñ	1€BÜ�"‹g€GÚÙÜ�H‰HÐ3°RÔ8Ø�H‰HŒJð ñU	ä”%—,‘,¤§¡Ð.Ñ/÷U	ñn 9¸ÈÓKˆÙ™ô ˜m¬U¯\©\Ô:ô �m×*Ñ*Ó,¨m×.JÑ.JÓ.LÐMÔNàð ô
 0Ø+¨G¨9Ð4MÈmÈ_Ð\]Ð^cÐ]dð ezð zóð ð( Ñ(Ø)×0Ñ0Ó2ó U�Ü Ÿ.™.Ð):¸GÓD�Ü Ÿ.™.¨¸Ó@�ä˜w¬Õ1Ü¨¯©×(9Ñ(9Ð9˜u¼5¿<¹<ÕHä! '¬8Ô4À7Ç<Á<×CTÑCTÐ:T¸%ÐY^Ò9^Ü% e¬U¯\©\Ô:Ø%×9Ñ9¸%ÀÕGà%×9Ñ9¸%ÀÕGÜ'¨´Õ:Ø!×5Ñ5°e¼U¿]¹]È7Ó=SÖTðUð ÐðO rN   c                 ó„   — t        | t        «      r&| j                  j                  «       rt	        | «      S yt        | «      S )a+  
    Returns True only if we can tell that a is True, possibly introducing
    a guard in the process.  If a depends on some unbacked SymInt, we may
    return False even though there may exist a possible value of the SymInt
    that would cause the expression to return True.

    When is it appropriate to use definitely_true?  First, if you can use
    a higher level combinator like parallel_or/parallel_and, prefer using
    those instead, they are definitely safe (modulo short-circuiting).
    Second, it can be used if the program would behave equivalently if
    definitely_true always returned False (parallel_or/parallel_and are
    examples of this pattern, modulo short-circuiting).  Finally, it even
    be OK if the program wouldn't behave equivalently, so long as the
    change is semantics preserving.  It can be semantics preserving if
    the program errors in more cases than it did previously (but otherwise
    behaves identically), or if it changes some quantity in a way that
    doesn't matter (e.g., strides often fall in this bucket.)
    F©rÇ   r    rÈ   rÎ   Ú
guard_boolrØ   rÏ   s    rM   Údefinitely_truer¿  ã  s2   € ô& �!”WÔØ�6‰6�?‰?ÔÜ˜a“=Ð àÜ�‹7€NrN   c                 óˆ   — t        | t        «      r'| j                  j                  «       rt	        | «       S yt        | «       S )aK  
    Returns True only if we can tell that a is False, possibly introducing
    a guard in the process.  If a depends on some unbacked SymInt, we may
    return False even though there may exist a possible value of the SymInt
    that would cause the expression a to be False.  See definitely_true
    for more usage guidance.
    Fr½  rÏ   s    rM   Údefinitely_falserÁ  ý  s8   € ô �!”WÔØ�6‰6�?‰?ÔÜ! !“}Ð$Ð$àÜ�A‹wˆ;ÐrN   rH  c                 ó.  — t        | t        «      rM| j                  j                  }| j                  j                  }	 |j                  |«      }|�t        |«      S 	 yt        | t        «      sJ ‚| S # t        $ r t        j                  d|«       Y yw xY w)aA  Returns True if x can be simplified to a constant and is true.

    .. note::
        This function doesn't introduce new guards, so the expression may end
        up evaluating to true at runtime even if this function returns False.

    Args:
        x (bool, SymBool): The expression to try statically evaluating

    zCould not simplify %sF)
rÇ   r    rÈ   rÑ   rð   Ú_maybe_evaluate_staticrØ   Ú	Exceptionr}   r~   )rH  rÑ   rð   Ú
simplifieds       rM   rr   rr     s’   € ô �!”WÔØ�v‰v�{‰{ˆØ—F‘F×$Ñ$ˆ	ð	5Ø"×9Ñ9¸$Ó?ˆJØÐ%Ü˜JÓ'Ð'ð &ð Ü�aœÔÐÐØ€Høô	 ò 	5Ü�I‰IÐ-¨tÕ4Øð	5ús   ¾A2 Á2BÂBc                  ód   — t        d„ | D «       «      ryt        d„ | D «       «      ryt        | «      S )z‰
    Evaluate the logical OR of several arguments, avoiding guarding on
    unbacked SymInts if another argument is definitely True.
    c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wrG   )rr   ©r_  rÄ   s     rM   ra  zparallel_or.<locals>.<genexpr>*  s   è ø€ Ò
2¨Ô  ×#Ñ
2ùó   ‚Tc              3   ó2   K  — | ]  }t        |«      –— Œ y ­wrG   )r¿  rÈ  s     rM   ra  zparallel_or.<locals>.<genexpr>,  s   è ø€ Ò
, !Œ?˜1×Ñ
,ùrÉ  )Úany©rK   s    rM   Úparallel_orrÍ  %  s0   € ô
 Ñ
2¨TÔ
2Ô2ØÜ
Ñ
, tÔ
,Ô,ØÜˆt‹9ÐrN   c                  ód   — t        d„ | D «       «      ryt        d„ | D «       «      ryt        | «      S )z�
    Evaluate the logical FALSE of several arguments, avoiding guarding on
    unbacked SymInts if another argument is definitely False.
    c              3   óX   K  — | ]"  }t        t        j                  |«      «      –— Œ$ y ­wrG   )rr   r²   Úsym_notrÈ  s     rM   ra  zparallel_and.<locals>.<genexpr>5  s   è ø€ Ò
A°qÔ ¤§¡¨qÓ!1×2Ñ
Aùs   ‚(*Fc              3   ó2   K  — | ]  }t        |«      –— Œ y ­wrG   )rÁ  rÈ  s     rM   ra  zparallel_and.<locals>.<genexpr>7  s   è ø€ Ò
- 1Ô˜A×Ñ
-ùrÉ  )rË  rl  rÌ  s    rM   Úparallel_andrÒ  0  s0   € ô
 Ñ
A¸DÔ
AÔAØÜ
Ñ
-¨Ô
-Ô-ØÜˆt‹9ÐrN   c                 óê  — t        | t        «      rt        |t        «      s t        | t        «      r\t        |t        «      rLt        | «      t        |«      k7  ryt	        j
                  t        j                  t        t        | |«      d«      S t        | t        t        j                  f«      r%t        |t        t        j                  f«      r| |k(  S t        dt        | «      › dt        |«      › �«      ‚)z”
    Like ==, but when run on list/tuple, it will recursively test equality
    and use sym_and to join the results together, without guarding.
    FTzunexpected sym_eq between rW  )rÇ   r:  rÁ   r  r†   rK  ÚoperatorÚand_r5  rm   rË   r²   r"   r[  rÊ   )rH  Úys     rM   rm   rm   ;  s°   € ô
 	�1”eÔ¤¨A¬uÔ!5¼:ÀaÌÔ;NÔS]Ð^_ÔaeÔSfÜˆq‹6”S˜“VÒØÜ×Ñ¤§¡¬s´6¸1¸aÓ/@À$ÓGÐGÜ	�AœœUŸ\™\Ð*Ô	+´
¸1¼sÄEÇLÁLÐ>QÔ0RØ�A‰vˆäÐ9¼$¸q»'¸À!ÄDÈÃGÀ9ÐMÓNÐNrN   c                 óä   — t        | t        t        f«      rt        | «      S t        | t        t
        f«      rt        | «      S t        | t        t        f«      rt        | «      S t        d| › �«      ‚)Nzunrecognized scalar )rÇ   r    rØ   r¾  r"   rË   r`   r!   rå   ra   r[  rÏ   s    rM   rb   rb   I  s^   € Ü�!”gœt�_Ô%Ü˜!‹}ÐÜ	�Aœ¤�}Ô	%Ü˜‹|ÐÜ	�Aœ¤%Ð(Ô	)Ü˜1‹~ÐäÐ3°A°3Ð7Ó8Ð8rN   rT  Úcompiler_minÚcompiler_maxc                 ó*   — | j                  |||«       y rG   )Úconstrain_symbol_range)rð   rT  rØ  rÙ  s       rM   Ú_constrain_symbol_rangerÜ  T  s   € Ø×$Ñ$ Q¨°lÕCrN   c                 óD  — t        | t        «      r�t        | j                  t        «      rut        | j                  j                  t
        j                  «      rF| j                  j                  j                  | j                  j                  «      rt        | «       yyyyy)ax  
    Don't use this directly; use torch._check_is_size instead.

    This is a softer version of _constrain_range_for_size (with min=0,
    max=Inf).  Instead of forcibly constraining a variable (and erroring if we
    failed to constrain it), it will simply advise us that a size is
    constrained in some way.  We will always defer a runtime assert for this
    constraint if we cannot prove it at compile-time, but we we only
    *sometimes* learn useful extra information at compile-time with this
    information.  This is in contrast to constrain_range_for_size, where if
    you don't call that on a fresh unbacked symint, chances are we will choke.

    TODO: Make Dynamo handle this appropriately if this is seen in Dynamo-ed
    code.  Right now this is only really used in code with AOTAutograd trace
    through, so it is not a big problem that this isn't supported, but in
    principle all of this code should be Dynamo'able too.

    TODO: I didn't support min/max because I didn't have a use case where this
    actually helped.  In principle we can support it, it just makes the
    implementation below more complicated.
    N)
rÇ   r"   rÈ   r   rÑ   rR   r  rð   Úis_unbacked_symintÚ_constrain_range_for_sizerÏ   s    rM   Ú_advise_is_sizerà  X  so   € ôD 	�1”fÔÜ�q—v‘vœwÔ'Ü�q—v‘v—{‘{¤E§L¡LÔ1Ø�F‰F×Ñ×/Ñ/°·±·±Ô<ä! !Õ$ð =ð 2ð (ð 	rN   ÚminÚmaxc                 óT  — t        | t        t        f«      rt        d«      ‚t        | t        «      sJ d«       ‚t        | j
                  j                  t        j                  «      sJ d«       ‚| j
                  j                  j                  | j
                  j                  ||«       y)z=
    This function is NOT INTENDED to be used by itself.
    z$Constraining SymFloat/SymBool is nyiz#can only constrain range for SymIntúconstraining non-Symbols NYIN)rÇ   r!   r    Ú
ValueErrorr"   rÈ   rÑ   rR   r  rð   rß  ©rÄ   rá  râ  s      rM   rß  rß  �  s{   € ô
 �!”h¤Ð(Ô)ÜÐ?Ó@Ð@ä�aœÔ ÐGÐ"GÓGÐ Ü�a—f‘f—k‘k¤5§<¡<Ô0ÐPÐ2PÓPÐ0à‡F�F×Ñ×.Ñ.¨q¯v©v¯{©{¸CÀÕErN   )râ  c          	      ó"  — |€t          }|€t         }||k  rt        d«      ‚t        | t        «      r#|| cxk  r|k  sn t        d| › d|› d|› d�«      ‚y| j                  j
                  j                  | j                  j                  ||«       y)aØ  
    Applies a constraint that the passed in SymInt must lie between min-max
    inclusive-inclusive, WITHOUT introducing a guard on the SymInt (meaning
    that it can be used on unbacked SymInts).  If min/max are None, we assume
    that the dimension is unbounded in that direction.  Repeated application
    of constrain_range intersects the ranges.  This is a fairly low level API
    that doesn't have a lot of safety guarantees (TODO: provide higher level
    APIs).

    Currently, we use this API in the following circumstance: when we allocate
    an unbacked SymInt, denoting an integer quantity which is data dependent,
    we ordinarily do not know anything about what values it may take.  This
    means that any sort of guard on it will immediately fail.  However, in
    many cases, we know something about the unbacked SymInt: for example, we
    know that nonzero(x).size(0) must be >= 0.  We use constrain_range to
    narrow the possible range, declaring that negative symbols are impossible.
    This permits to definitely answer True to queries like 'nnz >= 0', even if
    we don't know what the actual (hinted) value of 'nnz' is.  In fact, we
    actually use constrain_range to unsoundly discharge common guards: for an
    unbacked SymInt produced by nonzero, we will also assume that it is not
    equal to 0/1 (even though these are perfectly possible values at runtime),
    because we generally expect graphs that are valid for N=2 to also be valid
    for N=1.
    NúoMaximum value to constrain_as_size can't be less than the specified min value, received min={min} and max={max}úInvalid value ú for range [ú:ú])r0   rå  rÇ   rË   rÈ   rð   Ú_constrain_rangerÑ   ræ  s      rM   Úconstrain_rangerî  �  s‘   € ð2 €{ÜˆgˆØ
€{Üˆà
ˆS‚yÜð/ó
ð 	
ô
 �!”SÔØ�q”˜C”Ü˜~¨a¨S°¸S¸EÀÀ3À%ÀqÐIÓJÐJØà‡F�F×Ñ×%Ñ% a§f¡f§k¡k°3¸Õ<rN   r~  c                 óÒ   — t        | t        «      s/t        |t        «      s| |k(  sJ ‚y|j                  j                  }n| j                  j                  }|j	                  | |«       y)z¡
    Given two SymInts, constrain them so that they must be equal.  NB:
    this will not work with SymInts that represent nontrivial expressions
    (yet!)
    N)rÇ   r"   rÈ   rð   Ú_constrain_unify)rÄ   r~  rð   s      rM   Úconstrain_unifyrñ  »  sT   € ô �aœÔ Ü˜!œVÔ$Ø˜’6ˆM�6ØàŸ™×(Ñ(‰Ià—F‘F×$Ñ$ˆ	à×Ñ˜q !Õ$rN   Úskipc                 ó0  — t        | t        «      rmt        j                  «       }t	        |dz   «      D ]  }|j
                  }Œ | j                  j                  |j                  j                  |j                  «      S t        | «      t        u sJ | «       ‚| S rD  )rÇ   r    r°   Úcurrentframer�  Úf_backrÈ   Úexpect_trueÚf_codeÚco_filenameÚf_linenorÊ   rØ   )rÄ   rò  Úframer¦  s       rM   rö  rö  ì  sy   € Ü�!”WÔä×$Ñ$Ó&ˆÜ�t˜a‘x“ò 	!ˆAØ—L‘L‰Eð	!à�v‰v×!Ñ! %§,¡,×":Ñ":¸E¿N¹NÓKÐKÜ�‹7”d‰?Ð˜AÓˆ?Ø€HrN   c                 óŽ   — t        | t        «      r| j                  j                  dd«      S t	        | «      t
        u sJ | «       ‚| S ©Nr×   r   )rÇ   r    rÈ   r¾  rÊ   rØ   rÏ   s    rM   r¾  r¾  ö  s=   € Ü�!”WÔØ�v‰v× Ñ   QÓ'Ð'Ü�‹7”d‰?Ð˜AÓˆ?Ø€HrN   c                 óŽ   — t        | t        «      r| j                  j                  dd«      S t	        | «      t
        u sJ | «       ‚| S rü  )rÇ   r"   rÈ   r`   rÊ   rË   rÏ   s    rM   r`   r`   ü  s=   € Ü�!”VÔØ�v‰v×Ñ  AÓ&Ð&Ü�‹7”c‰>Ð˜1Óˆ>Ø€HrN   c                 óŒ   — t        | t        «      r| j                  j                  dd«      S t        | t        «      sJ | «       ‚| S rü  )rÇ   r!   rÈ   ra   rå   rÏ   s    rM   ra   ra     s=   € Ü�!”XÔØ�v‰v×!Ñ! " aÓ(Ð(Ü�aœÔÐ" Ó"ÐØ€HrN   c                 óŽ   — | j                   j                  D �cg c]!  }|j                  dk(  sŒ|j                  d   ‘Œ# c}S c c}w )Nr÷   rU  )ru  rt  rü   rý   ©Úgmrô   s     rM   Úfx_placeholder_valsr  	  s1   € Ø#%§8¡8§>¡>ÖK˜a°Q·T±T¸]Ó5JˆA�F‰F�5‹MÒKÐKùÒKs
   ™A®Ac                 óˆ   — | j                   j                  D �cg c]  }|j                  dk(  sŒ|j                  ‘Œ  c}S c c}w )Nr÷   )ru  rt  rü   r   r   s     rM   Úfx_placeholder_targetsr    s-   € Ø Ÿh™hŸn™nÖF˜°·±¸Ó0EˆA�H‹HÒFÐFùÒFs   ™?®?©Úignore_staticc                óP   — | j                   j                  t        | «      ||¬«      S )Nr  )rð   Úevaluate_guards_for_argsr  )r  r  rK   s      rM   Úeval_guardsr	    s%   € Ø�<‰<×0Ñ0Ô1DÀRÓ1HÈ$Ð^kÐ0ÓlÐlrN   c                 óL   — | j                   j                  t        | «      |«      S rG   )rð   Úbind_symbolsr  )r  rK   s     rM   r  r    s   € Ø�<‰<×$Ñ$Ô%8¸Ó%<¸dÓCÐCrN   c                   ó$   — e Zd ZdZdZdZdZdZdZy)Ú
DimDynamicai  
    Controls how to perform symbol allocation for a dimension.  It is always
    sound to default this to DYNAMIC, but the policies DUCK and STATIC can
    result in better trace-time and compile-time performance, as they reduce
    the number of allocated symbols and generally make your graph more static.

    NB: If we notice you've applied a constraint to the dimension, we will
    force it to DYNAMIC for simplicity.

    DimDynamic is controlled by a variety of higher level UX features.
    Currently:

    - In eager mode, the default policy is DUCK.
        - The default is changed to STATIC with assume_static_by_default.
        - An individual dim is marked DYNAMIC if you mark_dynamic_dim.
    - In export mode, the default policy is STATIC.
        - An individual dim is marked DYNAMIC if you specify it in
          dynamic_shapes passed to export.
    r   r½   rù   é   é   N)	rO   rP   rQ   Ú__doc__ÚDYNAMICÚDUCKÚSTATICÚSIZE_LIKE_UNBACKEDÚINFER_STRIDErZ   rN   rM   r  r    s%   „ ñð( €Gð €Dà€FàÐà�LrN   r  c                   ó   — e Zd ZU eed<   y)Ú
ConstraintÚ	warn_onlyN)rO   rP   rQ   rØ   rT   rZ   rN   rM   r  r  I  s   … à„OrN   r  c                   ó(   — e Zd ZU dZeed<   defd„Zy)ÚStrictMinMaxConstrainta-  
    For clients: the size at this dimension must be within 'vr' (which
    specifies a lower and upper bound, inclusive-inclusive) AND it
    must be non-negative and should not be 0 or 1 (but see NB below).

    For backends: there must not be any guards on this dimension which
    are not implied by the given lower and upper bound.  Regardless of
    the lower bound, the backend can assume the size is non-negative
    and that it is not 0 or 1.

    An unbounded StrictMinMaxConstraint can be thought of as a strict version
    of "RelaxedUnspecConstraint".

    NB: Export will often unsoundly assume that a graph works for 0/1, even
    though at trace time we assumed size is not 0 or 1.  The idea is that
    if we produce a graph that works for a range of values, it will be OK
    for N=0/1 too.
    ÚvrÚsourcec                 ó‚   — | j                   j                  › d|j                  «       › d| j                   j                  › �S )zFormat the constrain equationú <= )r  Úlowerr„  Úupper©rJ   r  s     rM   ÚrenderzStrictMinMaxConstraint.renderc  s1   € ð —'‘'—-‘-�  V§[¡[£] O°4¸¿¹¿¹°ÐGÐGrN   N)rO   rP   rQ   r  r3   rT   r$   r"  rZ   rN   rM   r  r  M  s   … ñð$ 	ƒOðH˜Vô HrN   r  c                   ó   — e Zd ZdZdefd„Zy)ÚRelaxedUnspecConstrainta  
    For clients: no explicit constraint; constraint is whatever is implicitly
    inferred by guards from tracing.

    For backends: there must exist at least TWO possible values for the
    size at this dimension which satisfy the guards for this dimension.

    In other words, this constraint helps us distinguish between "we don't
    care if this dimension specializes or not" versus "this dimension must be
    unspecialized."  However, this constraint doesn't say very much about what
    specialization is permitted; for example, if we guard on a size being
    even, this would still be acceptable under an unspec constraint.  This
    makes RelaxedUnspecConstraint useful for eager mode, where your backend compiler
    may add constraints to otherwise dynamic dimensions; we can't assert that
    there are NO guards as this is brittle because compilers should be able to
    add extra constraints.  If you want to assert that there are no guards,
    use StrictMinMaxConstraint with an unbounded ValueRanges.
    r  c                 ó*   — d|j                  «       › d�S )NzRelaxedUnspecConstraint(r—  r‡  r!  s     rM   r"  zRelaxedUnspecConstraint.render|  s   € Ø)¨&¯+©+«-¨¸Ð:Ð:rN   N)rO   rP   rQ   r  r$   r"  rZ   rN   rM   r$  r$  h  s   „ ñð$;˜Vô ;rN   r$  c                   óâ   — e Zd ZU dZeeeef      ed<   eeeeee	j                  f   ee	j                  ge	j                  f   f      ed<   ee	j                     ed<   d„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zy)ÚEqualityConstrainta  
    Represent and decide various kinds of equality constraints between input sources.

    A "source pair" is a pair of input sources for dynamic dimensions that
    are specified equal. We represent `source_pairs` in a union-find forest
    so that we can efficiently check whether two such sources are transitively equal.

    A "derived equality" relates an input source to an expression over a root.
    The root can be another input source, corresponding to some dynamic dimension,
    or a phantom symbol that does not directly represent any dynamic dimension. We
    represent `derived_equalities` involving input sources in a transitively-closed map
    so that we can efficiently check whether an input source is transitively equal to
    a given expression over another input source.
    (NOTE: In contrast, it is easy to decide whether an input source is transitively equal
    to a given expression over a phantom symbol; such expressions are already in canonical
    form and so the problem reduces to symbolic expression equality.)
    Úsource_pairsÚderived_equalitiesÚphantom_symbolsc                 óþ  — i }t         j                  | d|«       i }t         j                  | d|«       | j                  D ]5  \  }}| j                  | j	                  |«      | j	                  |«      «       Œ7 | j
                  D ]x  \  }}}t        |t        j                  «      r% ||«      | j                  | j	                  |«      <   ŒF || j                  |«      «      | j                  | j	                  |«      <   Œz y)aá  Pre-processing to answer queries `is_equal` and `is_derived` below.

        Example: Suppose we are given:
          source_pairs [a = b, b = c]
          derived_equalities [d = c + 1, e = d - 1]
        We first construct a union find with source_pairs:
          _parents = {a: a, b: a, c: a}
        Then we compute canonical symbolic expressions, recursively applying derived_equalities
        until we bottom out:
          _defs = {d: c + 1, e: (c + 1) - 1 aka c}
        Ú_parentsÚ_defsN)ÚobjectÚ__setattr__r(  Ú_unionÚ_findr)  rÇ   rR   r  r-  Ú_rewrite)rJ   r,  r-  Úsource1Úsource2r  ÚrootÚfns           rM   Ú__post_init__z EqualityConstraint.__post_init__›  sà   € ð *,ˆÜ×Ñ˜4 ¨XÔ6ð +-ˆÜ×Ñ˜4 ¨%Ô0à $× 1Ñ 1ò 	BÑˆG�Wà�K‰K˜Ÿ
™
 7Ó+¨T¯Z©Z¸Ó-@ÕAð	Bð !%× 7Ñ 7ò 	IÑˆF�D˜"ô ˜$¤§¡Ô-Ù13°D³�—
‘
˜4Ÿ:™: fÓ-Ò.á13°D·M±MÀ$Ó4GÓ1H�—
‘
˜4Ÿ:™: fÓ-Ò.ñ	IrN   c                 ó^   — || j                   v r| j                  | j                   |   «      S |S rG   )r,  r1  r!  s     rM   r1  zEqualityConstraint._find½  s+   € à�T—]‘]Ñ"Ø—:‘:˜dŸm™m¨FÑ3Ó4Ð4àˆMrN   c                 ó.   — ||k7  r|| j                   |<   y y rG   )r,  )rJ   Úroot1Úroot2s      rM   r0  zEqualityConstraint._unionÄ  s   € à�EŠ>Ø#(ˆD�M‰M˜%Ò ð rN   c                 ó¤   — | j                  |«      }|| j                  v r| j                  |   S t        j                  |j	                  «       «      S rG   )r1  r-  rR   r  r„  )rJ   Úsrcs     rM   r2  zEqualityConstraint._rewriteÉ  sB   € à�j‰j˜‹oˆØ�$—*‘*Ñð —:‘:˜c‘?Ð"ô —<‘< §¡£
Ó+Ð+rN   c                 ót   — | j                  |«      | j                  |«      k(  xs | j                  ||d„ «      S )Nc                 ó   — | S rG   rZ   ©rH  s    rM   râ   z-EqualityConstraint.is_equal.<locals>.<lambda>Ú  s   € ¸€ rN   )r1  Ú
is_derived)rJ   r3  r4  s      rM   Úis_equalzEqualityConstraint.is_equalÕ  s8   € ð �J‰J�wÓ 4§:¡:¨gÓ#6Ñ6ò ;à�O‰O˜G W©kÓ:ð		
rN   c                 óT   — | j                  |«       || j                  |«      «      k(  S rG   )r2  )rJ   r=  Ú
symbol_srcr6  s       rM   rA  zEqualityConstraint.is_derivedÝ  s$   € à�}‰}˜SÓ!¡R¨¯©°jÓ(AÓ%BÑBÐBrN   N)rO   rP   rQ   r  r   r   r$   rT   r   rR   r  r
   rS   r7  r1  r0  r2  rB  rA  rZ   rN   rM   r'  r'  „  s�   … ñð" �u˜V V˜^Ñ,Ñ-Ó-Ø˜U 6¨5°¸¿¹Ð1EÑ+FÈÐRW×R\ÑR\ÐQ]Ð_d×_iÑ_iÐQiÑHjÐ#jÑkÑlÓlØ˜%Ÿ,™,Ñ'Ó'ò IòDò)ò

,ò
óCrN   r'  c                 ób   — t        | t        «      sJ d«       ‚t        | «      t        usJ d«       ‚y )NzInvalid symbolic_context objectz%Illegal usage of symbolic_context ABC)rÇ   rn   rÊ   ©Úsymbolic_contexts    rM   Ú_assert_symbol_contextrH  â  s3   € ÜÐ&¬Ô8Ð[Ð:[Ó[Ð8ÜÐ Ó!¬Ñ8ÐaÐ:aÓaÑ8rN   c                 óz  — t        | t        j                  t        j                  f«      rxt	        | j
                  «      dkD  ry| j
                  \  }}t        |«      xr t        |t        j                  «      xs' t        |t        j                  «      xr t        |«      S t        | t        j                  «      S )Nrù   F)	rÇ   rR   r=  r1  r  rK   Ú_is_supported_equivalencerÔ   r  )rÑ   r  r	  s      rM   rJ  rJ  æ  sŠ   € ô �$œŸ™¤E§I¡IÐ.Ô/Üˆt�y‰y‹>˜AÒØØ—9‘9‰ˆˆSä& sÓ+ÒN´
¸3ÄÇÁÓ0Nò PÜ˜œUŸ]™]Ó+ÒNÔ0IÈ#Ó0Nð	
ô �dœEŸL™LÓ)Ð)rN   c                 ó0  — | j                  t        j                  j                  j                  j
                  t        j                  j                  j                  j                  t        j                  j                  j                  j                  «      S )zL
    Add functions that our sympy interpreter can't reify into FX nodes
    )Úhasr²   ÚutilsÚ_sympyÚ	functionsÚToFloatÚ
TruncToIntr.   rÙ   s    rM   Ú#_has_uninterpretable_sympy_functionrR  ô  s`   € ð �8‰8Ü�‰×Ñ×$Ñ$×,Ñ,Ü�‰×Ñ×$Ñ$×/Ñ/Ü�‰×Ñ×$Ñ$×.Ñ.óð rN   c                   ó   — e Zd ZdZy)rn   aS  
    Data structure specifying how we should create symbols in
    ``create_symbolic_sizes_strides_storage_offset``; e.g., should
    they be static or dynamic.

    This is an abstract base class because we are probably going to add
    another version of this that says "use exactly these SymInts, don't
    allocate fresh symbols."
    N)rO   rP   rQ   r  rZ   rN   rM   rn   rn   þ  s   „ òrN   rn   c                   óx   — e Zd ZU dZee   ed<   dZee   ed<   dZee	   ed<   dZ
ee	   ed<   dZee   ed<   d„ Zy)	ro   zÙ
    Create symbols in ``create_symbolic_sizes_strides_storage_offset`` via
    a symbolic_context determination as given by ``DimDynamic`` and ``DimConstraint``.
    This will cause fresh symbols to be allocated
    Údynamic_sizesNÚdynamic_stridesÚconstraint_sizesÚconstraint_stridesÚview_base_contextc                 ó¸  — | j                   €<t        j                  | dt        j                  gt        | j                  «      z  «       | j                  €.t        j                  | dd gt        | j                  «      z  «       | j                  €.t        j                  | dd gt        | j                  «      z  «       t        d„ | j                   D «       «      sJ ‚y )NrV  rW  rX  c              3   ó~   K  — | ]5  }|t         j                  t         j                  t         j                  fv –— Œ7 y ­wrG   )r  r  r  r  )r_  r  s     rM   ra  z9StatelessSymbolicContext.__post_init__.<locals>.<genexpr>#  s-   è ø€ ÒÐ`f�6œj×5Ñ5´z×7IÑ7IÌ:Ï?É?Ð[Ô[Ñùs   ‚;=)
rV  r.  r/  r  r  r  rU  rW  rX  rl  r|  s    rM   r7  z&StatelessSymbolicContext.__post_init__  s¹   € Ø×ÑÐ'Ü×Ñ˜tÐ%6¼×9PÑ9PÐ8QÔTWÐX\×XjÑXjÓTkÑ8kÔlØ× Ñ Ð(Ü×Ñ˜tÐ%7¸$¸Ä#Àd×FXÑFXÓBYÑ9YÔZØ×"Ñ"Ð*Ü×Ñ˜tÐ%9¸D¸6ÄCÈ×HZÑHZÓD[Ñ;[Ô\ÜÑÐjn×j~Ñj~ÔÔÐÑrN   )rO   rP   rQ   r  ÚDimListr  rT   rV  rW  ÚDimConstraintrX  rY  r   rn   r7  rZ   rN   rM   ro   ro     s[   … ñð
 ˜:Ñ&Ó&Ø+/€O�W˜ZÑ(Ó/Ø/3Ð�g˜mÑ,Ó3Ø15Ð˜ Ñ.Ó5ð 48Ð�x Ñ0Ó7ó@rN   ro   c                   óP   ‡ — e Zd ZU dZdZeed<   dZee	ed   f   ed<   ˆ fd„Z
ˆ xZS )rp   a   
    Create symbols in ``create_symbolic_sizes_strides_storage_offset`` via
    a symbolic_context determination as given by a cache of Source:Symbol. A cache hit
    will reuse a stored symbol, and a cache miss will write to this cache.

    This behaves like StatelessSymbolicContext, except the cache supersedes the
    other values - dynamic_sizes and constraint_sizes will not be read if we cache
    hit.

    It is the cache owners responsibility to maintain the lifecycle of the cache
    w/r/t different shape_envs, clearing, etc.
    NÚtensor_source)r?   ú
sympy.ExprÚ#shape_env_to_source_to_symbol_cachec                 ó†   •— t         ‰| �  «        | j                  €J ‚| j                  st        j                  | di «       y y )Nra  )rH   r7  r_  ra  r.  r/  ©rJ   rL   s    €rM   r7  z%StatefulSymbolicContext.__post_init__V  sA   ø€ Ü‰ÑÔà×!Ñ!Ð-Ð-Ð-Ø×7Ò7Ü×Ñ˜tÐ%JÈBÕOð 8rN   )rO   rP   rQ   r  r_  r$   rT   ra  r   rË   r7  rU   rV   s   @rM   rp   rp   <  s?   ø… ñð !€M�6Ó ð cgÐ'¨$¨s°DÐ9]Ñ4^Ð/^Ñ*_Óf÷Pð PrN   rp   c                   ó<   ‡ — e Zd ZU dZdZeeef   ed<   ˆ fd„Z	ˆ xZ
S )rq   a  
    The correct symbolic context for a given inner tensor of a traceable tensor subclass
    may differ from that of the outer symbolic context. This structure allows for this
    flexibility, with inner symbolic contexts mapped via attr -> symbolic context.
    NÚinner_contextsc                 óJ   •— t         ‰| �  «        | j                  €i | _        y y rG   )rH   r7  re  rc  s    €rM   r7  z%SubclassSymbolicContext.__post_init__g  s'   ø€ Ü‰ÑÔØ×ÑÐ&Ø"$ˆDÕð 'rN   )rO   rP   rQ   r  re  r   r�  rn   rT   r7  rU   rV   s   @rM   rq   rq   ^  s(   ø… ñð
 26€N�D˜˜oÐ-Ñ.Ó5÷%ð %rN   rq   c                 ón   — t        | t        t        t        f«      ry| j                  j                  «       S ©NF)rÇ   rË   rå   rØ   rÈ   rX  rm  s    rM   rX  rX  m  s)   € Ü�#œœU¤DÐ)Ô*ØØ�8‰8×ÑÓ!Ð!rN   é   c                 ó˜   — t        | d«      r	 t        j                  | «      S | S # t        $ r t        j                  d| «       | cY S w xY w)NÚexpandz"RecursionError in sympy.expand(%s))ÚhasattrrR   rk  ÚRecursionErrorr}   Úwarning)rv  s    rM   Úsafe_expandro  t  sK   € äˆq�(Ôð	Ü—<‘< “?Ð"ð
 ˆøô	 ò 	Ü�K‰KÐ<¸aÔ@ØŠHð	ús   Ž% ¥!A	ÁA	c                  ó   — t        d«      ‚)Nzshouldn't be hit)r[  rZ   rN   rM   Úerrorrq    s   € Ü
Ð+Ó
,Ð,rN   c                 ó>   — t        t        t        | |«      «      «      S rG   )rË   r¾  Ú"_eval_is_non_overlapping_and_dense)ÚsizesrÂ   s     rM   Ú!eval_is_non_overlapping_and_denseru  „  s   € ÜŒzÔ<¸UÀGÓLÓMÓNÐNrN   c                 óØ   — t        | «      }|dk(  r|d   dk(  xs | d   dk  S t        t        | |«      t        j                  d«      ¬«      }d}|D ]  \  }}|dk(  rŒ||k7  r y||z  }Œ y)Nr½   r   rù   ©ÚkeyFT)r  Úsortedrè   rÔ  Ú
itemgetter)rt  rÂ   rÃ   Úlengths_and_stridesÚexpected_strideÚlengthr  s          rM   rs  rs  ‡  s‘   € Ü
ˆe‹*€Cð
 ˆa‚xØ�q‰z˜Q‰Ò. %¨¡(¨Q¡,Ð.ô !ÜˆE�7Ó¤×!4Ñ!4°QÓ!7ôÐð €OØ-ò "‰ˆ�à�QŠ;Øà�_Ò$Ùà˜6Ñ!‰ð"ð rN   c                 ó2   — t        j                  d| fd«      S )Nr½   rú   )rR   r  r@  s    rM   r
  r
  ¦  s   € Ü�?‰?˜A˜q˜6 9Ó-Ð-rN   Úsymboolc                 ó   — t        | t        «      r| rdS dS t        | j                  j                  «      }| j                  j
                  j                  |t        | «      r(t        | j                  j                  «       «      ¬«      S d ¬«      S )Nr½   r   ©Úhint)
rÇ   rØ   r
  rÈ   rÑ   rð   Úcreate_symintnoderÎ   rË   rÉ   )r  Úint_syms     rM   r€  r€  ª  s„   € Ü�'œ4Ô ÙˆqÐ" Ð"Ü5°g·l±l×6GÑ6GÓH€GØ�<‰<×!Ñ!×3Ñ3°GÔfnÐovÔfwÄ#ÀgÇlÁl×F_ÑF_ÓFaÓBbÐ3ó  Cð  Cð  ~BÐ3ó  Cð  CrN   ÚAbsr  r)  r6  r7  r9  r8  ÚMinÚMaxr)   r*   r(   ÚTrueDivÚPowByNaturalr+   ÚfloorÚceiling)
r-   ÚFloatPowr.   r€  Ú
RoundToIntÚRoundDecimalrQ  Ú
IntTrueDivÚFloatTrueDivrP  c                 ó  ‡‡‡—  t        |«      | «      ŠdŠt        j                  r"dŠt        j                  | «      ˆˆˆfd„«       }nt        j                  | «      ˆˆfd„«       }‰j
                  |_        ‰j                  |_        |S )a¯  
    Wrapper around lru_cache that clears when new info about shapes has been
    updated.

    Use lru_cache if the output is always the same, regardless of the
    constraints we know now (i.e. evaluate_expr)

    Use _lru_cache otherwise.

    Also note that this depends on _update_version_counter being called on the
    shape environment whenever the constraints are updated, otherwise the cache
    will not be cleared.
    r   Nc                 óì   •— ‰€| j                  «       Š‰| j                  k7  r-‰j                  «        | j                  Š| j                  «       Šn‰| j                  «       k(  sJ d«       ‚ ‰| g|¢­i |¤ŽS )Nz9ShapeEnv cache key changed without version being updated!)Ú_get_keyÚ_version_counterr“   )rJ   rK   ÚkwargsÚfn_cacheÚ	prior_keyÚprior_versions      €€€rM   Úwrapperz_lru_cache.<locals>.wrapperã  s}   ø€ ð Ð Ø ŸM™M›O�	à × 5Ñ 5Ò5Ø×$Ñ$Ô&Ø $× 5Ñ 5�Ø ŸM™M›O‘	à  D§M¡M£OÒ3ð PØOóPÐ3ñ ˜DÐ2 4Ò2¨6Ñ2Ð2rN   c                 ór   •— ‰| j                   k7  r‰j                  «        | j                   Š ‰| g|¢­i |¤ŽS rG   )r”  r“   )rJ   rK   r•  r–  r˜  s      €€rM   r™  z_lru_cache.<locals>.wrapperõ  s?   ø€ ð  × 5Ñ 5Ò5Ø×$Ñ$Ô&Ø $× 5Ñ 5�á˜DÐ2 4Ò2¨6Ñ2Ð2rN   )r’   ÚconfigÚvalidate_shape_env_version_keyr†   Úwrapsr“   r…   )r6  rŠ   r™  r–  r—  r˜  s      @@@rM   Ú
_lru_cacherž  Ï  s„   ú€ ð "Œy˜Ó! "Ó%€HØ€Mä×,Ò,Øˆ	ä	�‰˜Ó	õ	3ó 
ñ	3ô" 
�‰˜Ó	ô	3ó 
ð	3ð #×.Ñ.€GÔØ!×,Ñ,€GÔØ€NrN   c                   ód   — e Zd ZU ej                  ed<    ed¬«      Zeed<    ed¬«      Z	eed<   y)ÚRuntimeAssertrÑ   F)r®  ÚmsgÚstackN)
rO   rP   rQ   rR   rS   rT   r   r¡  r�  r¢  rZ   rN   rM   r   r     s*   … à
�*‰*ÓÙ˜%Ô €CˆÓ Ù˜EÔ"€Eˆ3Ô"rN   r   c                   ó   — e Zd Zd„ Zy)ÚSymExprPrinterc                 ó*   — t        t        |«      «      S rG   )r�  rå   ©rJ   rÑ   s     rM   Ú_print_FloatzSymExprPrinter._print_Float  s   € Ü”5˜“;ÓÐrN   N)rO   rP   rQ   r§  rZ   rN   rM   r¤  r¤    s   „ ó rN   r¤  c                   ó<   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zd„ Zdefd„Zˆ xZ	S )ÚShapeGuardPrinterc                 óL   •— t         ‰| �  «        || _        || _        || _        y rG   )rH   rI   Úsymbol_to_sourceÚ
source_refÚvar_to_sources)rJ   r«  r¬  r­  rL   s       €rM   rI   zShapeGuardPrinter.__init__  s'   ø€ ô 	‰ÑÔØ 0ˆÔØ$ˆŒØ,ˆÕrN   c                 ól   — dj                  | j                  |j                  d   t        d   «      «      S )Nznot {}r   r(  )ÚformatÚparenthesizerK   rB   r¦  s     rM   Ú
_print_NotzShapeGuardPrinter._print_Not   s+   € Ø�‰˜t×0Ñ0°·±¸1±¼zÈ%Ñ?PÓQÓRÐRrN   c                 óJ   — | j                  |j                  dt        d   «      S )Nú and r&  ©Ú	stringifyrK   rB   r¦  s     rM   Ú
_print_AndzShapeGuardPrinter._print_And#  s   € Ø�~‰~˜dŸi™i¨´*¸UÑ2CÓDÐDrN   c                 óJ   — | j                  |j                  dt        d   «      S )Nú or r'  r´  r¦  s     rM   Ú	_print_OrzShapeGuardPrinter._print_Or&  s   € Ø�~‰~˜dŸi™i¨´¸DÑ1AÓBÐBrN   r›   c                 ór  ‡ — t        |t        j                  «      sJ t        t	        |«      «      «       ‚ˆ fd„}‰ j
                  j                  |«      s>J |› d‰ j                  |   D �cg c]  }|j                  «       ‘Œ c}› d |«       › d�«       ‚‰ j                  ‰ j
                  |   d   «      S c c}w )Nc                  óÆ   •— t        ‰j                  j                  «       D � ��ci c]$  \  } }| |D �cg c]  }|j                  «       ‘Œ c}“Œ& c}}} «      S c c}w c c}}} w rG   )r®  r«  rí   r„  )ÚsymbolÚsourcesrT  rJ   s      €rM   Úrepr_symbol_to_sourcez>ShapeGuardPrinter._print_Symbol.<locals>.repr_symbol_to_source,  s\   ø€ Üà'+×'<Ñ'<×'BÑ'BÓ'D÷ð á#�F˜Gð ¨7Ö3 a˜Ÿ™�Ò3Ñ3ôó ð ùÚ3ùôs   ¥A²AÁ	AÁAz (could be from z	) not in zu.  If this assert is failing, it could be due to the issue described in https://github.com/pytorch/pytorch/pull/90665r   )
rÇ   rR   r  r�  rÊ   r«  rï   r­  r„  r¬  )rJ   rÑ   r¾  rT  s   `   rM   Ú_print_SymbolzShapeGuardPrinter._print_Symbol)  s·   ø€ Ü˜$¤§¡Ô-Ð>¬s´4¸³:«Ó>Ð-ô	ð ×$Ñ$×(Ñ(¨Ô.ð 	
ØˆfÐ$¸×8KÑ8KÈDÑ8QÖ%R°1 a§f¡f¥hÒ%RÐ$Sð TÙ+Ó-Ð.ð /ZðZó	
Ð.ð
 �‰˜t×4Ñ4°TÑ:¸1Ñ=Ó>Ð>ùò	 &Ss   Á*B4
)
rO   rP   rQ   rI   r±  r¶  r¹  r�  r¿  rU   rV   s   @rM   r©  r©    s&   ø„ ô	-òSòEòCð? S÷ ?rN   r©  c                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )ÚLoggingShapeGuardPrinterc                 ó*   •— t         ‰| �  |d„ |«       y )Nc                 ó"   — | j                  «       S rG   r‡  ©rô   s    rM   râ   z3LoggingShapeGuardPrinter.__init__.<locals>.<lambda><  s   € °1·6±6³8€ rN   )rH   rI   )rJ   r­  rL   s     €rM   rI   z!LoggingShapeGuardPrinter.__init__;  s   ø€ Ü‰Ñ˜Ñ);¸^ÕLrN   )rO   rP   rQ   rI   rU   rV   s   @rM   rÁ  rÁ  :  s   ø„ ÷Mð MrN   rÁ  c                   ó4   ‡ — e Zd ZdZˆ fd„Zdefd„Zd„ Zˆ xZS )ÚDynamicDimConstraintPrinterzý
    Printer for dynamic dim constraints.
    - Instead of symbol s_k it prints its source t.size()[i]
    - Instead of Eq(_, _), Mod(_, _), etc. it prints _ == _, _ % _, etc.

    We use this to suggest code for specifying dynamic dim constraints.
    c                 ó>   •— t         ‰| �  «        || _        || _        y rG   )rH   rI   r«  Úsource_name_to_debug_name)rJ   r«  rÈ  rL   s      €rM   rI   z$DynamicDimConstraintPrinter.__init__G  s   ø€ Ü‰ÑÔØ 0ˆÔØ)BˆÕ&rN   r›   c                 óô   — t        |t        j                  «      sJ t        t	        |«      «      «       ‚| j
                  j                  |«      sJ d|› d�«       ‚| j
                  |   d   j                  «       S )NzUnknown symbol z created by constraints solverr   )rÇ   rR   r  r�  rÊ   r«  rï   r„  r¦  s     rM   r¿  z)DynamicDimConstraintPrinter._print_SymbolL  sr   € Ü˜$¤§¡Ô-Ð>¬s´4¸³:«Ó>Ð-Ø×$Ñ$×(Ñ(¨Ô.ð 	
Ø˜d˜VÐ#AÐBó	
Ð.ð ×$Ñ$ TÑ*¨1Ñ-×2Ñ2Ó4Ð4rN   c           
      ó¶   — | j                  |j                  t        |«      «      › d|j                  › d| j                  |j                  t        |«      «      › �S ©NrW  )r°  r  rA   Úrel_opr	  r¦  s     rM   Ú_print_Relationalz-DynamicDimConstraintPrinter._print_RelationalS  sQ   € Ø×#Ñ# D§H¡H¬j¸Ó.>Ó?Ð@ÀÀ$Ç+Á+ÀÈaÐPT×PaÑPaÐbf×bjÑbjÔlvÐw{Ól|ÓP}ÐO~ÐÐrN   )	rO   rP   rQ   r  rI   r�  r¿  rÍ  rU   rV   s   @rM   rÆ  rÆ  ?  s    ø„ ñôCð
5 Só 5ö@rN   rÆ  c            
       óú   — e Zd ZdZd„ Zd„ Zd„ Zdefd„Zdefd„Z	d„ Z
d	„ Zd
„ Zd„ Zed„ «       Zd„ Zd„ Zd„ Zdeeeeef   f   deeef   ddfd„Z	 	 	 ddej0                  deeeeef   ee   ee   f      fd„Zy)ÚDimConstraintsz’
    Custom solver for a system of constraints on symbolic dimensions.
    Solutions are "static" values or simplified "dynamic" constraints.
    c                 óŠ  — t        t        «      | _        t        «       | _        i | _        || _        t        t        «      | _        t        «       | _        g | _        t        «       | _	        t        «       | _
        t        ||«      | _        g | _        || _        t        t         t"        t$        h| _        | j)                  «        y rG   )r   rc  Ú_univariate_inequalitiesÚ_symbols_with_equalitiesÚ_substitutionsÚ_var_to_valÚ_congruencesÚ_multivariate_inequalitiesÚ_symbolic_equivalencesÚ_static_resultsÚ_dynamic_resultsrÆ  Ú_dcpÚ_inconsistenciesÚ_marked_dynamicr'   r)   r*   r(   Ú_supported_sympy_functionsÚ_enumerate_sympy_functions)rJ   r«  Ú
var_to_valÚmarked_dynamicrÈ  s        rM   rI   zDimConstraints.__init__]  s¿   € ô NYÔY\ÓM]ˆÔ%ô <?»5ˆÔ%ð BDˆÔð ?IˆÔÜ-8¼Ó-=ˆÔô <?»5ˆÔ'ð HJˆÔ#ô
 *-«ˆÔÜ*-«%ˆÔô 0Ð0@ÐB[Ó\ˆŒ	ð ,.ˆÔð  .ˆÔô ÜÜÜð	@
ˆÔ'ð 	×'Ñ'Õ)rN   c                 ó$  ‡ ‡— ˆˆ fd„}ˆˆ fd„}|j                  t        «      r|j                  t        |«      }|j                  t        «      r|j                  t        |«      }|j                  t        «      r|j                  t        |«      }|S )aA  
        Eliminate expressions of the form b // d and b % d while adding congruences of the form b % d == k.
        This leaves rational operators (in particular of the form b / d) that our inequality solver can handle.
        We solve the added congruences separately (using our congruence solver, see below).
        c                  ó  •— | \  }}‰j                  ‰|«      ‰j                  ‰|«      }}|j                  ‰j                  «      |j                  ‰j                  «      z  }||z
  |z  }|dk7  r‰j                  ‰   j	                  |«       |S r�   ©Úrewrite_with_congruencesÚxreplacerÔ  rÕ  Úadd©rK   Úbaser•  Úmod_reducedÚ
congruencerT  rJ   s        €€rM   Úmod_handlerz<DimConstraints.rewrite_with_congruences.<locals>.mod_handlerœ  s’   ø€ ð0 !‰MˆD�'Ø ×9Ñ9¸!¸TÓBÀD×DaÑDaÐbcÐelÓDm�'ˆDØŸ-™-¨×(8Ñ(8Ó9¸G×<LÑ<LÈT×M]ÑM]Ó<^Ñ^ˆKØ Ñ,°Ñ7ˆJØ˜QŠØ×!Ñ! !Ñ$×(Ñ(¨Ô4ØÐrN   c                  ó*  •— | \  }}‰j                  ‰|«      ‰j                  ‰|«      }}|j                  ‰j                  «      |j                  ‰j                  «      z  }||z
  |z  }|dk7  r‰j                  ‰   j	                  |«       ||z
  |z  S r�   rã  rç  s        €€rM   Úfloor_div_handlerzBDimConstraints.rewrite_with_congruences.<locals>.floor_div_handler¼  sž   ø€ ð !‰MˆD�'Ø ×9Ñ9¸!¸TÓBÀD×DaÑDaÐbcÐelÓDm�'ˆDØŸ-™-¨×(8Ñ(8Ó9¸G×<LÑ<LÈT×M]ÑM]Ó<^Ñ^ˆKØ Ñ,°Ñ7ˆJØ˜QŠØ×!Ñ! !Ñ$×(Ñ(¨Ô4ð ˜;Ñ&¨'Ñ1Ð1rN   )rL  r)   Úreplacer*   r(   )rJ   rT  rÑ   rë  rí  s   ``   rM   rä  z'DimConstraints.rewrite_with_congruences–  sk   ù€ õ	õ@	2ð$ �8‰8”CŒ=Ø—<‘<¤ [Ó1ˆDð �8‰8”IÔØ—<‘<¤	¨;Ó7ˆDØ�8‰8”HÔØ—<‘<¤Ð*;Ó<ˆDØˆrN   c                 ó0  — t         j                  j                  j                  }t	        «       }t        |«      D ]:  }t        t        ||«      x}t        j                  «      sŒ*|j                  |«       Œ< |j                  | j                  «      | _        y rG   )r²   rM  rN  rO  rc  ÚdirrÇ   rŠ  rR   ÚFunctionClassræ  Ú
differencerÝ  Ú_unsupported_sympy_functions)rJ   ÚmoduleÚall_functionsr§  Úfuncs        rM   rÞ  z)DimConstraints._enumerate_sympy_functionsØ  sv   € Ü—‘×#Ñ#×-Ñ-ˆÜ›ˆÜ˜“Kò 	(ˆDÜ¤'¨&°$Ó"7Ð7˜$¼×9LÑ9LÕMØ×!Ñ! $Õ'ð	(ð -:×,DÑ,DÀT×EdÑEdÓ,eˆÕ)rN   r›   c                 ó4   —  |j                   | j                  Ž S )z^
        Tracks list of sympy.Functions the export solver doesn't know how to handle.
        )rL  ró  r¦  s     rM   Ú_has_unsupported_sympy_functionz.DimConstraints._has_unsupported_sympy_functionà  s   € ð ˆt�x‰x˜×:Ñ:Ð;Ð;rN   c                 óÄ  — |t         j                  k(  ry|}|j                  | j                  «      }|t         j                  k(  r| j
                  j                  |› d�«       t        |t         j                  «      s| j                  |«      ry|j                  }|s
J d|› �«       ‚t        |«      dkD  r| j                  j                  |«       yt        t        |«      «      }t        | j                   |   «      }| j#                  ||«      }t        | j                   |   «      }|t         j                  k(  r||k(  S |j                  | j                  «      }|t         j                  k(  r!| j
                  j                  |› d|› d�«       t        |t         j$                  «      r| j&                  j                  |«       | j(                  |   j                  |«       y)z’Add an expression to the set of constraints.

        Return whether the expression is a trivial constraint (i.e., an obvious tautology).
        Tz is inconsistent!Fz2Did not expect constraint with no free variables: r½   z, obtained by rewriting z# with congruences, is inconsistent!)rR   Útruerå  rÔ  ÚfalserÛ  rÀ   rÇ   r)  rø  rf   r  rÖ  ræ  rd  ÚiterrÕ  rä  r  rÒ  rÑ  )	rJ   rÑ   Ú	orig_exprÚorig_reducedrf   rT  Úold_n_congruencesÚnew_n_congruencesÚreduceds	            rM   ræ  zDimConstraints.addæ  s°  € ð
 ”5—:‘:ÒØØˆ	Ø ×)Ñ)¨$×*:Ñ*:Ó;ˆð œ5Ÿ;™;Ò&Ø×!Ñ!×(Ñ(¨I¨;Ð6GÐ)HÔIÜ�dœEŸH™HÔ%¨×)MÑ)MÈdÔ)SàØ×(Ñ(ˆÙÐXÐQÐRVÐQWÐXÓXˆ|Üˆ|Ó˜qÒ à×+Ñ+×/Ñ/°Ô5ð( ô# ”T˜,Ó'Ó(ˆAä # D×$5Ñ$5°aÑ$8Ó 9ÐØ×0Ñ0°°DÓ9ˆDÜ # D×$5Ñ$5°aÑ$8Ó 9ÐØ”u—z‘zÒ!Ø(Ð,=Ñ=Ð=Ø—m‘m D×$4Ñ$4Ó5ˆGØœ%Ÿ+™+Ò%Ø×%Ñ%×,Ñ,Ø�fÐ4°Y°Kð @'ð 'ôô ˜$¤§¡Ô)à×-Ñ-×1Ñ1°!Ô4Ø×)Ñ)¨!Ñ,×0Ñ0°Ô6ØrN   c                 ó´   — |j                   r/| j                  j                  |j                  «       › d|› �«       y| j                  j                  ||f«       y)zAdd an equality constraintú == N)rk  rØ  ræ  r„  r×  rÀ   )rJ   r  rÑ   s      rM   Úadd_equalityzDimConstraints.add_equality  sH   € à�>Š>à× Ñ ×$Ñ$¨¯©« °d¸4¸&Ð%AÕBð ×'Ñ'×.Ñ.°¸¨~Õ>rN   c                 ó  ‡— i }| j                   j                  «       D �]j  \  }}g }t        «       }|D ]Ù  }|j                  \  }}t	        j
                  dd¬«      }	t	        j                  |||	z  z
  |g¬«      \  }
}||
k(  rzt        j                  j                  j                  ||	«      \  }}t        |t        j                  «      r3t        |t        j                  «      r||z  }|j                  ||f«       ŒÉ|j                  |«       ŒÛ |rst	        j                  j                  j                   |Ž \  }}||z
  |z  h||<   ||t	        j
                  dd¬«      z  |z   iŠ||   j#                  ˆfd„|D «       «       �Œf|||<   �Œm |S )NÚreduce_congruences_tmpT©Úinteger)ÚsymbolsÚtmpc              3   óN   •K  — | ]  }t        j                  |‰«      s|–— Œ y ­wrG   )rR   Úchecksol)r_  rê  Úsubstitutions     €rM   ra  z5DimConstraints._reduce_congruences.<locals>.<genexpr><  s'   øè ø€ ò .Ø#-Ü Ÿ>™>¨*°lÔCô ñ.ùs   ƒ"%)rÕ  rí   rc  rK   rR   r  Úsolve_linearÚpolysÚ	polytoolsÚdivrÇ   rÔ   rÀ   ræ  ÚntheoryÚmodularÚsolve_congruencerž  )rJ   Úreduced_congruencesrT  ÚcongruencesÚremainder_modulus_pairsÚcongruences_to_checkrê  rè  r•  r
  r¼  ÚsolutionÚmodulusÚ	remainderr  s                 @rM   Ú_reduce_congruencesz"DimConstraints._reduce_congruences  s—  ø€ Ø ÐØ"×/Ñ/×5Ñ5Ó7ó #	>‰NˆAˆ{Ø&(Ð#Ü#&£5Ð Ø)ò 5�
Ø *§¡‘��gô —l‘lÐ#;ÀTÔJ�Ü#(×#5Ñ#5°d¸WÀs¹]Ñ6JÐUVÐTWÔ#XÑ �˜ð ˜’;ä).¯©×)>Ñ)>×)BÑ)BÀ8ÈSÓ)QÑ&�G˜YÜ! '¬5¯=©=Ô9¼jÈÔTY×TaÑTaÔ>bà$-°Ñ$7˜	Ø/×6Ñ6¸	À7Ð7KÔLØ ð %×(Ñ(¨Õ4ð'5ñ. 'Ü%*§]¡]×%:Ñ%:×%KÑ%KÐMdÐ%eÑ"�	˜7Ø+,¨y©=¸GÑ*CÐ)DÐ# AÑ&Ø ! 7¬U¯\©\¸%ÈÔ-NÑ#NÐQZÑ#ZÐ[�Ø# AÑ&×-Ñ-ó .Ø1Eô.ö ð
 *>Ð# AÓ&ðG#	>ðJ #Ð"rN   c                 ó¢   — | j                   rCdj                  | j                   «      }| j                   j                  «        t        d|› �«      ‚y )Nú
z*The following inconsistencies were found:
)rÛ  Újoinr¬  rå  )rJ   r¡  s     rM   Ú_raise_inconsistenciesz%DimConstraints._raise_inconsistenciesE  sI   € Ø× Ò Ø—)‘)˜D×1Ñ1Ó2ˆCØ×!Ñ!×'Ñ'Ô)ÜÐJÈ3È%ÐPÓQÐQð !rN   c                 óà
  ‡ — ‰ j                  «        ‰ j                  �r¤‰ j                  j                  «       }‰ j                  j                  |«      }t        j
                  j                  j                  ||«      }t        |t        j                  «      rt        d„ |j                  D «       |«      }t        |t        j                  «      sJ d|› d|› �«       ‚|j                  \  }}||k(  sJ d|› d|› �«       ‚‰ j                  j                  ‰ j                  j                   |   d   j#                  «       › d|› �«       |‰ j$                  |<   ‰ j&                  }t)        «       ‰ _        |D ]1  }‰ j                  |j+                  |‰ j$                  |   i«      «       Œ3 ‰ j                  «        ‰ j                  r�Œ¤‰ j-                  «       }|j/                  «       D �]S  \  }}	|	D �]G  }
|‰ j$                  vs&t	        j0                  |
|‰ j$                  |   i«      rŒ8‰ j3                  |
«      sŒJ|
j                  \  }}d‰ j                  j4                  ‰ j                  j                   |   d   j#                  «          › �}t	        j6                  |d	¬
«      }ddlm}  ||«      g‰ j                  j                   |<   t=        t	        j                  |||z  «      |«      }‰ j>                  j                  ‰ j                  jA                  t	        j                  ||d   «      «      «       �ŒJ �ŒV ‰ j                  j/                  «       D �]  \  }}	 t        j
                  j                  j                  ||«      }t        |t        jB                  «      r't        tE        ˆ fd„|j                  D «       «      «      }t        |t        j                  «      rF|j                  D ]6  }‰ j>                  j                  ‰ j                  jA                  |«      «       Œ8 n4‰ j>                  j                  ‰ j                  jA                  |«      «       �Œ	 ‰ jN                  }g ‰ _'        |D ]0  \  }}‰ jQ                  ||j+                  ‰ j$                  «      «       Œ2 ‰ jN                  D ]L  \  }}‰ j>                  j                  |j#                  «       › d‰ j                  jA                  |«      › �«       ŒN y# tF        tH        f$ r\}tJ        jM                  d|«       |D ]6  }‰ j>                  j                  ‰ j                  jA                  |«      «       Œ8 Y d}~�Œd}~ww xY w)zPSolve the system of constraint equations to find simplified constraints
        c              3   óV   K  — | ]!  }t        |t        j                  «      sŒ|–— Œ# y ­wrG   )rÇ   rR   r  )r_  rI  s     rM   ra  z'DimConstraints.solve.<locals>.<genexpr>V  s    è ø€ Ò [¨ÄÈCÔQV×QYÑQYÕAZ¤Ñ [ùó   ‚)¢)z$Expected an equality constraint for z, got zExpected a constraint on z instead of on r   r  r¦  Tr  )ÚConstantSourcer½   c              3   óZ   •K  — | ]"  }|j                  ‰j                  «      sŒ|–— Œ$ y ­wrG   )rå  rÔ  )r_  rI  rJ   s     €rM   ra  z'DimConstraints.solve.<locals>.<genexpr>|  s#   øè ø€ Ò(h°ÈÏÉÐVZ×VfÑVfÕIg¬Ñ(hùs   ƒ +¤+z!Failed to reduce inequalities: %sN))r   rÒ  ÚpoprÑ  rR   ÚsolversÚinequalitiesÚreduce_inequalitiesrÇ   r&  rd  rK   r  rØ  ræ  rÚ  r«  r„  rÓ  rÖ  rc  rå  r  rí   r  Ú_is_supported_congruencerÈ  r  Útorch._dynamo.sourcer$  r/   rÙ  Údoprintr'  rü  ÚNotImplementedErrorr[  r}   rn  r×  r  )rJ   rT  Úexprsr  r¼  rU  Úmultivariate_inequalitiesrÑ   r  r  rê  rè  r•  Útmp_namer
  r$  rv  rI  r`  Úsymbolic_equivalencesr  s   `                    rM   ÚsolvezDimConstraints.solveK  s«  ø€ ð 	×#Ñ#Ô%ð ×+Ó+Ø×-Ñ-×1Ñ1Ó3ˆAØ×1Ñ1×5Ñ5°aÓ8ˆEÜ—}‘}×1Ñ1×EÑEÀeÈQÓOˆHÜ˜(¤E§I¡IÔ.ÜÑ [°·±Ô [Ð]eÓf�Ü˜h¬¯©Ô1ÐmÐ5YÐZ[ÐY\Ð\bÐckÐblÐ3mÓmÐ1Ø"Ÿ-™-‰KˆF�CØ˜Q’;ÐVÐ";¸A¸3¸oÈfÈXÐ VÓV�;à× Ñ ×$Ñ$¨¯	©	×(BÑ(BÀ1Ñ(EÀaÑ(H×(MÑ(MÓ(OÐ'PÐPTÐUXÐTYÐ%ZÔ[à%(ˆD×Ñ Ñ"ð )-×(GÑ(GÐ%Ü.1«eˆDÔ+Ø1ò E�Ø—‘˜Ÿ™¨¨4×+>Ñ+>¸qÑ+AÐ'BÓCÕDðEà×'Ñ'Ô)ð' ×+Ô+ð. #×6Ñ6Ó8ÐØ1×7Ñ7Ó9ó 	X‰NˆAˆ{Ø)ó 
X�
à˜D×/Ñ/Ñ/´u·~±~ÀjÐSTÐVZ×ViÑViÐjkÑVlÐRmÕ7nØ×4Ñ4°ZÕ@Ø(2¯©™˜˜gØ%& t§y¡y×'JÑ'JÈ4Ï9É9×KeÑKeÐfgÑKhÐijÑKk×KpÑKpÓKrÑ'sÐ&tÐ#u˜Ü#Ÿl™l¨8¸TÔB˜ÝGÙ;IÈ(Ó;SÐ:T˜Ÿ	™	×2Ñ2°3Ñ7Ü%¤e§h¡h¨t°W¸s±]Ó&CÀQÓG˜Ø×-Ñ-×1Ñ1°$·)±)×2CÑ2CÄEÇHÁHÈQÐPQÐRSÑPTÓDUÓ2VÖWò
Xð	Xð ×5Ñ5×;Ñ;Ó=ó 	G‰HˆAˆuðGÜ Ÿ=™=×5Ñ5×IÑIÈ%ÐQRÓS�ä˜h¬¯©Ô1Ü#¤DÓ(h¸¿¹Ô(hÓ$hÓi�HÜ˜h¬¯	©	Ô2Ø'Ÿ}™}ò J˜Ø×-Ñ-×1Ñ1°$·)±)×2CÑ2CÀCÓ2HÕIñJð ×)Ñ)×-Ñ-¨d¯i©i×.?Ñ.?ÀÓ.IÔJùð	Gð" !%× ;Ñ ;ÐØ&(ˆÔ#Ø1ò 	J‰LˆF�DØ×Ñ˜f d§m¡m°D×4GÑ4GÓ&HÕIð	Jð !×7Ñ7ò 	W‰LˆF�DØ×!Ñ!×%Ñ%¨¯©«¨°t¸D¿I¹I×<MÑ<MÈdÓ<SÐ;TÐ&UÕVñ	Wøô (¬Ð8ò GÜ—‘Ð?ÀÔCØ!ò G�DØ×)Ñ)×-Ñ-¨d¯i©i×.?Ñ.?ÀÓ.EÕFöGûðGús   ÍC?TÔU-ÔAU(Õ(U-c                 óÄ  — |j                   \  }}t        |t        j                  «      r~|j                   \  }}t        |t        j                  «      xr t        |t        j
                  «      xs6 t        |t        j
                  «      xr t        |t        j                  «      }nt        |t        j                  «      }|xr t        |t        j
                  «      }|S rG   )rK   rÇ   rR   r=  r  rÔ   )Úclsrê  rè  r•  r  r	  rE   s          rM   r*  z'DimConstraints._is_supported_congruence‘  sŸ   € à"Ÿ™‰ˆˆgô
 �dœEŸI™IÔ&Ø—y‘y‰HˆC�ä˜C¤§¡Ó.ÒQ´:¸cÄ5Ç=Á=Ó3Qò SÜ˜C¤§¡Ó/ÒQ´J¸sÄEÇLÁLÓ4Qñ ô
 ˜d¤E§L¡LÓ1ˆDØÒ:œ
 7¬E¯M©MÓ:ˆØˆrN   c                 óÒ   ‡ — ˆ fd„}‰ j                   j                  «       D ��ci c]6  \  }}|‰ j                  v r# |‰ j                  j                  |   d   «      |“Œ8 c}}S c c}}w )zPReturns a dictionary of the names of symbols to their specialized value
        c                 ó�   •— | j                  «       }‰j                  j                  r‰j                  j                  |   › d|› �S |S )Nú = )r„  rÚ  rÈ  )r=  r„  rJ   s     €rM   Ú
debug_namez9DimConstraints.forced_specializations.<locals>.debug_name¦  sA   ø€ Ø—8‘8“:ˆDØ�y‰y×2Ò2ØŸ)™)×=Ñ=¸dÑCÐDÀCÈÀvÐNÐNà�rN   r   )rÓ  rí   rÜ  rÚ  r«  )rJ   r8  rT  rU  s   `   rM   Úforced_specializationsz%DimConstraints.forced_specializations£  si   ø€ ô	ð ×-Ñ-×3Ñ3Ó5÷
á��3Ø�D×(Ñ(Ñ(ñ �t—y‘y×1Ñ1°!Ñ4°QÑ7Ó8¸#Ñ=ó
ð 	
ùó 
s   ¤;A#c                 ó^   — t        |t        j                  j                  j                  «      S rG   )rÇ   r²   ÚexportÚdynamic_shapesÚ_DerivedDim©rJ   rÃ   s     rM   Ú_is_derived_dimzDimConstraints._is_derived_dim³  s   € Ü˜#œuŸ|™|×:Ñ:×FÑFÓGÐGrN   c                 óÀ   — t        |t        j                  j                  j                  «      xr/ t        |t        j                  j                  j
                  «       S rG   )rÇ   r²   r;  r<  Ú_Dimr=  r>  s     rM   Ú_is_dimzDimConstraints._is_dim¶  sD   € ä�sœEŸL™L×7Ñ7×<Ñ<Ó=ò MÜ˜s¤E§L¡L×$?Ñ$?×$KÑ$KÓLÐLð	
rN   ÚresultsÚname_to_dimNc           
      óú  ‡ — ddl m} ˆ fd„}i }t        |j                  «       «      D �]I  \  }}d|v sŒt	        |d   t
        j                  «      sŒ*t        t        |d   j                  «      «      }t        |«      |vsŒY||t        |«      <   t
        j                  j                  j                  |d   |«      \  }	}
|j                  dd«      }t        j                   ||
z
  |	z  «      }|j                  dt"        «      }t        j$                  ||
z
  |	z  «      }||dœ|t        |«      <    |t        |«      ||¬«      |t        |«      <   |j'                  dd	«       |j'                  dd	«       �ŒL |j)                  «       D ]¢  }t        |j                  «       «      D ]„  \  }}d|v sŒt	        |d   t
        j                  «      sŒ)t        t        t        |d   j                  «      «      x}«      |k(  sŒY|t        |«         d   }|d   j+                  ||i«      }||d<   Œ† Œ¤ t-        «       }|j                  «       D ]š  \  }}||vrŒ‰ j/                  ||   «      rd|v sd|v r|j1                  |«       Œ9d|v sŒ>t	        |d   t
        j                  «      sŒ\t        t        |d   j                  «      «      }|€J ‚|j1                  t        |«      «       Œœ |j3                  |«      }i }|D �]2  }d
}||v r3||   }d|v sd|v st	        |d   t4        «      r ||||   «      s|||<   d}|sŒ@|j                  «       D ]à  \  }}||vrŒ||   }|j6                  j8                  dk(  sŒ*|j:                  j8                  |k(  sŒDd|v sd|v sŒMt        j<                  |«      }t        t        |j                  «      «      }t?        t        j@                  ||d   «      |«      d   t?        t        j@                  ||d   «      |«      d   dœ} ||||   «      rŒÚ|||<    �Œ2 �Œ5 t        |jC                  «       «      D ]#  }||vrŒ‰ jE                  ||   «      s||v sŒ!||= Œ% |jG                  |«       y	)aƒ
  
        Here we resolve 2 concerns with derived dims suggested fixes: 1) newly introduced roots,
        and 2) root swapping.

        1) Newly introduced roots appear with modulo guards, e.g. Mod(dx, 2) = 0 suggests
        dx is a derived dim equal to 2 * _dx, introducing a new root _dx. Currently the final
        suggested fixes handle this correctly, but we can get intermediate results that look like
        {"dy": {"eq": "dx + 1"}, "dx": {"eq": "2 * _dx + 1, "min": 3, "max": 15}}
        and this routine prettifies this by unifying to a single root, and making each suggestion
        either a derived dim or min/max range, not both.

        2) With suggested fixes for derived dims, roots can be swapped,
        e.g. dx, dx - 1 -> dy + 1, dy. Here we don't want to print out the attached name,
        since this leads to messages like "dx - 1 = Dim("dx - 1", ...)".
        Instead we evaluate the new root value, and remove results for its derivations.

        First we find all the original roots (specified in dynamic_shapes), that are found in the
        values of results (i.e. used for computing suggesting fix values). These original roots
        (suppose `dx`) are either specialized, unchanged, refined, or swapped
        (expressed as a derived dim). If any of the first 3 cases happen, we suggest `dx`'s value
        in results, and remove suggestions for derivations of `dx`, assuming the derived relation
        is valid. If swapped, we find the new root, and use the fix to evaluate `dx`'s new value,
        and then do the same with `dx`'s derivations.

        Assuming the originally specified derived relations are correct is valid, because:
            1) if the relations are plain wrong (e.g. input shape = (6, 4) with spec (dx, dx - 1))
               produce_guards() will catch this and crash before hand.
            2) if the relations are numerically correct but do not match the emitted guard,
               for example:

                    def forward(self, x, y):
                        return x.reshape([-1]) + y  # guard: s0 * 2 = s1
                    inputs = (torch.randn(6, 2), torch.randn(12))
                    dx = Dim("dx", min=2, max=32)
                    dynamic_shapes={"x": (dx, 2), "y": (dx + 6, )}  # this matches values but not op

               then this leads to 2 linear equations, and a) produce_guards() is able to solve for
               the unique solution of dx = 6 and specialize, and b) the export constraint solver will
               raise an issue due to range constraints (a unique solution means not all values in a
               range satisfy a guard) and also force specializations.
        r   )ÚDimc                 ó  •— ‰j                  |«      xrx d| v xs d| v xrl |j                  dk  xr | j                  dd«      dk(  xs |j                  | j                  dd«      k(  xr# |j                  | j                  dt        «      k(  S )Nrá  râ  rù   )rB  rá  rï   râ  r0   )ÚcrÃ   rJ   s     €rM   Ú_check_same_rangezDDimConstraints._process_derived_dim_roots.<locals>._check_same_rangeì  sŠ   ø€ ð —‘˜SÓ!ò 4Ø˜a�ZÒ- 5¨A :ò4ð —W‘W˜q‘[Ò9 Q§U¡U¨5°!£_¸Ñ%9ò 2Ø—w‘w !§%¡%¨¨q£/Ñ1ò	4ð —G‘G˜qŸu™u U¬FÓ3Ñ3ðrN   r  rá  rù   râ  )rá  râ  NTFr=  r½   )$Útorch.export.dynamic_shapesrF  rÁ   rí   rÇ   rR   rS   rd  rü  rf   r�  r  r  r  rï   rF  Úceilr0   rŠ  r&  r¯  Úsubsrc  rB  ræ  rò  rË   rL   rO   r5  r±  r/   r  r;  r?  rž  )rJ   rC  rD  rF  rI  Úintroduced_rootsrò   rH  r5  r  r  Úc_minÚmin_Úc_maxÚmax_Úold_rootr¼  Únew_root_exprÚnew_exprÚmodified_rootsÚmodified_root_valuesÚswapped_rootrÃ   rÑ   rT  r  s   `                         rM   Ú_process_derived_dim_rootsz)DimConstraints._process_derived_dim_roots¼  sH  ø€ õ\ 	4ô
	ð, ,.ÐÜ˜Ÿ™›Ó)ó 	'‰DˆAˆqØ�qŠyœZ¨¨$©´·±Õ<ÜœD  4¡×!5Ñ!5Ó6Ó7�Ü�t“9 KÒ/Ø23Ð$¤S¨£YÑ/ä).¯©×)>Ñ)>×)BÑ)BÀ1ÀTÁ7ÈDÓ)QÑ&�G˜YØŸE™E %¨›O�EÜŸ9™9 e¨iÑ&7¸7Ñ%BÓC�DØŸE™E %¬Ó0�EÜŸ:™: u¨yÑ'8¸GÑ&CÓD�Dà15¸dÑ)C�GœC ›IÑ&Ù-0´°T³ÀÈ$Ô-O�K¤ D£	Ñ*à—E‘E˜% Ô&Ø—E‘E˜% Ö&ð!	'ð( )×/Ñ/Ó1ò 		'ˆHÜ˜WŸ]™]›_Ó-ò '‘��1à˜A’IÜ" 1 T¡7¬E¯J©JÕ7Ü¤d¬4°°$±×0DÑ0DÓ+EÓ&FÐF˜FÓGÈ8ÓSà$+¬C°«MÑ$:¸4Ñ$@�MØ  ™wŸ|™|¨V°]Ð,CÓD�HØ&�A�d’Gñ'ð		'ô  $'£5ˆØ—M‘M“Oò 	.‰DˆAˆqØ˜Ñ#ØØ�|‰|˜K¨™NÔ+°¸!±¸uÈ¹zØ×"Ñ" 1Õ%Ø˜’œz¨!¨D©'´5·:±:Õ>ÜœD  4¡×!5Ñ!5Ó6Ó7�ØÐ'Ð'Ð'Ø×"Ñ"¤3 t£9Õ-ð	.ð (×2Ñ2Ð3CÓDˆð
 ;=ÐØ"ó !	&ˆDØˆLØ�w‰Ø˜D‘M�à˜a‘Z 5¨A¡:Ü! ! D¡'¬3Ô/ñ -¨Q°¸DÑ0AÔBØ56Ð,¨TÑ2Ø#(�Lâð $ŸM™M›Oò &‘D�A�qØ Ñ+Ø Ø% a™.�CØ—}‘}×-Ñ-°Ó>À3Ç8Á8×CTÑCTÐX\ÓC\à  A™:¨°!ªÜ#(§=¡=°Ó#3˜DÜ $¤T¨$×*;Ñ*;Ó%<Ó =˜Aä'0´·±¸$ÀÀ%ÁÓ1IÈ1Ó'MÈaÑ'PÜ'0´·±¸$ÀÀ%ÁÓ1IÈ1Ó'MÈaÑ'Pñ&˜Fñ $5°V¸[ÈÑ=NÕ#OØ=CÐ 4°TÑ :Ú %ò&ð%!	&ôN �g—l‘l“nÓ%ò 	ˆAØ˜Ñ#ØØ×#Ñ# K°¡NÔ3°q¸NÒ7JØ˜A‘Jð		ð 	�‰Ð+Õ,rN   Úoriginal_signaturer<  c                 ó.  ‡ ‡‡— ddl m} ‰ j                  j                  syd ˆ fd„	Št	        t
        «      Š|€i }d„ }ˆfd„} ||«      }‰ j                  j                  ‰ j                  «      D ]º  }	 ‰|	«      }
|
|	k(  rŒt        j                  d|
«      \  }}}|j                  «       }|d	k(  r||k(  rŒF|j                  «       r |||t        |«      «       Œj|j                  «       r || ||«      t        |«      «       Œ”|d	k(  sJ |
«       ‚t        j                  |«      ‰|   d
<   Œ¼ t!        |j#                  «       d„ ¬«      D �ci c]  }|||   “Œ
 }}d}|r¿t%        «       }|D ]k  }||j                  d«      d      }‰ j'                  |«      r&|j)                  |j*                  j,                  «       ŒQ|j)                  |j,                  «       Œm |ddj/                  t!        |«      «      › d�z  }|j1                  «       D ]  \  }	}|d|	› d|› d�z  }Œ ‰ j3                  ‰|«       g }g }t!        ‰j#                  «       ˆfd„¬«      D �ci c]  }|‰|   “Œ
 c}Š‰j1                  «       D ]ö  \  }}d
|v rO|d
   }t5        |t        «      r|j7                  |› d|› �«       Œ6t9        |«      sŒB|j7                  |› d|› �«       ŒY|j;                  dd«      }|dk(  rd}|j;                  dd«      }|� |�|j7                  |› d|› d|› d|› d�«       Œ¦|�|j7                  |› d|› d|› d�«       ŒÃ|�|j7                  |› d|› d|› d�«       Œà|j7                  |› d|› d�«       Œø |s|r|dz  }|dj/                  ||z   «      z  }|S c c}w c c}w )!z/Format a message for constraint violation errosr   )Ú_get_dim_name_mappingr×   c                 ó¬   •— ‰j                   j                  j                  «       D ]+  \  }}|s| j                  ||«      n| j                  ||«      } Œ- | S rG   )rÚ  rÈ  rí   rî  )rT  Úinverserò   ró   rJ   s       €rM   Ú	transformz2DimConstraints.prettify_results.<locals>.transformy  sM   ø€ ØŸ	™	×;Ñ;×AÑAÓCò H‘��1Ù+2�A—I‘I˜a ”O¸¿	¹	À!ÀQ»‘ðHàˆHrN   Nc                 óD   — | dk(  ry| dk(  ry| dk(  ry| dk(  ry| dk(  sJ ‚| S )Nú<=ú>=ú<ú>ú==rZ   )rü   s    rM   Úflipz-DimConstraints.prettify_results.<locals>.flip‚  s;   € Ø�TŠzØØ�TŠzØØ�SŠyØØ�SŠyØØ˜’:Ð�:ØˆIrN   c                 ó    •— |dk(  r	|‰|    d<   y |dk(  r|dz
  ‰|    d<   y |dk(  r	|‰|    d<   y |dk(  r|dz   ‰|    d<   y |dk(  sJ ‚|‰|    d	<   y )
Nr`  râ  rb  r½   ra  rá  rc  rd  r  rZ   )rÑ   rü   ÚdigitrC  s      €rM   Úrelation_with_digitz<DimConstraints.prettify_results.<locals>.relation_with_digitŽ  sy   ø€ Ø�TŠzØ',�˜‘˜eÒ$Ø�s’Ø',¨q¡y�˜‘˜eÒ$Ø�t’Ø',�˜‘˜eÒ$Ø�s’Ø',¨q¡y�˜‘˜eÒ$à˜T’zÐ!�zØ&+�˜‘˜dÒ#rN   z( == | <= | >= | < | > )rd  r  c                 ó*   — | j                  d«      d   S )Nr7  r½   )Úsplitr@  s    rM   râ   z1DimConstraints.prettify_results.<locals>.<lambda>³  s   € ˜aŸg™g e›n¨QÑ/€ rN   rw  r7  z'Specializations unexpectedly required (ú, ú9)! For more information, run with TORCH_LOGS="+dynamic".
z%  - solving the guards generated for z$ resulted in a specialized value of z.
c                 ó   •—  ‰| d¬«      S )NT)r]  rZ   )rH  r^  s    €rM   râ   z1DimConstraints.prettify_results.<locals>.<lambda>Ñ  s   ø€ ™i¨°4Ô8€ rN   rá  rù   râ  z = Dim('z', min=z, max=r—  z', max=z')z
Suggested fixes:
  ú
  ©F)rJ  r[  rÚ  rÈ  r   ÚdictrØ  rf  rÙ  Úrerj  ÚstripÚisdigitrË   rR   r±  ry  r;  rc  r?  ræ  r5  rO   r  rí   rX  rÇ   rÀ   rJ  rï   )rJ   rY  r<  Úconstraint_violation_errorr9  r[  re  rh  rD  rT  r3  Úleftrü   Úrightrò   ÚbufÚdebug_namesrÃ   rU  ÚdimsÚothersrH  ÚotherrO  rQ  rC  r^  s   `                        @@rM   Úprettify_resultszDimConstraints.prettify_resultsl  sÚ  ú€ õ 	FØ�y‰y×2Ò2àõ	ô
 œdÓ#ˆØÐ!ØˆNò
	ô	,ñ ,¨NÓ;ˆà×%Ñ%×+Ñ+¨D×,AÑ,AÓBò 	;ˆAÙ˜!“ˆAØ�AŠvØÜ Ÿh™hÐ'BÀAÓF‰OˆD�"�eØ—‘“ˆBØ�TŠz˜d ešmØØ�}‰}ŒÙ# D¨"¬c°%«jÕ9Ø—‘”Ù# E©4°«8´S¸³YÕ?à˜T’zÐ$ 1Ó$�zÜ&+§m¡m°EÓ&:�˜‘˜dÒ#ð	;ô& Ø&×+Ñ+Ó-Ù/ôö"
àð Ð% aÑ(Ñ(ð"
Ðð "
ð ˆÙ!Ü›%ˆKØ+ò 2�Ø! !§'¡'¨%£.°Ñ"3Ñ4�Ø×'Ñ'¨Ô,Ø—O‘O C§H¡H×$5Ñ$5Õ6à—O‘O C§L¡LÕ1ð2ð Ø9¸$¿)¹)ÄFÈ;ÓDWÓ:XÐ9Yð ZJð JñˆCð 1×6Ñ6Ó8ò o‘��3ØÐ>¸q¸cÐAeÐfiÐejÐjmÐnÑn‘ðoð 	×'Ñ'¨°Ô=àˆØˆô $*Ø—‘“Û8ô$ö
ØˆAˆw�q‰z‰Mò
ˆð —M‘M“Oò 	5‰DˆAˆqØ�q‰yØ˜$™�Ü˜e¤SÔ)Ø—M‘M Q C s¨5¨'Ð"2Õ3Ü.¨uÕ5Ø—M‘M Q C s¨5¨'Ð"2Õ3à—u‘u˜U DÓ)�Ø˜1’9Ø�DØ—u‘u˜U DÓ)�ØÐ#¨Ð(8Ø—K‘K 1 # X¨a¨S°¸°v¸VÀDÀ6ÈÐ KÕLØÐ%Ø—K‘K 1 # X¨a¨S°¸°v¸QÐ ?Õ@ØÐ%Ø—K‘K 1 # X¨a¨S°¸°v¸QÐ ?Õ@à—K‘K 1 # X¨a¨S°Ð 3Õ4ð'	5ñ0 ‘6ØÐ+Ñ+ˆCØ�6—;‘;˜t f™}Ó-Ñ-ˆCàˆ
ùòC"
ùò>
s   Å
NÉN)NNN)rO   rP   rQ   r  rI   rä  rÞ  rØ   rø  ræ  r  r  r   r2  Úclassmethodr*  r9  r?  rB  r   r�  r   rX  r°   Ú	Signaturer   r   r   r   r|  rZ   rN   rM   rÏ  rÏ  W  sþ   „ ñò
7*òr@òDfð<°tó <ð+˜4ó +òZ?ò'#òRRòDWðL ñó ðò"
ò Hò
ðn-à�c˜4  S ™>Ð)Ñ*ðn-ð ˜#˜s˜(‘^ðn-ð 
ó	n-ðf RVØ#'Ø#ñDà#×-Ñ-ðDð !  t¨C°¨H¡~°u¸S±zÀ4ÈÁ9Ð'LÑ!MÑNôDrN   rÏ  c                   óX   — e Zd ZU dZeed<   eed<   eed<   eed<   eed<   eed<   eed<   y	)
ÚShapeEnvSettingszŒ
    Encapsulates all shape env settings that could potentially affect
    FakeTensor dispatch. Used when creating dispatch cache keys.
    Úallow_scalar_outputsÚallow_dynamic_output_shape_opsÚassume_static_by_defaultÚspecialize_zero_oneÚ
duck_shapeÚ+prefer_deferred_runtime_asserts_over_guardsÚ'allow_complex_guards_as_runtime_assertsN)rO   rP   rQ   r  rØ   rT   rZ   rN   rM   r€  r€  ö  s3   … ñð
 ÓØ$(Ó(Ø"Ó"ØÓØÓØ15Ó5Ø-1Ô1rN   r€  c                   óì  — e Zd Zdddœdee   deee      ddfd„Zddddddddd	œd
ee   fd„Ze	d„ «       Z
e	d„ «       Ze	d„ «       Ze	d„ «       Ze	d„ «       Ze	d„ «       Ze	d„ «       Zd«d„Zdeee      fd„Zdefd„Zed„ «       Z e«       dej2                  dej4                  fd„«       Z e«       dej2                  deddfd„«       Z e«       dej2                  dej2                  fd„«       Z e«       d¬dej2                  dee   d ee   fd!„«       Z e«       dej4                  ded efd"„«       Z e«       d#„ «       Z d$„ Z! e«       d%„ «       Z" e«       d&„ «       Z#ed'„ «       Z$ e«       d(„ «       Z% e«       d)„ «       Z&d*e'deej2                     fd+„Z(d,ej2                  d-e)ddfd.„Z*d­d/„Z+d­d0„Z,d­d1„Z- e«       d2e.d3e/de/ee0jb                  jd                     ef   fd4„«       Z3d,ej2                  d-e)dee0jb                  jd                     fd5„Z4d6ee0jb                  jd                     ddfd7„Z5d6e0jb                  jd                  ddfd8„Z6d9„ Z7 e«       d:„ «       Z8 e«       d;„ «       Z9ed<„ «       Z:d=„ Z;d>„ Z<d?e=e   d*e'd@e>deej4                     fdA„Z?dBe/e   d*e'd@e>deej4                     fdC„Z@ddDœdEe0j‚                  d*e'd@ee>   fdF„ZBdefdG„ZC e«       ddDœd?e=e   dHe=e   dIedJe=e   d*e'd@ee>   fdK„«       ZD e«       ddLœdMdNdOee   d*ee'   fdP„«       ZE e«       ddLœdMdNdOee   d*ee'   fdQ„«       ZF e«       dR„ «       ZGd®dS„ZHdTeIdUeJfdV„ZK e«       dW„ «       ZL e«       dX„ «       ZMd,ej2                  defdY„ZN e«       dZ„ «       ZO e«       ePj¢                  dfd[eReeSeTeUf   d*e'd\ePd]eVddNf
d^„«       ZW e«       ePj¢                  ddddfd[ed*e'd\ePd]eVd_ee   d`eddNfda„«       ZXdbej2                  d[efdc„ZYdd„ ZZde„ Z[df„ fddddddgœdhee\   diee]e>      djee^   deeI   fdk„Z_dddlœdheee\      fdm„Z`dn„ Zado„ Zbddpœdq„Zcdr„ Zdds„ Zedt„ Zfd¯du„Zgd¯dbej4                  dvedeJfdw„Zheid°dxee/dy      dzede/dN   fd{„«       Zj ekd«      d|dNde/e/d}      fd~„«       ZleiddddddœdbdNd€edzedved�ee/ej4                        d‚ee/e/ej2                  eJf         ddƒfd„„«       Zmeid±d…„«       Zneid†„ «       Zoeid±d‡„«       Zp ekdˆ«      dd‰œd²dŠ„«       Zq ekdˆ«      d²d‹„«       ZrddŒœd�ee   fdŽ„Zsd�„ Ztddyd�dNd‘eIddfd’„Zud²d“„Zvei e«       d³d”„«       «       Zw ekdˆ«      d´d•„«       ZxdeJfd–„ZydeJfd—„Zzeid˜„ «       Z{d™„ Z|d¯dšefd›„Z}dTeIdœefd�„Z~ ekdˆ«       ed¬ž«      	 	 dµddŸœd dNdvedœefd¡„«       «       Z	 	 dµddŸœd dNdvedœefd¢„Z€d£„ Z� ed¬ž«      d¶d·d¤„«       Z‚dbej4                  ddfd¥„Zƒ ekd¬¦«       e«       d§ej2                  d¨ed©efdª„«       «       Z„y)¸r^   N)Úshould_record_eventsÚtracked_fakesr‰  rŠ  r›   c                óv  —  | j                   di |¤Ž d|d<   ddlm}  |«       | _        |�|n| j                  xr t        j
                   | _        | j                  xr t        j                  | _        | j                   | _	        || _
        | j                  rt        t        |¬«      gng | _        i | _        y )NFr‰  r   ©Útranslation_validation_enabled)r•  rZ   )Ú_initÚtorch.fx.experimental.validatorr�  Ú_translation_validation_enabledr›  Ú translation_validation_no_bisectr‰  Úcheck_shape_env_recorded_eventsÚcheck_recorded_eventsÚis_recordingrŠ  r   r^   ÚeventsÚfake_tensor_cache)rJ   r‰  rŠ  r•  r�  s        rM   rI   zShapeEnv.__init__	  sË   € ð 	ˆ�
‰
Ñ�VÒð */ˆÐ%Ñ&åRÙ/MÓ/OˆÔ,ð $Ð/ñ !ð ×4Ñ4ò @Ü×?Ñ?Ð?ð 	Ô!ð ×%Ñ%ÒP¬&×*PÑ*Pð 	Ô"ð
 !%× 9Ñ 9Ð9ˆÔà*ˆÔð 9=×8QÒ8QŒ]œ8¨FÔ3Ñ4ÐWYð 	Œð []ð 	ÕrN   TF)r�  r‚  rƒ  r„  r…  Ú	co_fieldsr†  r‡  r…  c          	      ó€  — |€t         j                  }t        |||||||¬«      | _        g | _        i | _        i | _        i | _        i | _        i | _	        i | _
        i | _        i | _        t        «       | _        t        «       | _        i | _        |r0t#        j$                  d«      t#        j$                  d«      dœ| _        t'        j(                  «       | _        t'        j(                  «       | _        i | _        d| _        t2        | _        | j2                  j5                  d«       d| _        d| _        d | _        t=        j>                  «       | _         t=        j>                  «       | _!        |r|ni | _"        g | _#        | jI                  «       | _%        d| _&        i | _'        i | _(        i | _)        ddl*m+}	  |	«       | _,        | jX                  rqddl*m-}
  |
«       | _.        t^        j`                  jc                  «       | _2        | jd                  jg                  | jd                  ji                  d «      «       i | _5        y y )	N)r�  r‚  rƒ  r„  r…  r†  r‡  r   r½   ©r   r½   Ú
create_envFrŒ  )ÚTranslationValidator)6r›  Úuse_duck_shaper€  ÚsettingsÚguardsrß  Úunbacked_var_to_valr  rÈ  r­  Úvar_to_stackÚreplacementsrî   rc  Ú	divisibleÚ	size_likeÚ
val_to_varrR   rÔ   Ú	itertoolsÚcountÚunbacked_symfloat_counterÚunbacked_symint_counterÚdeferred_runtime_assertsÚnum_deferred_runtime_assertsr}   r~   ry  Úruntime_asserts_frozenÚdim_constraintsÚcollectionsÚCounterÚcounterÚsymbol_guard_counterr—  r«  r“  Ú_prev_cache_keyr”  Úfx_node_cacheÚsource_to_symbolÚunbacked_alloc_orderr�  r�  r�  r›  Ú	validatorr²   r¤   ÚGraphru  Úinserting_beforeÚoutputÚname_to_node)rJ   r�  r‚  rƒ  r„  r…  r—  r†  r‡  r�  r›  s              rM   rŽ  zShapeEnv._initJ	  s  € ðP ÐÜ×.Ñ.ˆJä(à!5Ø+Ià%=Ø 3Ø!Ø8cØ4[ô

ˆŒð )+ˆŒð >@ˆŒð GIˆÔ ð
 >@ˆÔØ9;ˆÔ&Ø@BˆÔØCEˆÔð =?ˆÔØDFˆÔä*-«%ˆŒô -0«EˆŒð 24ˆŒÙÜ"'§-¡-°Ó"2´u·}±}ÀQÓ7GÑHˆDŒOÜ)2¯©Ó):ˆÔ&Ü'0§¡Ó'8ˆÔ$ð: RTˆÔ%ð -.ˆÔ)ÜˆŒØ�‰�‰�|Ô$ØˆŒØ&+ˆÔ#Ø9=ˆÔÜ"×*Ñ*Ó,ˆŒô %0×$7Ñ$7Ó$9ˆÔ!ñ '0™°RˆŒð( CEˆÔ+ð  $Ÿ}™}›ˆÔØ !ˆÔð UWˆÔØ9;ˆÔð6 >@ˆÔ!åRÙ/MÓ/OˆÔ,à×/Ò/ÝLá1Ó3ˆDŒNÜŸ™Ÿ™Ó)ˆDŒJð �J‰J×'Ñ'¨¯
©
×(9Ñ(9¸$Ó(?Ô@ð ;=ˆDÕð# 0rN   c                 ó.   — | j                   j                  S rG   )r�  r�  r|  s    rM   r�  zShapeEnv.allow_scalar_outputs 
  s   € à�}‰}×1Ñ1Ð1rN   c                 ó.   — | j                   j                  S rG   )r�  r‚  r|  s    rM   r‚  z'ShapeEnv.allow_dynamic_output_shape_ops$
  s   € à�}‰}×;Ñ;Ð;rN   c                 ó.   — | j                   j                  S rG   )r�  rƒ  r|  s    rM   rƒ  z!ShapeEnv.assume_static_by_default(
  s   € à�}‰}×5Ñ5Ð5rN   c                 ó.   — | j                   j                  S rG   )r�  r„  r|  s    rM   r„  zShapeEnv.specialize_zero_one,
  s   € à�}‰}×0Ñ0Ð0rN   c                 ó.   — | j                   j                  S rG   )r�  r…  r|  s    rM   r…  zShapeEnv.duck_shape0
  s   € à�}‰}×'Ñ'Ð'rN   c                 ó.   — | j                   j                  S rG   )r�  r†  r|  s    rM   r†  z4ShapeEnv.prefer_deferred_runtime_asserts_over_guards4
  s   € à�}‰}×HÑHÐHrN   c                 ó.   — | j                   j                  S rG   )r�  r‡  r|  s    rM   r‡  z0ShapeEnv.allow_complex_guards_as_runtime_asserts8
  s   € à�}‰}×DÑDÐDrN   c                 óP   — d}dt         dt        dt        fd„}t        | |||«       y)z1Compare another ShapeEnv for equivalence
        )r¯  r}   r   r²  ru  rµ  r“  r‰  r”  rŠ  r•  rÈ  r±  r”  r¬  rx  Úvaluer›   c           
      óh  — | dv rddl m } t         ||«      «      S | dk(  r|D �cg c]  }|j                  ‘Œ c}S | dk(  r>|j                  «       D ���ci c]   \  }}||D �cg c]  }|j                  ‘Œ c}“Œ" c}}}S | dk(  rt	        |j                  «       «      S | dv ry |S c c}w c c}w c c}}}w )N)r§  r¨  r   )Úcopyrž  r©  r¹  )r°  r«  r–  )rÄ  rd  rÑ   rí   rc  r;  )rx  rÂ  rÄ  ÚgrT  ÚrasÚras          rM   Ú	map_valuez'ShapeEnv.check_equal.<locals>.map_value]
  s­   € ØÐNÑNÝ%ô
 ™D ›KÓ(Ð(Ø˜’à(-Ö. 1˜Ÿ›Ò.Ð.ØÐ2Ò2àAFÇÁÃ×OÐO±v°q¸#˜¨cÖ2¨˜BŸG›GÒ2Ñ2ÔOÐOØ˜Ò&ä˜5Ÿ:™:›<Ó(Ð(ØÐgÑgàØˆLùò /ùò 3ùÔOs   ¥B#ÁB-Á!B(Á4B-Â(B-N)r�  r   r   )rJ   r{  Únon_state_variable_namesrÈ  s       rM   Úcheck_equalzShapeEnv.check_equal<
  s5   € ð$
Ð ð2	œ3ð 	¤sð 	¬só 	ô, 	$ D¨%Ð1IÈ9ÕUrN   c                 ó„   ‡— | j                   €y ddlmŠ d‰fˆfd„}| j                   D �cg c]
  } ||«      ‘Œ c}S c c}w )Nr   )ÚTrackedFakeÚfakec                 óþ   •— t        | j                  t        j                  t        j                  f«      r| j                  nt        j                  | j                  «      } ‰|| j                  | j                  «      S rG   )	rÇ   rÍ  r²   r"   r!   r   Ú	from_faker  rG  )rÍ  Ú
inner_fakerÌ  s     €rM   Úmaybe_transform_fakez>ShapeEnv._snapshot_tracked_fakes.<locals>.maybe_transform_fake{
  sY   ø€ ä˜dŸi™i¬%¯,©,¼¿¹Ð)GÔHð Ÿšä#×-Ñ-¨d¯i©iÓ8ð ñ ˜z¨4¯;©;¸×8MÑ8MÓNÐNrN   )rŠ  Útorch._dynamo.variables.builderrÌ  )rJ   rÑ  rÍ  rÌ  s      @rM   Ú_snapshot_tracked_fakesz ShapeEnv._snapshot_tracked_fakesu
  sE   ø€ Ø×ÑÐ%Øå?ð	O {õ 	Oð 8<×7IÑ7IÖJ¨tÑ$ TÕ*ÒJÐJùÒJs   «=c                 ó2   — t        | j                  «      dz
  S rD  )r  r•  r|  s    rM   Ú_last_event_indexzShapeEnv._last_event_index‡
  s   € Ü�4—;‘;Ó !Ñ#Ð#rN   c              #   óJ   K  — d| _         	 d –— d| _         y # d| _         w xY w­w©NTF)r”  r|  s    rM   Ú
_recordingzShapeEnv._recordingŠ
  s&   è ø€ à ˆÔð	&Ûà %ˆDÕø ˆDÕüs   ‚#‹ �#—	  #Úorig_srº  c                 ó*   — | j                  ||d«       y )NÚeliminate_unbacked)Ú_set_replacement)rJ   rÙ  rº  s      rM   r°  zShapeEnv._eliminate_unbacked’
  s   € à×Ñ˜f eÐ-AÕBrN   rò   ró   c                 óH   — t        j                  |«      | j                  |<   y)zˆUsed only when propagate_real_tensors; registers a value for an
        unbacked symbol, which can be used last resort to resolve hints.N)rR   r±  rŸ  )rJ   rò   ró   s      rM   r£  z ShapeEnv.set_unbacked_var_to_val–
  s   € ô ',§m¡m°AÓ&6ˆ× Ñ  Ò#rN   c                 ó¤  — t        |t        j                  «      sJ |«       ‚t        |t        j                  «      sJ |«       ‚t        |«      sJ |«       ‚t        |«      sJ |«       ‚| j                  j                  |«      }t        |«      rJ |› d|› �«       ‚| j                  ||d«       || j                  |<   |�| j                  ||d«       y y )Nz -> Úrename_unbacked_toÚrename_unbacked_to_dest)rÇ   rR   r  rq  r¡  rï   rÜ  rî   )rJ   rÙ  rº  Údests       rM   r  zShapeEnv._rename_unbacked_to�
  sÏ   € ä˜&¤%§,¡,Ô/Ð7°Ó7Ð/Ü˜%¤§¡Ô.Ð5°Ó5Ð.Ü$ UÔ+Ð2¨UÓ2Ð+Ü$ VÔ,Ð4¨fÓ4Ð,Ø× Ñ ×$Ñ$ VÓ,ˆÜ(¨Ô.ÐE°6°(¸$¸t¸fÐ0EÓEÐ.Ø×Ñ˜f eÐ-AÔBØ*/ˆ×Ñ Ñ'ØÐØ×!Ñ! %¨Ð/HÕIð rN   rÄ   rá  râ  c                 óš   — |€d}|€t         }||k  rt        d«      ‚| j                  |||¬«       | j                  j	                  |«       y )Nr   rè  ©rØ  rÙ  )r0   rå  rÛ  r£  ræ  ©rJ   rÄ   rá  râ  s       rM   rß  z"ShapeEnv._constrain_range_for_sizeª
  sa   € àˆ;ØˆCØˆ;ÜˆCà�Š9Üð3óð ð
 	×#Ñ#ØØØð 	$ô 	
ð
 	�‰×Ñ˜1ÕrN   c           	      ó   — t        |t        j                  «      r5|t        |«      cxk  r|k  s n t	        dt        |«      › d|› d|› d�«      ‚y t        |t        j
                  «      r| j                  |||¬«       y y )Nré  rê  rë  rì  rã  )rÇ   rR   rÔ   rË   r4   r  rÛ  rä  s       rM   rí  zShapeEnv._constrain_range¾
  s|   € ä�aœŸ™Ô'Øœ3˜q›6Ô( SÔ(Ü%¨´s¸1³v°h¸lÈ3È%ÈqÐQTÐPUÐUVÐ&WÓXÐXØô �aœŸ™Ô&Ø×'Ñ'ØØ Ø ð (õ ð 'rN   c                 óâ  — t        |t        «      sžt        |t        «      s||k(  sˆJ ‚t        |j                  j                  t        j
                  «      sJ d«       ‚|j                  j                  | u sJ ‚t	        j                  |«      | j                  |j                  j                  <   yyt        |j                  j                  t        j
                  «      sJ d«       ‚|j                  j                  | u sJ ‚t        |t        «      s7t	        j                  |«      | j                  |j                  j                  <   y|j                  j                  |j                  j                  u sJ ‚t        |j                  j                  t        j
                  «      sJ d«       ‚| j                  |j                  j                  «      }|| j                  |j                  j                  <   y)z±
        Given two SymInts, constrain them so that they must be equal.  NB:
        this will not work with SymInts that represent nontrivial expressions
        (yet!)
        rä  N)
rÇ   r"   rÈ   rÑ   rR   r  rð   rÔ   r¡  r1  )rJ   rÄ   r~  Únew_vars       rM   rð  zShapeEnv._constrain_unifyÐ
  s\  € ô ˜!œVÔ$Ü˜a¤Ô(Ø˜A’v��vä! !§&¡&§+¡+¬u¯|©|Ô<Ð\Ð>\Ó\Ð<Ø—v‘v×'Ñ'¨4Ñ/Ð/Ð/Ü16·±¸qÓ1A�×!Ñ! !§&¡&§+¡+Ò.ð	 ô ˜aŸf™fŸk™k¬5¯<©<Ô8ÐXÐ:XÓXÐ8Ø—6‘6×#Ñ# tÑ+Ð+Ð+Ü˜a¤Ô(Ü16·±¸qÓ1A�×!Ñ! !§&¡&§+¡+Ò.à—v‘v×'Ñ'¨1¯6©6×+;Ñ+;Ñ;Ð;Ð;Ü! !§&¡&§+¡+¬u¯|©|Ô<Ð\Ð>\Ó\Ð<ØŸ*™* Q§V¡V§[¡[Ó1�Ø18�×!Ñ! !§&¡&§+¡+Ò.rN   c                 ó$   — t        t        dd«      S )NÚignore_fresh_unbacked_symbolsF©rŠ  ÚTLSr|  s    rM   Ú"_ignore_fresh_unbacked_symbols_tlsz+ShapeEnv._ignore_fresh_unbacked_symbols_tlsò
  s   € Ü”sÐ;¸UÓCÐCrN   c                 ó   — dt         _        y rÍ   ©rë  ré  r|  s    rM   Ú$_ignore_fresh_unbacked_symbols_enterz-ShapeEnv._ignore_fresh_unbacked_symbols_enterõ
  s
   € à,0ŒÕ)rN   c                 ó   — dt         _        y rh  rî  r|  s    rM   Ú#_ignore_fresh_unbacked_symbols_exitz,ShapeEnv._ignore_fresh_unbacked_symbols_exitù
  s
   € à,1ŒÕ)rN   c              #   ó€   K  — | j                  «        	 d–— | j                  «        y# | j                  «        w xY w­w)za
        Indicates that the newly allocated unbacked SymInts are being
        discarded
        N)rï  rñ  r|  s    rM   ré  z&ShapeEnv.ignore_fresh_unbacked_symbolsý
  s4   è ø€ ð 	×1Ñ1Ô3ð	7Ûà×4Ñ4Õ6øˆD×4Ñ4Õ6üó   ‚>”) ˜>©;»>c                 ó   — d| _         y)zÈFreeze this ShapeEnv to stop accumulating guards

        A frozen ShapeEnv will ignore any further guards generated on it and
        only emit a warning which may lead to accuracy problems.
        TNrx  r|  s    rM   ÚfreezezShapeEnv.freeze	  s   € ð ˆ�rN   c                 ó   — d| _         y)a_  Freeze this ShapeEnv to stop adding deferred runtime asserts.

        We will error if you try to install a new runtime assert when it is
        frozen.  This would indicate a lowering violation, or perhaps something
        we know statically is already True but we are checking it again in a way
        that is not clearly dischargeable.
        TN)r«  r|  s    rM   Úfreeze_runtime_assertszShapeEnv.freeze_runtime_asserts  s   € ð '+ˆÕ#rN   r  c                 ó¾   — | j                   sy |j                  «       }|| j                  vr$t        j                  |d¬«      | j                  |<   | j                  |   S )NTr  )r�  r„  r³  rR   r  )rJ   r  Úsrcnames      rM   Ú_create_symbol_for_sourcez"ShapeEnv._create_symbol_for_source  sS   € Ø×3Ò3ØØ—+‘+“-ˆØ˜×.Ñ.Ñ.Ü-2¯\©\¸'È4Ô-PˆD×!Ñ! 'Ñ*Ø×$Ñ$ WÑ-Ð-rN   r¼  rÊ   c                 óV   — | j                   r| j                  j                  ||«       y y rG   )r�  rµ  Úadd_var)rJ   r¼  rÊ   s      rM   Ú
_add_z3varzShapeEnv._add_z3var&  s$   € Ø×/Ò/Ø�N‰N×"Ñ" 6¨4Õ0ð 0rN   c                 óT   — | j                   r| j                  j                  |«       y y rG   )r�  rµ  Úadd_target_exprr¦  s     rM   Ú_add_target_exprzShapeEnv._add_target_expr*  s"   € Ø×/Ò/Ø�N‰N×*Ñ*¨4Õ0ð 0rN   c                 óT   — | j                   r| j                  j                  |«       y y rG   )r�  rµ  Úadd_assertionr¦  s     rM   Ú_add_assertionzShapeEnv._add_assertion.  s"   € Ø×/Ò/Ø�N‰N×(Ñ(¨Õ.ð 0rN   c                 óR   — | j                   r| j                  j                  «        y y rG   )r�  rµ  Úvalidater|  s    rM   Ú_check_translation_validatez$ShapeEnv._check_translation_validate2  s    € Ø×/Ò/Ø�N‰N×#Ñ#Õ%ð 0rN   rü   rK   c                 ó°  — ||f}d}| j                   r§|| j                  vr™t        d„ |D «       «      rt        d„ |D «       «      sJ ‚d |fS d}t        d„ |D «       «      sJ d|j                  › d|› �«       ‚| j
                  j                  ||«      x}| j                  |<   || j                  |j                  <   | j                  j                  |d «      |fS )NFc              3   ó$   K  — | ]  }|d u –— Œ
 y ­wrG   rZ   rÈ  s     rM   ra  z4ShapeEnv._create_fx_call_function.<locals>.<genexpr>D  s   è ø€ Ò+ �1˜”9Ñ+ùó   ‚c              3   óf   K  — | ])  }t        |t        j                  j                  «       –— Œ+ y ­wrG   )rÇ   r²   r¤   ÚNoderÈ  s     rM   ra  z4ShapeEnv._create_fx_call_function.<locals>.<genexpr>G  s"   è ø€ ÒJÀœz¨!¬U¯X©X¯]©]Ó;Ô;ÑJùs   ‚/1Tc              3   ó$   K  — | ]  }|d u–— Œ
 y ­wrG   rZ   rÈ  s     rM   ra  z4ShapeEnv._create_fx_call_function.<locals>.<genexpr>N  s   è ø€ Ò3¨�q ”}Ñ3ùr	  zmissing arg in FX graph (z): )
r�  r²  rË  rl  rO   ru  r  r¹  r„  rï   )rJ   rü   rK   Únode_keyÚfreshrÈ   s         rM   Ú_create_fx_call_functionz!ShapeEnv._create_fx_call_function6  sé   € ð ˜�:ˆàˆà×/Ò/°HÀD×DVÑDVÑ4Vô Ñ+ dÔ+Ô+ô ÑJÀTÔJÔJÐJÐJØ˜U�{Ð"àˆEô Ñ3¨dÔ3Ô3ÐgÐ7PÐQS×Q\ÑQ\ÐP]Ð]`ÐaeÐ`fÐ5gÓgÐ3Ø26·*±*×2JÑ2JÈ2ÈtÓ2TÐTˆD�4×%Ñ% hÑ/Ø+/ˆD×Ñ˜dŸi™iÑ(à×!Ñ!×%Ñ% h°Ó5°uÐ<Ð<rN   c           	      ó¼  — | j                   sy | j                  j                  |ff}|| j                  vrš| j	                  ||«       t        j                  ddt        j                  dd|j                  «      «      }| j                  j                  |«      x}| j                  |<   || j                  |j                  <   ||j                  d<   | j                  |   S )Nz[^a-zA-Z0-9]r¦  z[()]r×   r¼  )
r�  ru  r÷   r²  rý  rq  r¨  r„  r¹  rý   )rJ   r¼  rÊ   r  Úmangled_namerÈ   s         rM   Ú _create_fx_placeholder_and_z3varz)ShapeEnv._create_fx_placeholder_and_z3varT  sÀ   € ð
 ×3Ò3Øà—J‘J×*Ñ*¨V¨IÐ6ˆð
 ˜4×-Ñ-Ñ-à�O‰O˜F DÔ)äŸ6™6 /°3¼¿¹¸wÈÈFÏKÉKÓ8XÓYˆLØ26·*±*×2HÑ2HÈÓ2VÐVˆD�4×%Ñ% hÑ/Ø+/ˆD×Ñ˜dŸi™iÑ(ð #)ˆD�I‰I�hÑà×!Ñ! (Ñ+Ð+rN   rÈ   c                 ó¤   — | j                   rD|�A| j                  j                  |j                  «       | j                  j                  |«       y y y rG   )r�  r¹  r&  r„  ru  Ú
erase_node)rJ   rÈ   s     rM   Ú_remove_fx_nodezShapeEnv._remove_fx_noden  sC   € Ø×/Ò/°DÐ4DØ×Ñ×!Ñ! $§)¡)Ô,Ø�J‰J×!Ñ! $Õ'ð 5EÐ/rN   c                 óœ   — ddl m} | j                  r:| j                  «       |j                  t
        <    |«       |j                  t        <   y y )Nr   )Úget_current_node)Útorch._dynamo.utilsr  r‰  rÕ  rý   rj   rk   )rJ   rÈ   r  s      rM   Ú_add_fx_node_metadatazShapeEnv._add_fx_node_metadatas  s=   € Ý8à×$Ò$Ø,0×,BÑ,BÓ,DˆD�I‰IÔ(Ñ)Ù*:Ó*<ˆD�I‰IÔ&Ò'ð %rN   c                 ó$   — t        t        dd«      S )NÚsuppress_guardsFrê  r|  s    rM   Ú_suppress_guards_tlszShapeEnv._suppress_guards_tlsz  s   € Ü”sÐ-¨uÓ5Ð5rN   c                 ó   — dt         _        y rÍ   ©rë  r  r|  s    rM   Ú_suppress_guards_enterzShapeEnv._suppress_guards_enter}  s
   € à"ŒÕrN   c                 ó   — dt         _        y rh  r  r|  s    rM   Ú_suppress_guards_exitzShapeEnv._suppress_guards_exit�  s
   € à#ŒÕrN   c              #   ó€   K  — | j                  «        	 d–— | j                  «        y# | j                  «        w xY w­w)z5Context manager to ignore all guards generated insideN)r  r!  r|  s    rM   r  zShapeEnv.suppress_guards…  s4   è ø€ ð 	×#Ñ#Ô%ð	)Ûà×&Ñ&Õ(øˆD×&Ñ&Õ(üró  c                 ó”   — t        | j                  «      t        | j                  «      | j                  t        | j                  «      fS )z—
        Defines the current "state" of the guards we've accumulated in this ShapeEnv.
        Determines when we need to invalidate our cache
        )r  r¡  r¢  rª  rŸ  r|  s    rM   r“  zShapeEnv._get_keyŽ  s:   € ô
 �D×%Ñ%Ó&¬¨D¯N©NÓ(;¸T×=^Ñ=^Ô`cÐdh×d|Ñd|Ó`}Ð~Ð~rN   c                 ó|   — | j                  «       }| j                  |k7  r|| _        | xj                  dz  c_        y y rD  )r“  r±  r”  )rJ   Úcur_keys     rM   Ú_update_version_counterz ShapeEnv._update_version_counter•  s;   € ð —-‘-“/ˆØ×Ñ 7Ò*Ø#*ˆDÔ Ø×!Ò! QÑ&Ö!ð +rN   Úex_sizerG  c                 ó:   — | j                  t        |«      ||«      S rG   )Ú!_produce_dyn_sizes_from_int_tupler:  )rJ   r'  r  rG  s       rM   Ú_produce_dyn_sizeszShapeEnv._produce_dyn_sizes   s   € ð
 ×5Ñ5´e¸G³nÀfÐN^Ó_Ð_rN   Útensor_sizec                 ó8  — t        d„ |D «       «      s
J d|› �«       ‚ddlm}m} t	        |«       |j
                  }|j                  }g }t        |«      D ]B  \  }	}
|j                  | j                  |
 |||j                  |	«      ||	   ||	   |¬«      «       ŒD |S )Nc              3   ó4   K  — | ]  }t        |«       –— Œ y ­wrG   )rX  )r_  rU  s     rM   ra  z=ShapeEnv._produce_dyn_sizes_from_int_tuple.<locals>.<genexpr>¬  s   è ø€ Ò?¨C”{ 3Ó'Ô'Ñ?ùrb  z0Expect size to be a plain tuple of ints but got r   ©r?   ÚTensorPropertyrF  )rl  r+  r?   r/  rH  rU  rW  Ú	enumeraterÀ   Úcreate_symbolÚSIZE)rJ   r+  r  rG  r?   r/  Údynamic_dimsÚconstraint_dimsr  rê   rU  s              rM   r)  z*ShapeEnv._produce_dyn_sizes_from_int_tuple§  sÀ   € ô
 Ñ?°;Ô?Ô?ð  	BÐCsÐtð  tAð  BBó  	BÐ?ßMÜÐ/Ô0Ø'×5Ñ5ˆØ*×;Ñ;ˆØˆÜ Ó,ò 	‰FˆAˆsØ�K‰K˜×*Ñ*ØÙ$ V¨^×-@Ñ-@À!ÓDØ˜Q‘Ø Ñ"Ø!1ð +ó õ ð	ð ˆrN   rF  Úexc                ó`  ‡ — t        ˆ fd„|j                  «       D «       «      }t        ˆ fd„|j                  «       D «       «      }‰ j                  |j	                  «       «      }‰ j                  |||t        |j                  «       «      D �cg c]  }t        ||«      ‘Œ c}||¬«      S c c}w )zÌ
        Returns a list of symbolic sizes and strides for the given tensor.
        We try our best to express stride in terms of the sizes, so as to not
        introduce new symbolic variables.
        c              3   ó@   •K  — | ]  }‰j                  |«      –— Œ y ­wrG   ©Ú#_maybe_specialize_sym_int_with_hint)r_  ÚszrJ   s     €rM   ra  zHShapeEnv.create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>É  s   øè ø€ ÒYÈ˜×@Ñ@À×DÑYùó   ƒc              3   ó@   •K  — | ]  }‰j                  |«      –— Œ y ­wrG   r8  )r_  ÚsdrJ   s     €rM   ra  zHShapeEnv.create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>Ê  s   øè ø€ Ò]È2˜$×BÑBÀ2×FÑ]ùr;  rF  )	r:  r  r  r9  r  Ú-_create_symbolic_sizes_strides_storage_offsetr�  rÃ   Ú_is_dim_dynamic)rJ   r5  r  rG  r'  Ú	ex_strideÚex_storage_offsetrê   s   `       rM   Ú,create_symbolic_sizes_strides_storage_offsetz5ShapeEnv.create_symbolic_sizes_strides_storage_offset¼  s›   ø€ ô ÓYÈrÏwÉwËyÔYÓYˆÜÓ]ÐQS×QZÑQZÓQ\Ô]Ó]ˆ	Ø ×DÑDÀR×EVÑEVÓEXÓYÐà×AÑAØØØÜ-2°2·6±6³8«_Ö=¨Œ_˜R Õ#Ò=ØØ-ð Bó 
ð 	
ùò >s   ÂB+c                 óÒ   — t        |t        t        j                  f«      sJ ‚t	        |«      r9|j
                  j                  | usJ d«       ‚|j
                  j                  «       S |S )NzFexpect the symbol is created from an shape env other than current one.)rÇ   rË   r²   r"   rX  rÈ   rð   rÉ   )rJ   Ú	maybe_syms     rM   r9  z,ShapeEnv._maybe_specialize_sym_int_with_hintø  s`   € Ü˜)¤c¬5¯<©<Ð%8Ô9Ð9Ð9Ü�yÔ!Ø—>‘>×+Ñ+°4Ñ7ð YØXóYÐ7à—>‘>×.Ñ.Ó0Ð0ØÐrN   r@  rA  Úis_dim_dynamicc                óÀ	  — t        |«      }|€¼d g|z  }d g|z  }	g }
g }t        |«      D ]g  }||   rt        j                  }n-| j                  rt        j
                  }nt        j                  }|
j                  |«       |j                  |«       Œi t        j                  g|z  }
t        j                  g|z  }t        |
|||	¬«      }t        |«       |j                  }|j                  }	|j                  }|j                  }t        d„ |D «       «      rt        j
                  nt        j                  }t        d„ |D «       «      }t        |«      |k(  sJ t        |«      › d|› �«       ‚t        |«      |k(  sJ t        |«      › d|› �«       ‚t        |«      |k(  sJ ‚t        |	«      |k(  sJ ‚ddlm}m} | j'                  |||«      }d gt        |«      z  }t)        |«      D ]"  \  }}|dv sŒt+        j,                  |«      ||<   Œ$ t/        d„ |D «       «      �r˜t        t        |«      «      D �ci c]$  }||   �||   dk\  r||   ||   z  ||   ||   z  “Œ& }}d	„ }t1        t        t        |«      «      D �cg c]  }||   �Œ	||   |f‘Œ c}|¬
«      }|D ]L  \  }}||   �Œ||   t        j                  k(  sŒ#||   |v sŒ+|||      ||<   ||   ||   z  |||   ||   z  <   ŒN t/        d„ |D «       «      r¥t3        t        t        |«      «      D �cg c]  }||   €||   |f‘Œ c}|¬
«      \  }}||   }||   t        j                  k(  r"|rt        j
                  nt        j                  }| j5                  | |||j6                  |«      ||	|   |¬«      ||<   t/        d„ |D «       «      r�Œ˜t        d„ |D «       «      sJ ‚t)        t9        ||«      «      D ���cg c].  \  }\  }}| j;                  || |||j<                  |«      ¬«      ‘Œ0 }}}}g }t)        |«      D ]A  \  }}|€J ‚|j                  | j;                  |||    |||j6                  |«      ¬«      «       ŒC | j;                  | j5                  | |||j>                  «      |d |¬«      | |||j>                  «      ¬«      } tA        |«      tA        |«      | fS c c}w c c}w c c}w c c}}}w )N©rU  rV  rW  rX  c              3   óB   K  — | ]  }|t         j                  k(  –— Œ y ­wrG   ©r  r  ©r_  rv  s     rM   ra  zIShapeEnv._create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>4  s   è ø€ Ò1`ÈQ°!´z×7HÑ7HÕ2HÑ1`ùó   ‚c              3   óB   K  — | ]  }|t         j                  k(  –— Œ y ­wrG   rI  rJ  s     rM   ra  zIShapeEnv._create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>5  s   è ø€ ÒM¸!˜q¤J×$5Ñ$5Õ5ÑMùrK  rÝ   r   r.  r™  c              3   ó$   K  — | ]  }|d u –— Œ
 y ­wrG   rZ   ©r_  rH  s     rM   ra  zIShapeEnv._create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>B  s   è ø€ Ò, �!�t”)Ñ,ùr	  c                 óp   — t        | d   «      r#d| d   j                  j                  «       | d   fS dg| ¢­S )Nr   r½   )ri   rÈ   Únested_int_coeff)Útups    rM   Ú_nested_int_aware_sortzVShapeEnv._create_symbolic_sizes_strides_storage_offset.<locals>._nested_int_aware_sortJ  sH   € ô DQÐQTÐUVÑQWÔCX�Q˜˜A™Ÿ™×4Ñ4Ó6¸¸A¹Ð?ðð ˜˜c™ð	rN   rw  c              3   ó$   K  — | ]  }|d u –— Œ
 y ­wrG   rZ   rN  s     rM   ra  zIShapeEnv._create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>[  s   è ø€ Ò- �1˜”9Ñ-ùr	  )Údynamic_dimÚconstraint_dimrG  c              3   ó$   K  — | ]  }|d u–— Œ
 y ­wrG   rZ   rN  s     rM   ra  zIShapeEnv._create_symbolic_sizes_strides_storage_offset.<locals>.<genexpr>o  s   è ø€ Ò1 Q�1˜D”=Ñ1ùr	  ©r‚  r  )!r  r�  r  r  rƒ  r  r  rÀ   r  ro   rH  rW  rX  rU  rV  rl  r+  r?   r/  r)  r0  rR   rÔ   rË  ry  rá  r1  ÚSTRIDErè   rƒ  r2  ÚSTORAGE_OFFSETr:  )!rJ   r'  r@  rA  rE  r  rG  rÃ   rW  rX  r3  rV  rê   rv  rU  Údynamic_offsetÚare_sizes_staticr?   r/  r  r  rU  Ú
candidatesrR  Úval_listr¦  Ú
dyn_strideÚsymr‚  Ú	sym_sizesr   Ústride_exprr!  s!                                    rM   r>  z6ShapeEnv._create_symbolic_sizes_strides_storage_offset   s‚  € ô �'‹lˆð Ð#Ø $˜v¨™|ÐØ"& ¨#¡ÐØˆLØ ˆOÜ˜3“Zò 
*�ð " !Ò$Ü"×*Ñ*‘AØ×2Ò2Ü"×)Ñ)‘Aä"Ÿ™�AØ×#Ñ# AÔ&Ø×&Ñ& qÕ)ð
*ô 'ŸO™OÐ,¨sÑ2ˆLÜ)×6Ñ6Ð7¸#Ñ=ˆOä7Ø*Ø /Ø!1Ø#5ô	 Ðô 	Ð/Ô0Ø+×<Ñ<ÐØ-×@Ñ@ÐØ(×6Ñ6ˆØ*×:Ñ:ˆô /2Ñ1`ÐR_Ô1`Ô.`œ×*Ò*Ôfp×fuÑfuˆÜÑM¸}ÔMÓMÐä�=Ó! SÒ(ÐJ¬S°Ó-?Ð,@ÀÀSÀEÐ*JÓJÐ(Ü�?Ó# sÒ*ÐL¬s°=Ó/AÐ.BÀ$ÀsÀeÐ,LÓLÐ*ÜÐ#Ó$¨Ò+Ð+Ð+ÜÐ%Ó&¨#Ò-Ð-Ð-çMØ!%×!GÑ!GÈÐQWÐYiÓ!jˆØ.2¨V´c¸$³iÑ-?ˆÜ 	Ó*ò 	/‰FˆAˆsØ�fŠ}Ü!ŸM™M¨#Ó.��q’	ð	/ô Ñ, VÔ,Õ,ô œs 4›yÓ)öàØ˜!‘9Ð(¨Y°q©\¸QÒ->ð ˜‘
˜Y q™\Ñ)¨4°©7°V¸A±YÑ+>Ñ>ðˆJð òô Ü,1´#°f³+Ó,>ÖT qÀ&ÈÁ)ÑBS�)˜A‘, Ò"ÒTØ*ôˆHð !ò P‘��1à˜!‘9Ñ$¨¸Ñ);¼z×?VÑ?VÓ)VÐ[dÐefÑ[gÐkuÒ[uØ *¨9°Q©<Ñ 8�F˜1‘IØ<@À¹GÀfÈQÁiÑ<O�J˜w q™z¨I°a©LÑ8Ò9ð	Pô Ñ- fÔ-Ô-äô "'¤s¨6£{Ó!3öàØ! !™9Ð,ð # 1™ qÒ)òð 2ô‘��Qð -¨QÑ/�
Ø" 1Ñ%¬×)@Ñ)@Ò@Ù6F¤×!2Ò!2ÌJÏOÉO�JØ ×.Ñ.ØÙ(¨°×1FÑ1FÈÓJØ *Ø#5°aÑ#8Ø%5ð /ó ��q‘	ôM Ñ, VÔ,Ö,ôZ Ñ1¨&Ô1Ô1Ð1Ð1ô #,¬C°°gÓ,>Ó"?÷
ð 
ñ �‘;�C˜ð ×"Ñ"ØØÙ+¨F°N×4GÑ4GÈÓKð #õ ð
ˆ	ò 
ð ˆ
Ü'¨Ó/ò 	p‰NˆAˆ{ð Ð*Ð*Ð*Ø×Ñ˜d×4Ñ4Ø )¨A¡,Ñ7KÈFÐTb×TiÑTiÐklÓ7mð 5ó oõ pð		pð "×3Ñ3Ø×ÑØ!Ù$ V¨^×-JÑ-JÓKØ*Ø#Ø!1ð ó ð #Ù'¨°×0MÑ0MÓNð 4ó 	PÐô �YÓ¤ zÓ!2Ð4FÐFÐFùòOùò Uùòùô&
s   È2)S
É;
SÊ	SÌSÏ!3S)r  r_  r`  r‚  c          	      ó¶  — |r|j                  «       nd}| j                  rS|�Q| j                  |«      }|€J ‚| j                  |t        «      }| j                  t        j                  ||«      «       nd}t        |t        j                  «      r|�t	        |«      |k(  sJ ‚t	        |«      }|S t        |«      rd}t        t        || t        ||¬«      «      }|S )zäCreate a SymInt value from a symbolic expression

        If you know what the current hint value of the SymInt to be created
        is, pass it into hint.  Otherwise, pass None and we will make our best
        guess

        N©Úfx_node)r„  r�  rú  r  rË   r  rR   r  rÇ   rÔ   rq  r"   r   ©rJ   r_  r‚  r  Úsource_namer¼  rd  Úouts           rM   rƒ  zShapeEnv.create_symintnodeŒ  sÒ   € ñ (.�f—k‘k”m°4ˆà×/Ò/°FÐ4Fà×3Ñ3°FÓ;ˆFØÐ%Ð%Ð%ð ×;Ñ;¸FÄCÓHˆGð ×Ñ¤§¡¨°Ó 5Õ6àˆGä�cœ5Ÿ=™=Ô)ØÐÜ˜3“x 4Ò'Ð'Ð'Ü�c“(ˆCð ˆ
ô % SÔ)Ø�Üœ  d¬C°¸wÔGÓHˆCØˆ
rN   c          	      óÄ  — |r|j                  «       nd}| j                  rS|�Q| j                  |«      }|€J ‚| j                  |t        «      }| j                  t        j                  ||«      «       nd}t        |t        j                  «      r|�t	        |«      |k(  sJ ‚t	        |«      }|S t        |«      r	|�J |«       ‚t        t        || t        ||¬«      «      }|S )z2Create a SymFloat value from a symbolic expressionNrc  )r„  r�  rú  r  rå   r  rR   r  rÇ   ÚFloatrq  r!   r   re  s           rM   Úcreate_symfloatnodezShapeEnv.create_symfloatnode¹  sÜ   € ñ (.�f—k‘k”m°4ˆà×/Ò/°FÐ4Fà×3Ñ3°FÓ;ˆFØÐ%Ð%Ð%ð ×;Ñ;¸FÄEÓJˆGð ×Ñ¤§¡¨°Ó 5Õ6àˆGä�cœ5Ÿ;™;Ô'ØÐÜ˜S“z TÒ)Ð)Ð)Ü˜“*ˆCð ˆ
ô % SÔ)Ø�|Ð( SÓ(�|Üœ7 3¨¬e°TÀ7ÔKÓLˆCØˆ
rN   c                 óN   — | j                  | j                  |||¬«      ||¬«      S )z1Create a SymInt wrapping a new unspecified symbol)r  rT  rW  )rƒ  Úcreate_unspecified_symbol)rJ   rÂ  r  rT  s       rM   Ú$create_unspecified_symint_and_symbolz-ShapeEnv.create_unspecified_symint_and_symbolß  s@   € ð ×%Ñ%Ø×*Ñ*ØØØ'ð +ó ð
 Øð &ó 
ð 	
rN   c                 ó8   — t        t        || t        d«      «      S )z7Create a SymBool object from a sympy boolean expressionN)r    r   rØ   ©rJ   r_  s     rM   Úcreate_symboolnodezShapeEnv.create_symboolnodeì  s   € ô ”w˜s D¬$°Ó5Ó6Ð6rN   Úprefixr  c                 ó   — t         j                  d uxr* t        |«      t         j                  j                  d«      v }| j	                  |«      \  }}}t
        j                  d|||j                  |j                  |t        |«      ||¬«	       y )Nú,z%s %s [%s, %s]%s (%s)%s©Ú
stack_info)
r›  Úextended_debug_create_symbolr�  rj  Ú_get_stack_summaryr}   r  r  r   r7   )rJ   rq  r¼  r  Úis_debugÚfsummaryÚmaybe_user_locÚmaybe_extra_debugs           rM   Ú_log_create_unbacked_symbolz$ShapeEnv._log_create_unbacked_symbolò  sŽ   € Ü×6Ñ6¸dÐBò  EÄsÈ6Ã{ÔV\×VyÑVy×VÑVð  ADó  WEð  HEˆØ6:×6MÑ6MÈhÓ6WÑ3ˆ�.Ð"3Ü�‰Ø%Ø�F˜BŸH™H b§h¡h°ÄÈXÓ@VÐXiÐv~ð 	õ 	
rN   c           	      ó  — t        t        j                  t        | j                  «      «      }| j
                  dxx   dz  cc<   | j                  «       s| j                  j                  |«       t        j                  d¬«      | j                  |<   t        j                  «       x}| j                  |<   |j                  sJ ‚| j!                  |t"        «      }| j%                  d||«       t'        t)        || t"        d|¬«      «      S )z5Create a symbolic float without a hint value
        Úcreate_unbacked_symbolr½   ©rò  Úcreate_unbacked_symfloatNrc  )r<   r;   rp  rd  r§  r¯  rì  r«  rÀ   r8   Úextractr   r3   Úunknownr  Úis_floatr  rå   r|  r!   r   ©rJ   r¼  r  rd  s       rM   r€  z!ShapeEnv.create_unbacked_symfloatú  sÚ   € ô  +¬4×+>Ñ+>ÄÀT×EcÑEcÓ@dÓeˆØ�‰Ð-Ó.°!Ñ3Ó.Ø×6Ñ6Ô8Ø×/Ñ/×6Ñ6°vÔ>Ü$5×$=Ñ$=À1Ô$Eˆ×Ñ˜&Ñ!Ü)4×)<Ñ)<Ó)>Ð>ˆˆT×Ñ˜vÑ&Ø�{Š{Ðˆ{ð ×7Ñ7¸ÄÓFˆà×(Ñ(Ð)CÀVÈRÔPäœ ¨¬e°TÀ7ÔKÓLÐLrN   c           	      ó  — t        t        j                  t        | j                  «      d¬«      }| j                  «       s| j                  j                  |«       | j                  dxx   dz  cc<   t        j                  d¬«      | j                  |<   | j                  «       x}| j                  |<   |j                  sJ ‚| j                  |t         «      }| j#                  d||«       t%        t'        || t         d|¬«      «      S )	z7Create a symbolic integer without a hint value
        Tr  r~  r½   r  Úcreate_unbacked_symintNrc  )r<   r;   ro  rd  r¨  rì  r«  rÀ   r¯  r8   r�  r   Ú _default_unspecified_value_ranger  Úis_intr  rË   r|  r"   r   r„  s       rM   r†  zShapeEnv.create_unbacked_symint  sÝ   € ô  +¬4×+<Ñ+<¼dÀ4×C_ÑC_Ó>`ÐjnÔoˆØ×6Ñ6Ô8Ø×/Ñ/×6Ñ6°vÔ>Ø�‰Ð-Ó.°!Ñ3Ó.Ü$5×$=Ñ$=À1Ô$Eˆ×Ñ˜&Ñ!Ø)-×)NÑ)NÓ)PÐPˆˆT×Ñ˜vÑ&Ø�yŠyÐˆyð ×7Ñ7¸ÄÓDˆà×(Ñ(Ð)AÀ6È2ÔNä”g˜f d¬C°¸wÔGÓHÐHrN   c                 ó6   — t        |t        j                  «      S )zSCheck if a sympy symbol matches the naming convention for unbacked symbols
        ©r=   r;   ro  )rJ   r¼  s     rM   rÞ  zShapeEnv.is_unbacked_symint   s   € ô ˜f¤d×&7Ñ&7Ó8Ð8rN   c           	      ó0  — t        t        j                  t        | j                  «      d¬«      }| j                  «       s| j                  j                  |«       | j                  dxx   dz  cc<   t        j                  d¬«      | j                  |<   t        dd«      x}| j                  |<   |j                  sJ ‚| j                  |t         «      }| j#                  d||«       t%        t'        t)        j*                  |d«      | t         d|¬	«      «      S )
z7Create a symbolic boolean without a hint value
        Tr  r~  r½   r  r   Úcreate_unbacked_symboolNrc  )r<   r;   ro  rd  r¨  rì  r«  rÀ   r¯  r8   r�  r   r3   r  rˆ  r  rØ   r|  r    r   rR   r  r„  s       rM   rŒ  z ShapeEnv.create_unbacked_symbool%  sæ   € ô  +¬4×+<Ñ+<¼dÀ4×C_ÑC_Ó>`ÐjnÔoˆØ×6Ñ6Ô8Ø×/Ñ/×6Ñ6°vÔ>Ø�‰Ð-Ó.°!Ñ3Ó.Ü$5×$=Ñ$=À1Ô$Eˆ×Ñ˜&Ñ!Ü)4°Q¸Ó):Ð:ˆˆT×Ñ˜vÑ&Ø�yŠyÐˆyð ×7Ñ7¸ÄÓEˆà×(Ñ(Ð)BÀFÈBÔOä”wœuŸx™x¨°Ó2°D¼$ÀÈgÔVÓWÐWrN   rU  rT  rU  c           	      ó2   — | j                  ||||ddd¬«      S )z³Create a symbol with an unspecified value

        Compared to standard symbols we do not assume the value is positive,
        nor do we specialze on zero or one values.
        NT)ÚpositiveÚdo_not_specialize_zero_onerG  )r1  )rJ   rU  r  rT  rU  s        rM   rl  z"ShapeEnv.create_unspecified_symbol8  s1   € ð$ ×!Ñ!ØØØØØØ'+Ø!ð "ó #ð 	#rN   rŽ  r�  c                 óÌ  — t        |t        «      rÂ|j                  j                  |j                  j                  k(  r•t
        j                  }|j                  j                  |k7  r6t        d|j                  j                  › d|› d|j                  «       › �«      ‚|r2||j                  |j                  <   d|j                  |j                  <   d}|j                  «       }t        |t        «      r/t        | «      |j                  vri |j                  t        | «      <   t        |t        «      r7|r5||j                  t        | «         v r|j                  t        | «         |   S |t
        j                  u rd| j!                  «       j"                  j$                  }	| j'                  |	«       t        |t        «      r|r|	|j                  t        | «         |<   |	S |rd}
n| j(                  }
t        |t*        «      sJ t-        |«      › d|› �«       ‚|r|dk  r
J d|› �«       ‚|�t
        j.                  }|t
        j                  u rDt1        j2                  |«      }	t        |t        «      r|r|	|j                  t        | «         |<   |	S |t
        j4                  u r| j6                  }n#|t
        j.                  u rd}nt9        d	|› �«      ‚|d
v r|
r| j:                  |   }�nÓ|r|| j:                  v�rˆt-        |«      t<        u st?        |«      r1tA        tB        jD                  tG        | jH                  «      |d¬«      }n0tA        tB        jJ                  tG        | jH                  «      |d¬«      }t        |t<        «      r#t1        j2                  |«      | jH                  |<   n}t        |tL        «      r#t1        jN                  |«      | jH                  |<   nJtQ        |j"                  jS                  «       |j"                  jU                  «       ¬«      | jH                  |<   g | jV                  |<   | jY                  |t<        «       |r|| j:                  |<   t        |t<        «      rí|r2| j[                  |dkD  «       | j]                  «       | j^                  |<   n| ja                  «       | j^                  |<   t        |t        «      r%|rJ ‚| j^                  |xx   |j                  z  cc<   | j^                  |   }|jb                  sJ ‚||vr(t        |› d|j                  › d|j                  › d�«      ‚d|j                  › d|j                  › d�}nut        |tL        «      rcte        t0        jf                   t0        jf                  «      x| j^                  |<   }d|j                  › d|j                  › d�}|jh                  sJ ‚d}|}tj        jl                  duxr* to        |«      tj        jl                  jq                  d«      v }d}|sd|› d�}| js                  |«      \  }}}| jt                  jw                  d|||j                  «       ||ty        |«      |||¬«
       | jz                  dxx   dz  cc<   n:| j:                  |   }| jt                  j}                  d||j                  «       «       t        |t0        j~                  «      rc| jV                  |   }|j�                  |«       |jƒ                  «       s$|d   jƒ                  «       r|d   |d   c|d<   |d<   d| j„                  |<   t        |t        «      r|r||j                  t        | «         |<   |S )z>Create a new symbol which is tracked by this ShapeEnv
        zStatic shape constraint of z does not match input size of z, for NFrW  r   z!positive set for negative value: zunhandled dynamic_dim r™  T©rŽ  r  )rŽ  rœ  )Úcoeffr½   z not in range [rk  rì  ú[r×   rs  zC, for more info run with TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="ú"z*create_symbol %s = %s for %s %s%s (%s)%s%srt  r1  zcreate_symbol %s duck sized %sr¾   )CrÇ   r  r  r  r   r  r  r·   r„  rU  ÚidxrW  rp   Úidra  r  r†  rÈ   rÑ   rß  r„  r$   rÊ   r  rR   rÔ   r  r…  r[  r¤  rË   ri   r<   r;   r2  r  rß  ÚFLOATrå   ri  r6   Ú
nested_intrP  r­  rý  r  Ú_default_value_ranger  r‡  rˆ  r3   Úoorƒ  r›  rv  r�  rj  rw  r}   r  r7   r¯  r~   r  rÀ   Úis_ephemeralr°  )rJ   rU  r  rT  rU  rŽ  r�  rG  rf  rg  r„  Úduckrv  Ú
sympy_exprr  Ú	range_strrx  Úmaybe_more_infory  rz  r{  Ú	r_sourcess                         rM   r1  zShapeEnv.create_symbolS  sœ  € ô �nÔ&<Ô=À.×BSÑBS×BYÑBYÐ]k×]nÑ]n×]tÑ]tÒBtÜ$×+Ñ+ˆKØ× Ñ ×&Ñ&¨#Ò-Ü.Ø1°.×2CÑ2C×2IÑ2IÐ1JÐJhÐilÐhmð nØ!Ÿ;™;›=˜/ð+óð ñ  Ø=HÐ ×.Ñ.¨v¯z©zÑ:Ø@DÐ ×1Ñ1°&·*±*Ñ=Ø!ˆNð —k‘k“mˆÜÐ'Ô)@ÔAÜ�t“HÐ$4×$XÑ$XÑXØMOÐ×@Ñ@ÄÀDÃÑJäÐ'Ô)@ÔAÙØ Ð$4×$XÑ$XÔY[Ð\`ÓYaÑ$bÑbØ#×GÑGÌÈ4ËÑQÐR]Ñ^Ð^àœ*×7Ñ7Ñ7Ø×-Ñ-Ó/×4Ñ4×9Ñ9ˆCØ×*Ñ*¨3Ô/äÐ*Ô,CÔDÉØ^aÐ ×DÑDÄRÈÃXÑNÈ{Ñ[ØˆJá%Ø"'Ñà"&×":Ñ":Ðä˜&¤&Ô)ÐE¬d°6«l¨^¸1¸V¸HÐ+EÓEÐ)Ù  q¢ÐTÐ-NÈsÈeÐ+TÓTÐ)ð Ð%Ü$×,Ñ,ˆKàœ*×+Ñ+Ñ+Ü—-‘- Ó$ˆCÜÐ*Ô,CÔDÉØ^aÐ ×DÑDÄRÈÃXÑNÈ{Ñ[ØˆJàœJŸO™OÑ+ð —?‘?‰DØœJ×.Ñ.Ñ.Ø‰Dä Ð#9¸+¸Ð!GÓHÐHà�&‰=Ñ0Ø—‘ Ñ$ŠAÙ˜ D§O¡OÒ3ô �C‹yœCÑ¤=°Ô#5Ü(¬¯©´C¸¿¹Ó4HÐS[ÐeiÔj‘
ä(¬¯©´S¸¿¹Ó5IÐT\ÐcgÔh�
ä˜#œsÔ#Ü.3¯m©m¸CÓ.@�—‘ 
Ò+Ü˜C¤Ô'Ü.3¯k©k¸#Ó.>�—‘ 
Ò+ô /;¸3¿8¹8×;NÑ;NÓ;PÐX[×X`ÑX`×XqÑXqÓXsÔ.t�—‘ 
Ñ+ð /1ˆD×Ñ 
Ñ+à�O‰O˜J¬Ô,áà'1�—‘ Ñ$ä˜#œsÔ#Ùà×'Ñ'¨
°Q©Ô7ð 59×4MÑ4MÓ4O�D×%Ñ% jÒ1à48×4YÑ4YÓ4[�D×%Ñ% jÑ1ô ˜nÔ.DÔEÙ#�O˜8Ø×%Ñ% jÓ1°^×5FÑ5FÑFÓ1à×&Ñ& zÑ2�Ø—y’yÐ �yà˜b‘=Ü2°c°U¸/È"Ï(É(ÈÐSUÐVX×V^ÑV^ÐU_Ð_`Ð3aÓbÐbà §¡˜z¨¨B¯H©H¨:°QÐ7‘	Ü˜C¤Ô'Ü5@Ä%Ç(Á(ÀÌEÏHÉHÓ5UÐU�×!Ñ! *Ñ-°Ø §¡˜z¨¨B¯H©H¨:°QÐ7�	Ø—{’{Ð"�{ð �	àˆAô ×3Ñ3¸4Ð?ò RÜ�J“¤6×#FÑ#F×#LÑ#LÈSÓ#QÐQð ð !ˆOÙðAØAKÀÈAðOð  ð ;?×:QÑ:QÐRZÓ:[Ñ7ˆH�nÐ&7Ø�H‰H�M‰MØ<Ø˜C §¡£°	Ø¤¨XÓ 6¸ÐIZÐgoð ô ð �L‰L˜Ó)¨QÑ.Ô)ð —‘ Ñ$ˆAØ�H‰H�N‰NÐ;¸QÀÇÁÃÔNä�aœŸ™Ô&Ø×+Ñ+¨AÑ.ˆIØ×Ñ˜VÔ$Ø×&Ñ&Ô(¨Y°q©\×-FÑ-FÔ-Hà.7¸©m¸YÀq¹\Ð+�	˜!‘˜i¨™mð
 ,-ˆD×%Ñ% aÑ(äÐ&Ô(?Ô@Á[ØZ[Ð×@Ñ@ÄÀDÃÑJÈ;ÑWØˆrN   rÑ   c                 óª   — t         j                  d||d¬«       || j                  vs
J |› d�«       ‚t        j                  |«      | j                  |<   y)z0 Adds a new symbol to the symbolic environment. zadd_var_to_val %s %sTrt  z already existsN)r}   r~   rß  rR   rÔ   )rJ   rÑ   rU  s      rM   Úadd_var_to_valzShapeEnv.add_var_to_val  sL   € ä�	‰	Ð(¨$°Àˆ	ÔEØ˜4Ÿ?™?Ñ*ÐD¨t¨f°OÐ,DÓDÐ*Ü %§¡¨cÓ 2ˆ�‰˜ÒrN   c                 óZ   — |j                  «       }| j                  j                  ||«      S rG   )r„  rÈ  rï   )rJ   r  Úsrc_names      rM   Ú_debug_namezShapeEnv._debug_name  s&   € Ø—;‘;“=ˆØ×-Ñ-×1Ñ1°(¸HÓEÐErN   c                 ó  — t        |t        «      ræ|j                  j                  |j                  j                  }}| j                  «       }||j                  k  rd }||j                  k\  rd }| j                  |«      › d|j                  «       › d�}|�!|�|d|› d| j                  |«      › d|› �z  }|S |€|�|d| j                  |«      › d|› �z  }|S |�|€|d|› d| j                  |«      › �z  }|S |j                  |«      S )Nr7  z in the specified rangerW  r  )	rÇ   r  r  r  r   r™  r¥  r„  r"  )rJ   r  rH  r  r   r  Úc_renders          rM   Ú&_render_range_for_constraint_violationz/ShapeEnv._render_range_for_constraint_violation  s/  € Ü�aÔ/Ô0ØŸ4™4Ÿ:™: q§t¡t§z¡z�5ˆEØ×/Ñ/Ó1ˆGØ˜Ÿ™Ò%Ø�Ø˜Ÿ™Ò%Ø�Ø×*Ñ*¨6Ó2Ð3°3°v·{±{³}°oÐE\Ð]ˆHØÐ  UÐ%6Ø˜a ˜w d¨4×+;Ñ+;¸FÓ+CÐ*DÀDÈÈÐPÑP�ð
 ˆOð	 � 5Ð#4Ø˜a × 0Ñ 0°Ó 8Ð9¸¸e¸WÐEÑE�ð ˆOð Ð" u }Ø˜a ˜w d¨4×+;Ñ+;¸FÓ+CÐ*DÐEÑE�ØˆOØ�x‰x˜ÓÐrN   c                 ó"   — | j                  «       S rG   r‡  rÄ  s    rM   râ   zShapeEnv.<lambda>"  s   € ˜QŸV™V›X€ rN   )rž  Úinput_contextsÚequalities_inputsÚ_simplifiedr  rž  rª  r«  c                ó¸!  ‡ ‡‡‡@‡A‡B‡C‡D‡E‡F‡G‡H‡I‡J‡K‡L— ‰ j                   j                  d«       ‰ j                  r&t        ‰ j                  «      }	‰ j                  |	«       t        ‰«      t        |«      k(  sJ d‰› d|› d�«       ‚t        j                  t        f}
d„ }|€$‰D �cg c]  }t        ||
«      r ||«      nd‘Œ }}nˆt        |«      t        ‰«      k(  sJ ‚t        t        ‰|«      «      D ]W  \  }\  }}t        ||
«      r|�Œ ||«      ||<   Œ$t        |t        t        t        t         f«      sJ ‚t        |t"        «      sŒWJ ‚ ddlmŠAmŠ@ g ŠEt+        j,                  t"        «      ŠLt+        j,                  t.        «      ŠKg ŠBd9ˆBfd	„	ŠHˆ@ˆAfd
„ŠF|�rQi ŠIt        |«      D ]  \  }}|‰I|j1                  «       <   Œ ˆˆIfd„}|j2                  D ]Ê  \  }} ||«       ||«      }}‰ j5                  t7        j8                  ||«      «      }|rŒ>t;        |j1                  «       › dt        |t        «      r|n|j=                  ‰ j>                  «      › d|j1                  «       › dt        |t        «      r|› �«      ‚|j=                  ‰ j>                  «      › �«      ‚ |j@                  D �]  \  }}} ||«      }t        |t6        jB                  «      r"|‰ jD                  |   d   j1                  «       fn ||«      ‰ jG                  |«      f\  }} ||«      }‰ j5                  t7        j8                  ||«      «      }|rŒ˜t;        d|j1                  «       › d |t7        jB                  |«      «      › d|› d|j=                  ‰ j>                  «      › d|j=                  ‰ j>                  «      › �
«      ‚ |jH                  D ]#  }‰L|   jK                  ‰ jD                  |   «       Œ% d9ˆEˆHˆ ˆˆKˆLfd„	}ˆEˆLfd„}t        ‰||«      D �]O  \  }}}t        |tL        «      rddlm'}  ||«      }t        |tP        «      sJ ‚|€Œ;t        |t        t        f«      r
 |||«       Œ[t        |t        t         f«      r
 |||«       Œ{t        ||
«      sJ ‚tS        |«      r™ddlm*} t        |tV        «      sJ ‚|||jX                  |jZ                  fg} |j]                  «       \  }!}"|!D ]M  }#t_        ||#«      }$|j`                  |#   }%| jc                   |||#«      |$|%jX                  |%jZ                  f«       ŒO n|||jX                  |jZ                  fg} | D �]  \  }}&}'}(te        |&«      rCt        |&jg                  «       «      D ]&  \  }}) ‰A|‰@jh                  |«      }* ||*|)|'|   «       Œ( ŒWt        |&jg                  «       «      D ]&  \  }}) ‰A|‰@jh                  |«      }* ||*|)|'|   «       Œ( t        |&jk                  «       «      D ]&  \  }}) ‰A|‰@jl                  |«      }* ||*|)|(|   «       Œ(  | ‰A|‰@jn                  «      |&jq                  «       «       �Œ �ŒR g ŠDts        ‰L‰ j>                  t/        ‰Kju                  «       «      ‰ jv                  «      ‰ _<        |�sV‰ED �]P  \  }ŠC‰ jz                  rP|j1                  «       }+|+‰ j|                  v r2‰ j                  t7        j8                  ‰ j|                  |+   ‰C«      «       t        ‰Ct6        jB                  «      r‰Lj�                  ‰C«      r|‰L‰C   d   k(  rŒš|r@t        |‰A«      r4‰Cj‚                  r(‰ j                   j…                  d ‰|«      › d‰C› �«       ŒÜ ‰F|«      r‰ jx                  j‡                  |‰C«       t‰        ‰L‰‰ jD                  «      j‹                  ‰C«      },‰Djc                   ‰|«      › d|,› �«       t        |‰A«      s�ŒP|jŒ                  ‰@jh                  u s�Œj|s�Œnt        ‰CjŽ                  «      dk(  s�Œˆt‘        t“        ‰CjŽ                  «      «      ŠJt        ‰Ct6        jB                  «      r”‰C‰Kv r�|j•                  |‰L‰C   d   «      sxd‰ jG                  |«      › d|j1                  «       › d‰ jG                  ‰L‰C   d   «      › d‰L‰C   d   j1                  «       › d�	}- ‰H|j–                  ‰ jG                  |«      |-«       t        ‰Ct6        jB                  «      r�Œp‰J‰Kv s�Œv|j™                  |‰L‰J   d   ˆCˆJfd„«      r�Œ•‰L‰J   d   }d‰ jG                  |«      › d|j1                  «       › d‰ jG                  |«      › d|j1                  «       › d‰ jG                  |«      › d‰Cj=                  ‰Jt7        jš                  ‰ jG                  |«      «      i«      › d�}- ‰H|j–                  ‰ jG                  |«      |-«       �ŒS t/        «       ŠGd tœ        d!dfˆDˆFˆGˆHˆ ˆˆKˆLfd"„}.|�|n‰ jž                  D ](  }/‰ j¡                  |/j¢                  d#¬$«      �Œ! |.|/«       Œ* ‰ j¤                  j�                  dg «      D ]V  }0‰ j¡                  |0j¢                  d#¬$«      �Œ!‰ j§                  |0j¢                  «      ŠC‰ jx                  j©                  ‰C«       ŒX ‰Lj«                  «       D �]  \  ŠJ}‰ j¬                  j�                  ‰J«      }1|1€‰J‰ j¬                  vrŒ3‰ j¬                  ‰J   }1|sJ ‚g }2|1j®                  t6        j°                   t²         fvrštµ        ˆFfd%„|D «       «      r9‰ jx                  j©                  t7        j¶                  ‰J|1j®                  «      «       |r'|1j®                  ‰ j¹                  «       j®                  k7  r$|2jc                  tM        |1j®                  «      «       |2jc                   ‰|d   «      «       |1jº                  t6        j°                  t²        fvrqtµ        ˆFfd&„|D «       «      r9‰ jx                  j©                  t7        j¼                  ‰J|1jº                  «      «       |2jc                  tM        |1jº                  «      «       t        |2«      dkD  �r$‰Djc                  d'j¿                  |2«      «       ‰K‰J   }3|3D ]ú  }4t        |4tÀ        «      sŒ|4jÂ                  ‰ j¹                  «       z  jÅ                  |1«      rŒA|d   }t7        jÆ                  t7        j¼                  |1j®                  ‰J«      t7        j¼                  ‰J|1jº                  «      «      ŠCt‰        ‰L‰‰ jD                  «      j‹                  ‰C«      }5‰ jÉ                  ||4«      }6d(|6› d)|5› �}- ‰H|4j–                  ‰ jG                  |«      |-«       Œü tË        ‰JtÌ        jÎ                  «      s�Œ‰Djc                  d* ‰|d   «      › d�«       �Œ" ‰Brég }7g }8t/        «       }9‰BD ]_  \  }:}}-|:r+d+t        |7«      dz   › d, |-«       › �}-|7jc                  |-«       Œ4d- |-«       › �}-|8jc                  |-«       |9j©                  |«       Œa t        |8«      dkD  r<d.j¿                  tÑ        |9«      «      }9d/j¿                  |8«      };t;        d0|9› d1|;› �«      ‚t        |7«      dkD  rt         j…                  d2t        |7«      «       tÓ        d3di ‰ jÔ                  ¥‰ jÖ                  ¥t        ‰D«      tÙ        d4„ ‰LjÛ                  «       D «       «      tÑ        ‰ jÜ                  jÛ                  «       d5¬6«      d7œ¥«       ‰ jz                  �rVdd8lomp}< ‰ j¤                  jÛ                  «       D ]$  }=|=D ]  }0‰ j                  |0j¢                  «       Œ Œ& ‰ j¬                  j«                  «       D ]ª  \  }>}?|?j®                  t6        j°                   t²         fvr/‰ j                  t7        j¼                  |?j®                  |>«      «       |?jº                  t6        j°                  t²        fvsŒ|‰ j                  t7        j¼                  |>|?jº                  «      «       Œ¬ tã        jä                  «       5   |<‰ jæ                  ‰ jè                  «      jë                  «        ddd«       |€‰ jí                  «        ‰DS c c}w # 1 sw Y   Œ"xY w):a}  
        Generates a list of guards strings which, when evaluated in a context that
        defines tensors for all the sources, returns True or False depending
        on if the guards in the list evaluated to True or not.  Primarily used by Dynamo,
        but this is also helpful for manual testing of guards (see
        evaluate_guards_for_args)

        For convenience in testing, a source is allowed to be a str,
        in which case we will assume it is a LocalSource

        simplified lets you omit duck sizing, equality and 0/1 guards.
        This is useful for testing when you don't care about the boilerplate
        guards, and it may be helpful for user output too (be careful though;
        some equality guards are nontrivial!  It would be nice to get simplified
        output to print them too).  It's private because it's not
        intended for normal use
        Úproduce_guardszlen(z	) != len(r—  c                 óè   — t        t        j                  g| j                  «       z  t        j                  g| j                  «       z  d g| j                  «       z  d g| j                  «       z  ¬«      S )NrG  )ro   r  r  rÃ   r  r2  s    rM   Ú_create_no_constraints_contextz?ShapeEnv.produce_guards.<locals>._create_no_constraints_contextQ  s]   € Ü+ä)×1Ñ1Ð2°Q·U±U³WÑ<Ü!+×!8Ñ!8Ð 9¸A¿E¹E»GÑ CØ"& ¨!¯%©%«'Ñ!1Ø$( 6¨A¯E©E«GÑ#3ôð rN   Nr   r.  c                 ó:   •‡‡— ‰j                  | |ˆˆfd„f«       y )Nc                  ó"   •— ‰ r‰›  ‰ «       › �S ‰S rG   rZ   )r‚  r¡  s   €€rM   râ   zNShapeEnv.produce_guards.<locals>.record_constraint_violation.<locals>.<lambda>±  s   ø€ ÁD°3°%¹»°xÐ0@€ Èc€ rN   )rÀ   )r  r8  r¡  r‚  Úconstraint_violationss     ``€rM   Úrecord_constraint_violationz<ShapeEnv.produce_guards.<locals>.record_constraint_violation¯  s   ú€ Ø!×(Ñ(Ø˜JÔ(QÐRõrN   c                 óP   •— t        | ‰«      xr | j                  ‰j                  u S rG   )rÇ   Úpropr2  )r=  r/  r?   s    €€rM   Úis_dimz'ShapeEnv.produce_guards.<locals>.is_dim´  s%   ø€ Ü˜cÐ#7Ó8Ò\¸S¿X¹XÈ×I\ÑI\Ð=\Ð\rN   c                 ó"  •— ‰‰| j                   j                  «             }|j                  | j                     }t	        |t
        j                  «      r|j                  j                  S t        |«      t        u sJ dt        |«      › �«       ‚|S )NzExpected int, got )rè  r„  r»   r•  rÇ   r²   r"   rÈ   rÑ   rÊ   rË   )Útensor_dim_srcrÍ  ÚsymintÚplaceholdersÚsource_indexs      €€rM   Úget_expressionz/ShapeEnv.produce_guards.<locals>.get_expression¼  s{   ø€ Ø# L°×1DÑ1D×1IÑ1IÓ1KÑ$LÑM�ØŸ™ N×$6Ñ$6Ñ7�Ü˜f¤e§l¡lÔ3Ø!Ÿ;™;×+Ñ+Ð+ä ›<¬3Ñ.ÐSÐ2DÄTÈ&Ã\ÀNÐ0SÓSÐ.Ø!�MrN   r7  z is not equal to zExpected input z to be equal to z, where z
, but got c           	      ó  •— t         j                  dt        | j                  «      ||«       t	        |t
        «      rt        |«      sJ ‚t	        |t
        «      r4|j                  j                  «       �|j                  j                  «       }t	        |t
        «      �r„|j                  j                  }t	        |t        j                  «      r>‰|   j                  | «       |��)t	        |t        «      �s‰|   j                  |«       �nd}t	        |t        «      rW|j                   D �ci c]  }|‰j"                  j%                  |d «      “Œ! }}t'        d„ |j)                  «       D «       «      r0d}n-t	        |t        «      r|j*                  rt-        |«      }|dvrd}|rjˆˆˆfd„}‰j/                  | |«      }	d|	› d‰j1                  | «      › d	�}
 ‰|j2                  ‰j1                  | «      |
t5        j6                  ||«      ¬
«       ‰j                  | |f«       y t        j8                  |«      }‰j                  | |f«       d}t	        |t        «      r8||j:                  j<                  cxk(  r|j:                  j>                  k(  sn d}nt	        |t        «      r|dvrd}|rQ‰j/                  | |«      }	d|	› d‰j1                  | «      › d|› d�}
 ‰|j2                  ‰j1                  | «      |
«       y y c c}w )Nztrack_symint %s %s %sFc              3   ó$   K  — | ]  }|d u –— Œ
 y ­wrG   rZ   )r_  r  s     rM   ra  z@ShapeEnv.produce_guards.<locals>.track_symint.<locals>.<genexpr>
  s   è ø€ ÒE¨b˜r TœzÑEùr	  Tr™  c                 óZ   •— t        ‰‰‰j                  «      j                  | «      }|› d�S r‘  )r©  r­  r,  )rT  ÚsexprrJ   r¬  r«  s     €€€rM   r‚  z;ShapeEnv.produce_guards.<locals>.track_symint.<locals>.hint  s1   ø€ Ü$5Ð6FÈ
ÐTX×TgÑTgÓ$h×$pÑ$pÐqrÓ$s˜EØ&+ W¨A ;Ð.rN   úNot all values of z are valid because z was inferred to be equal to r�  z  was inferred to be a constant (z).) r}   r~   r>   r„  rÇ   r"   rX  rÈ   Úmaybe_as_intrÑ   rR   r  rÀ   r$  ræ  r  rf   r  rï   rË  r¯  rk  rË   r¨  r¥  r  r†   ÚpartialrÔ   r  r  r   )r  rU  Ú
constraintrT  Úconstraint_violatedrH  Úsym_vrsrê   r‚  Úvar_with_ranger¡  Úinput_guardsr´  rJ   r¬  Úsymbol_to_constraintsr«  s              €€€€€€rM   Útrack_symintz-ShapeEnv.produce_guards.<locals>.track_symintõ  s¿  ø€ Ü�I‰IÐ-¬z¸&¿+¹+Ó/FÈÈZÔXÜ! #¤vÔ.´+¸cÔ2BÐBÐBä˜#œvÔ&¨3¯8©8×+@Ñ+@Ó+BÐ+NØ—h‘h×+Ñ+Ó-�ä˜#œvÕ&Ø—H‘H—M‘M�Ü˜a¤§¡Ô.Ø$ QÑ'×.Ñ.¨vÔ6à"Ñ.Ü *¨:Ô7NÕ Oà-¨aÑ0×4Ñ4°ZÖ@à*/Ð'Ü! *Ô.DÔEàNOÏnÉnÖ"]È 1 d×&7Ñ&7×&;Ñ&;¸A¸tÓ&DÑ#DÐ"]˜Ð"]ÜÑE°G·N±NÓ4DÔEÔEà26Ñ/Ü# JÔ0GÔHØŸ;š;Ü # A£˜Að  !¨™Ø6:Ð 3Ù*ö/ð *.×)TÑ)TÐU[Ð]gÓ)h˜à0°Ð0@Ð@SØ#×/Ñ/°Ó7Ð8Ð8UðWð ñ 4Ø&×0Ñ0Ø ×,Ñ,¨VÓ4ØÜ!*×!2Ñ!2°4¸Ó!;õ	ð ×#Ñ# V¨Q KÕ0ä—M‘M #Ó&�Ø×#Ñ# V¨Q KÔ0Ø&+Ð#Ü˜jÔ*@ÔAØ §¡×!4Ñ!4ÔK¸
¿¹×8KÑ8KÔKØ.2Ñ+Ü 
Ô,CÔDð  &Ñ(Ø.2Ð+Ù&Ø%)×%PÑ%PÐQWÐYcÓ%d�Nà,¨^Ð,<Ð<OØ×+Ñ+¨FÓ3Ð4Ð4TÐUXÐTYÐY[ð]ð ñ 0°
×0DÑ0DÀd×FVÑFVÐW]ÓF^Ð`cÕdð 'ùòS #^s   Ä-$K?c                 ó<  •— t         j                  dt        | j                  «      |«       t	        |t
        «      rt        |«      sJ ‚t	        |t
        «      r4|j                  j                  «       �|j                  j                  «       }t	        |t
        «      rX|j                  j                  }t	        |t        j                  «      r‰|   j                  | «       ‰j                  | |f«       y t        j                  |«      }‰j                  | |f«       y )Nztrack_symfloat %s %s)r}   r~   r>   r„  rÇ   r!   rX  rÈ   Úmaybe_as_floatrÑ   rR   r  rÀ   ri  )r  rU  rT  rÉ  r«  s      €€rM   Útrack_symfloatz/ShapeEnv.produce_guards.<locals>.track_symfloat:  sÌ   ø€ Ü�I‰IÐ,¬j¸¿¹Ó.EÀsÔKÜ! #¤xÔ0´KÀÔ4DÐDÐDä˜#œxÔ(¨S¯X©X×-DÑ-DÓ-FÐ-RØ—h‘h×-Ñ-Ó/�ä˜#œxÔ(Ø—H‘H—M‘M�Ü˜a¤§¡Ô.Ø$ QÑ'×.Ñ.¨vÔ6Ø×#Ñ# V¨Q KÕ0ä—K‘K Ó$�Ø×#Ñ# V¨Q KÕ0rN   ©ÚLocalSource)Ú
AttrSourcezSkipping guard %sr  r½   zThe values of r³  z must always be equal.c                 ó*   •— ‰j                  ‰| i«      S rG   )rå  )rH  rÑ   r¼  s    €€rM   râ   z)ShapeEnv.produce_guards.<locals>.<lambda>¼  s&   ø€ Ðhl×huÑhuÐw}ð  @Að  wBó  iC€ rN   z) must always be related to the values of z by r†  Úguardr›   c                 óŠ  •— ‰j                  | j                  «      }|‰v ry ‰j                  |«       	 d}t        ˆˆfd„|j                  D «       «      r‰j
                  j                  |«      }t        ‰‰‰j                  «      j                  |«      }‰
j                  |«       ‰j                  |«       |s¹t        |j                  «      dk(  r t        t        |j                  «      «      }‰|   d   }‰|   }|D ]o  }t        |t        «      r?‰j!                  ||«      }d|› d|› d�}	 ‰|j"                  ‰j%                  |«      |	«       ŒRt        |t&        «      rŒct)        d|› �«      ‚ y y y # t*        $ rE ‰j,                  j/                  d	d
j1                  | j2                  j5                  «       «      «       ‚ w xY w)NFc              3   óB   •K  — | ]  }‰|   D ]  } ‰|«      –— Œ Œ y ­wrG   rZ   )r_  rT  r  r·  r«  s      €€rM   ra  z?ShapeEnv.produce_guards.<locals>.issue_guard.<locals>.<genexpr>Û  s(   øè ø€ Òc¨!ÐO_Ð`aÑObÒcÀV‘v˜f—~Ðc�~Ñcùs   ƒr½   r   rÂ  ú satisfy the generated guard r†  zunrecognized constraint zFailing guard allocated at: 
%sr×   )ÚsimplifyrÑ   ræ  rË  rf   r¬  r©  r­  r,  rÀ   r   r  rd  rü  rÇ   r  r¨  r  r¥  r$  r[  rÄ  r}   rn  r  r¢  r¯  )rÓ  rÑ   Ú
is_trivialÚ
guard_exprr¼  r  ÚconstraintsrH  rÈ  r¡  r.  r·  Úissuedr´  rJ   r¬  rÊ  r«  s             €€€€€€€€rM   Úissue_guardz,ShapeEnv.produce_guards.<locals>.issue_guardÐ  sº  ø€ Ø—=‘= §¡Ó,ˆDð �v‰~Øà�J‰J�tÔðØ"�
ÜÔc¨t×/@Ñ/@ÔcÔcØ!%×!5Ñ!5×!9Ñ!9¸$Ó!?�JÜ.Ð/?ÀÈT×M`ÑM`Óa×iÑiÐjnÓo�
Ø—‘˜ZÔ(Ø×%Ñ% dÔ+ñ "¤c¨$×*;Ñ*;Ó&<ÀÒ&AÜ!¤$ t×'8Ñ'8Ó"9Ó:�FØ-¨fÑ5°aÑ8�FØ"7¸Ñ"?�KØ(ò Q˜Ü% aÔ)?Ô@Ø-1×-XÑ-XÐY_ÐabÓ-c˜Nà"4°^Ð4Dð E?Ø?I¸lÈ!ð!Mð  ñ 8¸¿¹ÀT×EUÑEUÐV\ÓE]Ð_bÕcÜ'¨Ô+BÔCð
 !ä"0Ð3KÈAÈ3Ð1OÓ"PÐPñQð	 'B�zøô( ò Ø—‘× Ñ Ð!CÀRÇWÁWÈUÏ[É[×M_ÑM_ÓMaÓEbÔcØðús   ´D=E4 Å4AGrZ   ©Úaxiomsc              3   ó.   •K  — | ]  } ‰|«      –— Œ y ­wrG   rZ   ©r_  r  r·  s     €rM   ra  z*ShapeEnv.produce_guards.<locals>.<genexpr>  ó   øè ø€ Ò<¨&‘v˜f—~Ñ<ùó   ƒc              3   ó.   •K  — | ]  } ‰|«      –— Œ y ­wrG   rZ   rà  s     €rM   ra  z*ShapeEnv.produce_guards.<locals>.<genexpr>!  rá  râ  r  rÂ  rÖ  znot __math_isnan(z  ú. z  - rk  r  zConstraints violated (rl  z$%s Warning only constraints violatedÚdynamicc              3   ó&   K  — | ]	  }|sŒd –— Œ y­w©r½   NrZ   )r_  ró   s     rM   ra  z*ShapeEnv.produce_guards.<locals>.<genexpr>a  s   è ø€ Ò#N¨!ÊA¤AÑ#Nùs   ‚ŠT)Úreverse)Ú
num_guardsrf   Úsymbol_guard_counts)ÚPopulateValidatorrG   )wr}   r  r“  r   r•  rÊ  r  r²   ræ   r   rÇ   r0  rè   r"   rË   r!   rå   rÁ   r+  r?   r/  r­  r   rc  r„  r(  Úevaluate_exprrR   r  r·   rå  rß  r)  r  r­  r¥  r*  Úextendr�  rÐ  r$   r&   rÑ  rq   rW  rX  r   rŠ  re  rÀ   r:   r  r2  r  rX  rY  r  rÏ  r;  rÈ  r¬  r�  r³  r   rï   rk  r~   r  r©  r,  r¶  rf   rd  rü  rB  r  rA  r±  r#   rž  rÃ  rÑ   r©  r×  ræ  rí   r  r  rš  r0   rË  r8  r™  r   r9  r  r  r  r  r&  r¨  r=   r;   r—  ry  r9   r—  r¯  Úsumr¯  r°  r�  rë  Úfx_tracebackÚpreserve_node_metaru  rµ  Úrunr  )MrJ   r»  r½  r¬  rž  rª  r«  r¬  r  rð   Ú
Tensorliker°  r3  rê   Úcontextr=  r½  Úsrc1Úsrc2Úexpr1Úexpr2Úconcrete_valr5  r6  r8  Úexpr2_Úphantom_symbolrË  rÎ  r  rÐ  rÑ  Úsources_tensors_constraintsr¥  r¦  r§  Úinner_tÚinner_contextÚcurr_tÚconstraint_sizeÚconstraint_strideÚssÚproperty_sourcerù  rÁ  r¡  rÜ  rÓ  rÇ  rv  ÚboundsrÚ  rH  rÙ  rÈ  Ú	warn_msgsÚ
error_msgsrx  r  Úerrrë  rÆ  r_  r  r/  r?   r³  rÑ   r.  rÉ  r·  rÛ  r´  r¼  r¼  rÊ  r«  sM   `` `                                                            @@@@@@@@@@@@@rM   r®  zShapeEnv.produce_guards  sÿ  ÿÿ€ ð@ 	�‰�‰Ð&Ô'ð ×%Ò%Ü/°·±Ó<ˆIØ×Ñ˜YÔ'ä�<Ó ¤C¨£LÒ0ÐZ°D¸¸ÀiÐPWÈyÐXYÐ2ZÓZÐ0Ü—l‘l¤NÐ3ˆ
ò	ð Ð!ð $0öàô 6@ÀÀ:Ô5NÑ.¨qÔ1ØñðˆNñ ô
 �~Ó&¬#¨lÓ*;Ò;Ð;Ð;Ü#,¬S°¸~Ó-NÓ#Oò 9‘�‘<�A�wÜ˜a Ô,Ø‘Ù,JÈ1Ó,M˜ qÒ)ä% a¬&´#´xÄÐ)GÔHÐHÐHÜ)¨'´4Õ8Ð8Ð8ð9÷F 	Nð ˆä&×2Ñ2´4Ó8ÐÜ +× 7Ñ 7¼Ó <ÐØLNÐõ	õ
	]ò ØˆLÜ# GÓ,ò -‘��3Ø+,�˜SŸX™X›ZÒ(ð-õ"ð 0×<Ñ<ò ‘
��dÙ-¨dÓ3±^ÀDÓ5I�u�ð  $×1Ñ1´%·(±(¸5À%Ó2HÓI�Ú#Ü2ØŸ9™9›;˜- s´J¸uÄcÔ4J©5ÐPU×P^ÑP^Ð_c×_nÑ_nÓPoÐ*pØ+ØŸ9™9›;˜- s´J¸uÄcÔ4J¨5Ð*pðróð ð QV×P^ÑP^Ð_c×_nÑ_nÓPoÐ*pðróð ðð "3×!EÑ!Eó ‘��T˜2Ù& sÓ+�ô DNÈdÔTY×T`ÑT`ÔCa�T˜4×.Ñ.¨tÑ4°QÑ7×<Ñ<Ó>Ñ?Ù(¨Ó.°×0@Ñ0@ÀÓ0FÐGñ "��zñ ˜E›�ð  $×1Ñ1´%·(±(¸5À&Ó2IÓJ�Ú#Ü2Ø)¨#¯(©(«*¨Ð5EÙœeŸl™l¨:Ó6Ó7Ð8ð 9!Ø!+ ¨C°·±¸t¿¹Ó0OÐ/Pð Q#Ø#(§>¡>°$·/±/Ó#BÐ"CðEóð ðð( #4×"CÑ"Cò ]�à  Ñ0×7Ñ7¸×8KÑ8KÈNÑ8[Õ\ð]÷C	eò C	eõJ	1ô  #& l°G¸^Ó"Ló 1	tÑˆAˆv�wÜ˜&¤#Ô&Ý<Ù$ VÓ,�Ü˜f¤fÔ-Ð-Ð-ØˆyØÜ˜!œf¤c˜]Ô+Ù˜V QÔ'ØÜ˜A¤¬%Ð0Ô1Ù˜v qÔ)ØÜ˜a Ô,Ð,Ð,Ü,¨QÔ/Ý;ä! 'Ô+BÔCÐCÐCð
 ˜Q × 8Ñ 8¸'×:TÑ:TÐUð/Ð+ð ×/Ñ/Ó1‘��qØ!ò �DÜ% a¨Ó.�GØ$+×$:Ñ$:¸4Ñ$@�MØ/×6Ñ6Ù" 6¨4Ó0ØØ%×6Ñ6Ø%×8Ñ8ð	8õ ñð 17¸¸7×;SÑ;SÐU\×UoÑUoÐ/pÐ.qÐ+àC^ó tÑ?��V˜_Ð.?Ü  Ô(Ü!*¨6¯;©;«=Ó!9ò N™˜˜2Ù*>¸sÀN×DWÑDWÐYZÓ*[˜Ù$ _°b¸/È!Ñ:LÕMñNô "+¨6¯;©;«=Ó!9ò N™˜˜2Ù*>¸sÀN×DWÑDWÐYZÓ*[˜Ù$ _°b¸/È!Ñ:LÕMðNô "+¨6¯=©=«?Ó!;ò P™˜˜2Ù*>¸sÀN×DYÑDYÐ[\Ó*]˜Ù$ _°bÐ:KÈAÑ:NÕOðPñ !Ñ!5°c¸>×;XÑ;XÓ!YÐ[a×[pÑ[pÓ[rÖsòtðK1	tðn ˆÜ-ØØ�O‰OÜÐ%×*Ñ*Ó,Ó-Ø×*Ñ*ó	 
ˆÔò Ø ,ó :p‘�˜Ø×7Ò7à$Ÿk™k›m�GØ $×"7Ñ"7Ñ7Ø×-Ñ-¬e¯h©h°t×7LÑ7LÈWÑ7UÐW[Ó.\Ô]ô ˜t¤U§\¡\Ô2Ø$×(Ñ(¨Ô.ØÐ.¨tÑ4°QÑ7Ò7àñ
 !¤Z°Ð8LÔ%MØ—~’~ØŸ™Ÿ™Ð':¹zÈ&Ó?QÐ>RÐRVÐW[ÐV\Ð<]Ô^Ø á˜&”>Ø×(Ñ(×5Ñ5°f¸dÔCä)Ð*:¸JÈ×H[ÑH[Ó\×dÑdÐeiÓj�Ø—‘¡
¨6Ó 2Ð3°4¸°wÐ?Ô@ä˜vÐ';Ö<ØŸ™ ~×':Ñ':Ó:Û)Ü˜D×-Ñ-Ó.°!Ô3ä!¤$ t×'8Ñ'8Ó"9Ó:�Fä" 4¬¯©Ô6ØÐ 5Ñ5Ø-×6Ñ6°vÐ?OÐPTÑ?UÐVWÑ?XÔYð -¨T×-=Ñ-=¸fÓ-EÐ,FÀcÈ&Ï+É+Ë-ÈÐX]Ø#×/Ñ/Ð0@ÀÑ0FÀqÑ0IÓJÐKÈ3ÐO_Ð`dÑOeÐfgÑOh×OmÑOmÓOoÐNpð q4ð4ð ñ
 4Ð4E×4OÑ4OÐQU×QaÑQaÐbhÓQiÐknÔoô ' t¬U¯\©\Ö:ØÐ"7Ó7Ø-×8Ñ8¸ÐAQÐRXÑAYÐZ[ÑA\ô  _Cö  Dà.¨vÑ6°qÑ9˜à,¨T×-=Ñ-=¸fÓ-EÐ,FÀcÈ&Ï+É+Ë-Èð Y-Ø-1×-=Ñ-=¸cÓ-BÐ,CÀ3ÀsÇxÁxÃzÀlÐRVØ#×/Ñ/°Ó7Ð8¸¸D¿M¹MÈ6ÔSX×S`ÑS`Ðae×aqÑaqÐruÓavÓSwÐJxÓ<yÐ;zÐz{ð}ð ñ
 4Ð4E×4OÑ4OÐQU×QaÑQaÐbhÓQiÐknÖoðu:pôH “ˆð(	œzð (	¨d÷ (	ô (	ðZ !'Ð 2‘f¸¿¹ò 	ˆEØ×*Ñ*¨5¯:©:¸bÐ*ÓAÐMØÙ˜Õð	ð ×/Ñ/×3Ñ3°D¸"Ó=ò 	+ˆBØ×*Ñ*¨2¯7©7¸2Ð*Ó>ÐJØØ—=‘= §¡Ó)ˆDØ× Ñ ×$Ñ$ TÕ*ð		+ð  0×5Ñ5Ó7ó 2	L‰OˆF�GØ×!Ñ!×%Ñ% fÓ-ˆAØˆyØ ×!2Ñ!2Ñ2ØØ×%Ñ% fÑ-�áˆN�7ØˆFØ�w‰w¤§¡˜y¬6¨'Ð2Ñ2ÜÓ<°GÔ<Ô<Ø×(Ñ(×,Ñ,¬U¯X©X°f¸a¿g¹gÓ-FÔGñ # a§g¡g°×1JÑ1JÓ1L×1RÑ1RÒ&RØ—M‘M¤# a§g¡g£,Ô/Ø�M‰M™* W¨Q¡ZÓ0Ô1Ø�w‰wœuŸx™x¬Ð0Ñ0ÜÓ<°GÔ<Ô<Ø×(Ñ(×,Ñ,¬U¯X©X°f¸a¿g¹gÓ-FÔGà—‘œc !§'¡'›lÔ+Ü�6‹{˜Q‹Ø—‘˜VŸ[™[¨Ó0Ô1ð 4°FÑ;�Ø$ò �AÜ! !Ô%;Õ<ð !"§¡ t×'@Ñ'@Ó'BÑ B×LÑLÈQÕOØ%,¨Q¡Z˜Fä#(§9¡9¬U¯X©X°a·g±g¸vÓ-FÌÏÉÐQWÐYZ×Y`ÑY`ÓHaÓ#b˜DÜ):Ð;KÈZÐY]×YlÑYlÓ)m×)uÑ)uÐvzÓ){˜JØ-1×-XÑ-XÐY_ÐabÓ-c˜Nà"4°^Ð4DÐDaÐblÐamÐ nð  ñ 8Ø !§¡Ø $× 0Ñ 0°Ó 8Ø #õðô, ˜f¤d§j¡jÖ1Ø—‘Ð0±¸GÀA¹JÓ1GÐ0HÈÐJÖKðe2	Lñh !ØˆIØˆJÜ›%ˆKØ.Cò 0Ñ*�	˜: sÙØœs 9›~°Ñ1Ð2°"±S³U°GÐ<�CØ×$Ñ$ SÕ)à ¡£ ˜.�CØ×%Ñ% cÔ*Ø—O‘O JÕ/ð0ô �:‹ Ò"Ø"Ÿi™i¬¨{Ó(;Ó<�Ø—i‘i 
Ó+�Ü.Ø,¨[¨Mð :Nà�eðóð ô
 �Y“ !Ò#Ü—	‘	Ð@Ä#ÀiÃ.ÔQäØØðØ—.‘.ðà—,‘,ðô " %›jÜ #Ñ#NÐ/?×/FÑ/FÓ/HÔ#NÓ Nô (.¨d×.GÑ.G×.NÑ.NÓ.PÐZ^Ô'_òô	
ð ×/Ó/ÝIð
 ×4Ñ4×;Ñ;Ó=ò 3�Øò 3�BØ×)Ñ)¨"¯'©'Õ2ñ3ð3ð  ×,Ñ,×2Ñ2Ó4ò C‘��RØ—8‘8¤U§X¡X I´¨wÐ#7Ñ7Ø×)Ñ)¬%¯(©(°2·8±8¸SÓ*AÔBØ—8‘8¤E§H¡H¬fÐ#5Ò5Ø×)Ñ)¬%¯(©(°3¸¿¹Ó*AÕBð	Cô ×0Ñ0Ó2ñ DÙ! $§*¡*¨d¯n©nÓ=×AÑAÔC÷Dð ˆ>Ø×,Ñ,Ô.ØˆùòO÷BDð Dús   Â"ACÁB,ACÁCAC©rž  r  c          	      óä   — ddl m} t        t        |«      «      D �cg c]  }d|› �‘Œ	 }}| j	                  ||D �cg c]
  } ||«      ‘Œ c}||¬«      }|rdj                  |«      S yc c}w c c}w )a  
        Expected to be used with evaluate_guards_expression(). Produces the guards
        for the given placeholders and returns a string expression to be evaluated
        by evaluate_guards_expression given concrete values for the placeholders.
        r   rÏ  r3  r  r³  N)r+  rÐ  r�  r  r®  r  )	rJ   r»  rž  r  rÐ  rê   Ú	arg_namesrÄ   Úproduced_guardss	            rM   Úproduce_guards_expressionz"ShapeEnv.produce_guards_expression…  s|   € õ 	5Ü&+¬C°Ó,=Ó&>Ö? �q˜˜’WÐ?ˆ	Ð?Ø×-Ñ-ØØ%.Ö/ ‰[˜�^Ò/ØØ'ð	 .ó 
ˆñ Ø—<‘< Ó0Ð0Øùò @ùò 0s
   �A(»A-
c                 óœ   — | j                   j                  «       D ��ci c]  \  }}t        |«      |“Œ }}}t        |t        |«      S c c}}w )z?
        To be used by compile_fx to evaluate symexprs
        )rß  rí   r�  Úevalre   )rJ   Úcoder`  rU  rK   s        rM   Úevaluate_symexprzShapeEnv.evaluate_symexpr�  sE   € ð +/¯/©/×*?Ñ*?Ó*A×B¡  3”�A“˜‘ÐBˆÑBÜ�Dœ,¨Ó-Ð-ùó Cs   žAc                 ó    — t        t        |«      «      D �cg c]  }d|› �‘Œ	 }}t        |t        dt	        t        ||«      «      i«      S c c}w )z«
        Expected to be used with produce_guards_expression(). Evaluates an expression
        generated by produce_guards_expression for the given concrete args.
        r3  ÚL)r�  r  r  re   rp  rè   )rJ   r  rK   rê   r	  s        rM   Úevaluate_guards_expressionz#ShapeEnv.evaluate_guards_expression¤  sK   € ô
 ',¬C°«IÓ&6Ö7 �q˜˜’WÐ7ˆ	Ð7Ü�Dœ,¨¬d´3°yÀ$Ó3GÓ.HÐ(IÓJÐJùò 8s   —Ar  c                óR   — | j                  ||¬«      }|r| j                  ||«      S y)z[Generate guards for a graph's placeholder values and evaluate the guards with args
        r  T)r  r  )rJ   r»  rK   r  r  s        rM   r  z!ShapeEnv.evaluate_guards_for_args¬  s2   € ð ×-Ñ-¨lÈ-Ð-ÓXˆÙØ×2Ñ2°4¸Ó>Ð>ØrN   c                 óR  ‡— ‰D �ch c]G  }t        |j                  j                  t        j                  «      sŒ2|j                  j                  ’ŒI c}Šg }| j
                  D ]<  }t        ˆfd„|j                  j                  D «       «      sŒ,|j                  |«       Œ> |S c c}w )z…
        Get a list of guards, but pruned so it only provides guards that
        reference symints from the passed in input
        c              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wrG   rZ   )r_  rT  Úsymintss     €rM   ra  z-ShapeEnv.get_pruned_guards.<locals>.<genexpr>¼  s   øè ø€ Ò= A�1˜”<Ñ=ùs   ƒ)	rÇ   rÈ   rÑ   rR   r  rž  rl  rf   rÀ   )rJ   r  rT  rž  rÅ  s    `   rM   Úget_pruned_guardszShapeEnv.get_pruned_guards´  s{   ø€ ð
 )0ÖY 1´:¸a¿f¹f¿k¹kÌ5Ï<É<Õ3X�1—6‘6—;“;ÒYˆØˆØ—‘ò 	!ˆAÜÓ=¨¯©×)<Ñ)<Ô=Õ=Ø—‘˜aÕ ð	!ð ˆùò Zs
   †3B$ºB$c                 óÞ  ‡— i Šˆfd„}t        ||«      D ]Õ  \  }}|€Œ	t        |t        «      r
 |||«       Œ#t        |t        j                  «      sJ ‚t        |j                  «       «      D ]  \  }} ||j                  |«      |«       Œ t        |j                  «       «      D ]  \  }} ||j                  |«      |«       Œ  ||j                  «       |j                  «       «       Œ× ‰S )a5  
        Given a paired list of placeholders (fake tensors with
        symbolic sizes) and concrete arguments (regular tensors
        with real sizes), returns a dictionary mapping each
        symbol to its real value.  So for example, if you
        have a placeholder with size (s0, s1), binding
        (2, 4) to it will give you {s0: 2, s1: 4}.  This is
        not guaranteed to bind ALL symbols in the ShapeEnv;
        we can't bind a symbol if it doesn't occur in any placeholder,
        and symbols that already have replacements won't get bindings.

        This is a little duplicative with evaluate_guards but
        it's different enough that it seemed cleanest to make
        another copy.  This assumes the guards are already checked,
        though if it's cheap we'll check for shenanigans
        c                 óT  •— t        |t        «      r—|j                  j                  }t        |t        j
                  «      r"|‰v r‰|   | k(  sJ ‰|   › d| › �«       ‚| ‰|<   y y t        | t        j
                  «      r)| ‰v r‰|    |  k(  sJ ‰|    › d|  › �«       ‚y |  ‰| <   y y y )NrÝ   )rÇ   r"   rÈ   rÑ   rR   r  )rI  rU  rT  rñ   s      €rM   Úbind_symintz*ShapeEnv.bind_symbols.<locals>.bind_symintÓ  sÃ   ø€ Ü˜#œvÔ&Ø—H‘H—M‘M�ä˜a¤§¡Ô.Ø˜H‘}Ø'¨™{¨cÒ1ÐL°h¸q±k°]À$ÀsÀeÐ3LÓLÐ1à&)˜ šð  2ô    ¤E§L¡LÔ1Ø�r˜X‘~Ø'¨¨™|°¨tÒ3ÐP¸À!À¹°~ÀTÈ3È$ÈÐ5PÓPÑ3à(+ t˜ ! šð	 2ð 'rN   )	rè   rÇ   r"   r²   ræ   r0  r  r  r  )	rJ   r»  rK   r  r3  rI  rê   rT  rñ   s	           @rM   r  zShapeEnv.bind_symbolsÀ  sã   ø€ ð" -/ˆô	,ô ˜,¨Ó-ò 	B‰FˆAˆsØˆyØÜ˜!œVÔ$Ù˜C Ô#ØÜ˜a¤§¡Ô.Ð.Ð.Ü! !§&¡&£(Ó+ò ,‘��1Ù˜CŸH™H Q›K¨Õ+ð,ä! !§(¡(£*Ó-ò .‘��1Ù˜CŸJ™J q›M¨1Õ-ð.á˜×*Ñ*Ó,¨a×.>Ñ.>Ó.@ÕAð	Bð ˆrN   c                 ó®   — | j                   D �cg c];  }| j                  |j                  d¬«      �Œ!| j                  |j                  «      ‘Œ= c}S c c}w )zSReturns a list of guard expressions that aren't statically known (i.e. not trivial)rZ   rÝ  )rž  rÃ  rÑ   r×  )rJ   rÓ  s     rM   Úget_nontrivial_guardszShapeEnv.get_nontrivial_guardsñ  sT   € à7;·{±{ö  B¨eÀd×FaÑFaÐbg×blÑblÐuwÐFaÓFxñ  GA�—‘˜eŸj™jÕ)ò  Bð  	Bùò  Bs
   �"A²Ac                 óX   ‡‡— ˆfd„Šdj                  ˆfd„| j                  D «       «      S )zQFormat this shape env's guard expressions with optional traceback info if verbosec                 ó\   •— ‰syddj                  d„ | j                  «       D «       «      › �S )Nr×   z
   Guarded at:
c              3   ó&   K  — | ]	  }d |z   –— Œ y­w)z   NrZ   )r_  Úls     rM   ra  z<ShapeEnv.format_guards.<locals>.format_tb.<locals>.<genexpr>ú  s   è ø€ Ò/O¸a°¸µ	Ñ/Oùs   ‚)r  r¯  )ÚtbÚverboses    €rM   Ú	format_tbz)ShapeEnv.format_guards.<locals>.format_tb÷  s,   ø€ ÙØØ'¨¯©Ñ/OÀ2Ç9Á9Ã;Ô/OÓ(OÐ'PÐQÐQrN   r  c              3   ó`   •K  — | ]%  }d |j                   ›  ‰|j                  «      › �–— Œ' y­w)z - N)rÑ   r¢  )r_  rÓ  r#  s     €rM   ra  z)ShapeEnv.format_guards.<locals>.<genexpr>ü  s*   øè ø€ Ò]È˜3˜uŸz™z˜l©9°U·[±[Ó+AÐ*BÔCÑ]ùs   ƒ+.)r  rž  )rJ   r"  r#  s    `@rM   Úformat_guardszShapeEnv.format_guardsõ  s'   ù€ ô	Rð
 �y‰yÓ]ÐQU×Q\ÑQ\Ô]Ó]Ð]rN   Úsize_obliviousc                 ó(  — |j                   D �ci c]  }|| j                  j                  |d«      “Œ! }}|rL| j                  |j	                  «       z  D ],  }||   €Œ	t        dt        «      ||<   ||   j                  rŒ,J ‚ t        ||«      S c c}w )zPGiven a sympy expression, computes a ValueRanges bound for what values it can beNrù   )	rf   r  rï   r£  r;  r3   r0   rˆ  r1   )rJ   rÑ   r&  rH  r  s        rM   r1   zShapeEnv.bound_sympyþ  s�   € àCG×CTÑCTÖU¸a˜˜4×,Ñ,×0Ñ0°°DÓ9Ñ9ÐUˆÐUÙð —^‘^ l×&7Ñ&7Ó&9Ñ9ò 2�Ø ‘?Ñ.ô '2°!´VÓ&<�L ‘OØ'¨™?×1Ó1Ð1Ð1ð2ô ˜4 Ó.Ð.ùò Vs   �$Br	  úsympy.SymbolÚcompute_hintc                 ó&  ‡ — |€"d„ ‰ j                   j                  «       D «       }nˆ fd„|D «       }d„ ‰ j                  D «       }t        j                  ||«      }|rˆ fd„|D «       }t        t        j                  |«      j                  «       «      S )zî
        Given the symbols in an expression, it returns all the runtime asserts that have those symbols
        concatenated with all the guards.
        If symbols is None, it returns all the runtime asserts (and all the guards)
        c              3   óB   K  — | ]  }|D ]  }|j                   –— Œ Œ y ­wrG   rÙ   )r_  Úrsrv  s      rM   ra  z&ShapeEnv.get_axioms.<locals>.<genexpr>  s.   è ø€ ò ,Ø#%Ø(*ò,à#$ð  !Ÿv�vð ,˜vñ ,ùrK  c              3   ó”   •K  — | ]?  }|‰j                   vr/‰j                  j                  |d «      D ]  }|j                  –— Œ ŒA y­w)rZ   N)rß  r©  rï   rÑ   )r_  rT  rv  rJ   s      €rM   ra  z&ShapeEnv.get_axioms.<locals>.<genexpr>  sQ   øè ø€ ò RØ#$°1¸D¿O¹OÑ3KØ(,×(EÑ(E×(IÑ(IÈ!ÈRÓ(PòRà#$ð  !Ÿv�vð R˜vñ Rùs   ƒAAc              3   ó4   K  — | ]  }|j                   –— Œ y ­wrG   rÙ   )r_  rÅ  s     rM   ra  z&ShapeEnv.get_axioms.<locals>.<genexpr>  s   è ø€ Ò.˜Q�!—&•&Ñ.ùrb  c              3   óf   •K  — | ](  }t        |j                  ‰j                  «      «      –— Œ* y ­wrG   )rc   rå  rß  )r_  rÄ   rJ   s     €rM   ra  z&ShapeEnv.get_axioms.<locals>.<genexpr>   s$   øè ø€ ÒZÈaÔ,¨Q¯Z©Z¸¿¹Ó-H×IÑZùs   ƒ.1)	r©  r¯  rž  r¥  Úchainr:  rp  Úfromkeysr;  )rJ   r	  r)  Úruntime_assertsrž  rÞ  s   `     rM   Ú
get_axiomszShapeEnv.get_axioms  s„   ø€ ð ˆ?ñ,Ø)-×)FÑ)F×)MÑ)MÓ)Oô,‰OóRØ(/ôRˆOñ / $§+¡+Ô.ˆÜ—‘ ¨Ó9ˆÙÛZÐSYÔZˆFÜ”T—]‘] 6Ó*×/Ñ/Ó1Ó2Ð2rN   r`  )r`  zsympy.logic.boolalg.BooleanAtomc                 óš  ‡— i Šˆfd„} ||«       t        |t        j                  «      rb |t        j                  |j                  |j
                  «      «        |t        j                  |j                  |j
                  «      «       �n't        |t        j                  «      rÀ |t        j                  |j                  |j
                  «      «        |t        j                  |j                  |j
                  «      «       |j                  j                  r—|j
                  j                  r� |t        j                  |j                  |j
                  dz
  «      «       nMt        |t        j                  «      r3 |t        j                  |j                  |j
                  dz   «      «       t        ‰j                  «       «      S )zI Given a expression, it returns a list of predicates that follow from it c                 ó   •— t        | «      } t        | t        j                  t        j                  f«      �rt        | t        j                  «      rt        j                  nt        j                  }t        j
                  ‰ t        | «      | j                  | j                  «      <   t        j
                  ‰ t        | «      | j                  | j                  «      <   t        j                  ‰ || j                  | j                  «      <   t        j                  ‰ || j                  | j                  «      <   y t        j
                  ‰| <   t        j                  ‰t        t        j                  | «      «      <   y rG   )rc   rÇ   rR   r  r)  rú  rÊ   r  r	  rû  r(  )rÑ   r>  Úequivs     €rM   Úadd_exprz+ShapeEnv.get_implications.<locals>.add_expr)  sí   ø€ Ü)¨$Ó/ˆDÜ˜$¤§¡¬5¯8©8Ð 4Õ5ô (2°$¼¿¹Ô'Aœ5Ÿ8š8ÄuÇxÁx�ä8=¿
¹
��j”d˜4“j §¡¨4¯8©8Ó4Ñ5Ü8=¿
¹
��j”d˜4“j §¡¨4¯8©8Ó4Ñ5Ü6;·k±k�‘h˜tŸx™x¨¯©Ó2Ñ3Ü6;·k±k�‘h˜tŸx™x¨¯©Ó2Ò3ô $Ÿj™j��d‘ÜAFÇÁ�Ô,¬U¯Y©Y°t«_Ó=Ò>rN   r½   )rÇ   rR   r  r9  r  r	  r8  r7  r)  Ú
is_integerr:  rí   )rJ   r`  r7  r6  s      @rM   Úget_implicationszShapeEnv.get_implications#  s  ø€ ð ˆô	Mñ" 	�Œä�aœŸ™Ô"Ù”U—X‘X˜aŸe™e Q§U¡UÓ+Ô,Ù”U—X‘X˜aŸe™e Q§U¡UÓ+Ö,Ü˜œ5Ÿ8™8Ô$Ù”U—X‘X˜aŸe™e Q§U¡UÓ+Ô,Ù”U—X‘X˜aŸe™e Q§U¡UÓ+Ô,Ø�u‰u×Ò A§E¡E×$4Ò$4ÙœŸ™ !§%¡%¨¯©°©Ó3Õ4Ü˜œ5Ÿ8™8Ô$Ù”U—X‘X˜aŸe™e Q§U¡U¨Q¡YÓ/Ô0Ü�U—[‘[“]Ó#Ð#rN   )Úunbacked_onlyr)  r&  rÞ  r  r:  rÞ  r  zOptional[sympy.Expr]c                óv  — |r|rJ ‚|€| j                   }nt        |«      }| j                  |«      }|r|j                  | j                  «      }t        |«      }t        |j                  «      }|€| j                  ||¬«      }i }	|D ]Q  }
|
j                  j                  |j                  «      sŒ)|	j                  t        | j                  |
«      «      «       ŒS |j                  |	«      }t        |j                  «      }i }i }t        |«      D �]  \  }}t        | j                  j                  |d«      t        «      rŒ2||   }|rL|| j                   v r>t#        d|j$                  «      }t'        d|j(                  «      }||k  rt+        ||«      }n|j$                  }|t,         u s|r|| j                  v s|j.                  s|||<   Œ¼t1        j2                  d|› �dd¬«      }t5        |dz
  «      }||z   ||<   t7        j8                  || «      ||<   �Œ	 	 |j                  |«      }t        tC        |«      «      }|jD                  r|S 	 tG        ||«      }|jI                  «       r|j$                  S |r|S dS # t:        $ r1 t<        j?                  d	||«       | j@                  d
xx   dz  cc<   Y yw xY w)a-  
        Tries to evaluate expr without introducing guards

        If unbacked_only == True, then we only do substitutions on
        unbacked SymInts (leaving regular hinted integers alone).  This could
        result in an expression that still contains backed SymInts, which you
        could then potentially guard on.

        Use compute_hint == True if you are trying to compute a non-binding
        hint for the particular hint values of backed SymInts, e.g., if
        s0 happens to be 3 this run, compute_hint will subsitute s0 with 3.
        N©r)  rù   l          Úevaluate_static_shape_Tr‘  r½   z(RecursionError in sympy.xreplace(%s, %s)Úsympy_recursion_error)%r  rp  r×  rå  rß  rc   r:  rf   r3  r  rž  r9  r0  rÇ   rï   r6   r£  râ  r  rá  r   r3   r0   rˆ  rR   r  rË   r2   ræ  rm  r}   rn  r¯  ro  rk  r1   Úis_singleton)rJ   rÑ   r:  r)  r&  rÞ  r  Ú
var_rangesr	  Úsubstr`  Únew_shape_envÚnew_range_envr•  rò   r  r  r   rT  ÚoffsetrT  rg  s                         rM   rÃ  zShapeEnv._maybe_evaluate_staticH  sª  € ñ(  ¡vÐ-Ð-àÐØ×*Ñ*‰Jä˜lÓ+ˆJà�}‰}˜TÓ"ˆáØ—=‘= §¡Ó1ˆDä% dÓ+ˆô ˜×)Ñ)Ó*ˆØˆ>Ø—_‘_ W¸<�_ÓHˆFØˆØò 	=ˆAØ�~‰~×&Ñ& t×'8Ñ'8Õ9Ø—‘œT $×"7Ñ"7¸Ó":Ó;Õ<ð	=ð �}‰}˜UÓ#ˆä˜×)Ñ)Ó*ˆð ˆØˆÜ Ó(ó 9	H‰FˆC�Ü˜$Ÿ/™/×-Ñ-¨a°Ó6¼ÔEð Ø˜A‘ˆBÙ ! t§~¡~Ñ"5Ü˜A˜rŸx™xÓ(�ô ˜G R§X¡XÓ.�ð ˜E’>Ü$ U¨EÓ2‘BàŸ™�ð
 œ&˜Ñ Ù 1¨¯©Ñ#7Ø—I’Ià#%�˜aÑ Øô —‘Ð5°c°UÐ;ÀdÐTXÔYˆAô ˜ ™“^ˆFØ  6™zˆM˜!ÑÜ6×:Ñ:¸2À¸wÓGˆM˜!Óðs9	Hðv	Ø—}‘} ]Ó3ˆHô *¬+°hÓ*?Ó@ˆØ×ÒØˆOð
		ô ˜( MÓ2ˆØ×ÑÔØ—9‘9Ðá(ˆxÐ2¨dÐ2øô? ò 	Ü�K‰KÐBÀDÈ-ÔXØ�L‰LÐ0Ó1°QÑ6Ó1Ùð	ús   ÈI> É>7J8Ê7J8c           
      óÂ   — |j                   D �ci c],  }|| j                  t        t        j                  |«      «      “Œ. }}t        |j                  |«      «      S c c}w )zIApply symbol replacements to any symbols in the given expression
        )rf   r1  r	   rR   r  ro  rå  )rJ   rÑ   rT  r¡  s       rM   rî  zShapeEnv.replaceØ  sR   € ð GK×FWÑFWÖXÀ˜˜4Ÿ:™:¤d¬5¯<©<¸Ó&;Ó<Ñ<ÐXˆÐXÜ˜4Ÿ=™=¨Ó6Ó7Ð7ùò Ys   �1Ac                 óÆ   — t        «       }| j                  D ]1  }| j                  |«      }|j                  rŒ!|j	                  |«       Œ3 || _        | j                  «        y rG   )rc  r¢  rî  rk  ræ  r&  )rJ   Únew_divisiblerò   Úress       rM   Ú_update_divisiblezShapeEnv._update_divisibleß  sS   € ä›ˆØ—‘ò 	%ˆAØ—,‘,˜q“/ˆCØ—=“=Ø×!Ñ! !Õ$ð	%ð
 'ˆŒØ×$Ñ$Õ&rN   c                 ó  — | j                  |«      }|j                  t        «      rÒ| j                  «        i }|j	                  t        «      D ]Œ  }|j
                  \  }}t        |t        «      sŒ#|j
                  \  }}| j                  t        ||«      «      | j                  v sŒZ||k(  sŒ`| j                  t        ||«      «      | j                  v sŒˆ|||<   ŒŽ |j                  |«      }t        |«      }|j                  t        «      �rvi }|j	                  t        j                  «      }|j	                  t        j                  «      j                  |j	                  t        j                  «      «      }	|j	                  t        «      D ]H  }
|
j
                  \  }}| j                  t        ||«      «      | j                  v sŒ:t!        ||«      ||
<   ŒJ |j                  |«      }t        |«      }|j	                  t        j                  «      }|j	                  t        j                  «      j                  |j	                  t        j                  «      «      }|j#                  |«      r|j#                  |	«      r|}|S )zJUse known constraints and replacements to simplify the given expr
        )rî  rL  r(   rI  rM  rK   rÇ   r)   r¢  rå  ro  rR   ÚPowÚRationalrò  rÔ   r,   r  )rJ   rÑ   Údiv_replacementsÚatomrè  r•  Úbase1Údivisor1ÚpowsÚ	rationalsÚfdrT  Únew_powsÚnew_rationalss                 rM   r×  zShapeEnv.simplifyê  s÷  € ð �|‰|˜DÓ!ˆð �8‰8”HÔØ×"Ñ"Ô$Ø!ÐØŸ
™
¤8Ó,ò :�Ø $§	¡	‘��gÜ˜g¤xÕ0Ø&-§l¡l‘O�E˜8Ø—|‘|¤C¨¨gÓ$6Ó7¸4¿>¹>ÒIØ  E›M¨d¯l©l¼3¸uÀhÓ;OÓ.PÐTX×TbÑTbÒ.bØ19Ð(¨Ò.ð:ð —=‘=Ð!1Ó2ˆDÜ˜tÓ$ˆDØ�8‰8”HÕØ!ÐØ—:‘:œeŸi™iÓ(ˆDØŸ
™
¤5§>¡>Ó2×=Ñ=¸d¿j¹jÌÏÉÓ>WÓXˆIØ—j‘j¤Ó*ò C�Ø "§¡‘��gØ—<‘<¤ D¨'Ó 2Ó3°t·~±~ÒEÜ+3°D¸'Ó+BÐ$ RÒ(ðCð —}‘}Ð%5Ó6ˆHÜ" 8Ó,ˆHØ—~‘~¤e§i¡iÓ0ˆHØ$ŸN™N¬5¯>©>Ó:×EÑEÀhÇnÁnÔUZ×UbÑUbÓFcÓdˆMà× Ñ  Ô&¨=×+AÑ+AÀ)Ô+LØ�ØˆrN   ri  ©Ú
allow_nonec                óú  ‡‡— t        ‰«      j                  | j                  «      }|j                  sÈddlm} t        ||«      ry| j                  |d¬«      }|�|S |ry| j                  r}|j                  | j                  «      Š‰j                  sVt        j                  d‰‰«       t        dˆˆfd„¬	«       | j                  t        j                  |‰«      d
|› d‰› �«       ‰S | j!                  |‰«      ‚|S )a  
        Gets a size hint for a given expression from the underlying shapes we had.
        Does not introduce a guard, so only use this when you can guarantee that
        your code is still valid for arbitrary shapes (such as optimization decisions)
        r   r5   NTr<  z*propagate_real_tensors size_hint(%s) -> %sÚpropagate_real_tensorsc                  óž   •— t        ‰ «      t        ‰«      t        j                  t        j                  d¬«      j                  «       «      dœS ©Nr½   r  )rÑ   r  r¢  ©r®  r   Úfrom_tracebackr8   r�  Úsummary)rÑ   Úunsound_exprs   €€rM   râ   z$ShapeEnv.size_hint.<locals>.<lambda>,  s=   ø€ Ü$(¨£JÜ&*¨<Ó&8Ü%/×%>Ñ%>Ô?P×?XÑ?XÐ^_Ô?`×?hÑ?hÓ?jÓ%kñ-€ rN   ©Úmetadata_fnúpropagate_real_tensors: r  )ro  rå  rß  rk  Ú torch.utils._sympy.singleton_intr6   rÇ   rÃ  rŸ  rf   r}   rn  r   Údefer_runtime_assertrR   r  Ú_make_data_dependent_error)rJ   rÑ   rW  Úresult_exprr6   rv  r_  s    `    @rM   Ú	size_hintzShapeEnv.size_hint  sõ   ù€ ô " $Ó'×0Ñ0°·±ÓAˆØ×$Ò$åEä˜+ |Ô4ØØ×+Ñ+¨KÀdÐ+ÓKˆAØˆ}Ø�ÙØà×'Ò'Ø*×3Ñ3°D×4LÑ4LÓM�Ø#×0Ò0Ü—K‘KÐ LÈdÐT`ÔaÜ$Ø0ô%õð ×-Ñ-ÜŸ™ ¨lÓ;Ø2°;°-¸tÀLÀ>ÐRôð (Ð'à×1Ñ1°+¸tÓDÐDØÐrN   c                 óŒ   — t        |«      j                  | j                  «      }|j                  xs | j	                  |«      d uS rG   )ro  rå  rß  rk  rÃ  )rJ   rÑ   rf  s      rM   rÎ   zShapeEnv.has_hint<  s=   € ä! $Ó'×0Ñ0°·±ÓAˆØ×$Ñ$Ò\¨×(CÑ(CÀKÓ(PÐX\Ð(\Ð\rN   ©Úsize_oblivious_resultrj  c                ó¬  — g }|j                   D ]k  }dj                  | j                  |   j                  «       «      }| j                  j                  d||«       || j                  v sŒ[|j                  |«       Œm d}|�d|› d�}| j                  d«      \  }}	}
|j                  rd}nd}|› d|› d	|› d
dj                  t        t        |«      «      xs d› d|› ddj                  t        j                  j                  |g«      j                  «       «      › ddj                  t        t        |j                   «      «      › d�|
z   }t        ||«      S )Nr×   z-Data dependent variable '%s' allocated at:
%szNATTENTION: guard_size_oblivious would fix the error, evaluating expression to zb.
Maybe you need to add guard_size_oblivious to framework code, see doc below for more guidance.

TzDCould not extract specialized integer from data-dependent expressionz,Could not guard on data-dependent expressionrW  z (unhinted: z).  (Size-like symbols: rk  Únonez)

zAPotential framework code culprit (scroll up for full backtrace):
z’
For more information, run with TORCH_LOGS="dynamic"
For extended logs when we create symbols, also add TORCHDYNAMO_EXTENDED_DEBUG_CREATE_SYMBOL="rs  zÖ"
If you suspect the guard was triggered from C++, add TORCHDYNAMO_EXTENDED_DEBUG_CPP=1
For more debugging help, see https://docs.google.com/document/d/1HSuTTVvYH1pTew89Rtpeu84Ht3nQEFTYhAX3Ypa_xJs/edit?usp=sharing
)rf   r  r   r¯  r}   r~   r£  rÀ   rw  r8  r5  r�  Ú	tracebackÚStackSummaryÚ	from_listrD   )rJ   rÑ   Úunhinted_exprrj  Úsize_like_symbolsrT  Ú
stacktraceÚsize_oblivious_result_msgry  rz  r{  Údescr¡  s                rM   re  z#ShapeEnv._make_data_dependent_errorA  s}  € ð ÐØ×"Ñ"ò 	,ˆAØŸ™ ×!2Ñ!2°1Ñ!5×!<Ñ!<Ó!>Ó?ˆJØ�H‰H�N‰NÐKÈQÐPZÔ[Ø�D—N‘NÒ"Ø!×(Ñ(¨Õ+ð		,ð
 %'Ð!Ø Ð,à`ÐavÐ`wð xuð uð &ð 7;×6MÑ6MÈdÓ6SÑ3ˆ�.Ð"3Ø�?Š?ØY‰DàAˆDàˆf�A�d�V˜<¨ ð 7#Ø#'§9¡9¬S´Ð6GÓ-HÓ#IÒ#SÈVÐ"TÐTYØ(Ð)ØPØ�w‰w”y×-Ñ-×7Ñ7¸¸
ÓC×JÑJÓLÓMÐNð O:ð ;>¿(¹(Ä3ÄsÈD×L]ÑL]ÓC^Ó:_Ð9`ð aqð
qð ñð 	ô  +¨4°Ó5Ð5rN   c                 ó  — |j                   |j                  }}|dk  r|| j                  v rd}|| j                  vr9t	        ||«      }| j
                  j                  d||«       || j                  |<   nO| j                  |   }|t	        ||«      z  }||k7  r,|| j                  |<   | j
                  j                  d||«       | j                  j                  |«      x}� | j                  |   }||v sJ |› d|› �«       ‚y y )Nrù   z"_update_var_to_range %s = %s (new)z%_update_var_to_range %s = %s (update)z not in )	r  r   r£  r  r3   r}   r~   rß  rï   )	rJ   r¼  r  r  r   rv  rá   rà   ró   s	            rM   Ú_update_var_to_rangezShapeEnv._update_var_to_rangeg  s  € Ø—x‘x §¡ˆuˆð �1Š9˜ 4§>¡>Ñ1ØˆEð ˜×*Ñ*Ñ*Ü˜E 5Ó)ˆAØ�H‰H�N‰NÐ?ÀÈÔKØ()ˆD×Ñ˜fÒ%à×#Ñ# FÑ+ˆCØœ E¨5Ó1Ñ1ˆCØ�cŠzØ,/�×!Ñ! &Ñ)Ø—‘—‘ÐFÈÐPSÔTà—‘×$Ñ$ VÓ,Ð,ˆAÐ9Ø×!Ñ! &Ñ)ˆAØ˜‘6Ð,˜a˜S ¨¨Ð,Ó,‘6ð :rN   Útgtr¡  c                 ó´  ‡ ‡‡‡‡— ‰‰ j                   j                  ‰d«      k(  ryt        ‰t        j                  «      sJ ‚‰ j
                  rt        ‰«      syd}‰‰ j                  v �rW‰ j                  ‰   }‰ j                  ‰«      }‰ j                  ‰|«       |j                  |«      sõt        ‰j                  «      dk(  rÝt        t        ‰j                  «      «      }t        t        j                   ‰‰«      |d¬«      }|�›‰ j"                  j%                  d|‰‰|«       ‰ j                  |d   «      }t'        t)        |j*                  «      t-        |j.                  «      «      }	‰ j                  ||	«       ‰ j                  ‰«      }|j                  |«      sJ ‚‰‰ j0                  v r6t        ‰t        j                  «      r‰ j0                  j3                  ‰«       nCt        ‰t        j                  «      r)‰‰ j0                  v r‰ j0                  j3                  ‰«       |j                  |«      s!‰ j"                  j%                  d‰‰‰||«       y‰‰ j0                  v rX‰ j                  ‰d¬«      }
‰ j                  ‰d¬«      }|
j                  |«      s!‰ j"                  j%                  d	‰‰‰|
|«       yt        ‰t        j4                  t        j6                  f«      r�t9        j:                  «       Št=        d
ˆˆˆ ˆˆfd„¬«       t>        j@                  rX‰ j"                  jC                  d‰ jD                  ‰   d   jG                  «       ‰«       ‰ j"                  j%                  dd¬«       t"        jI                  d‰‰‰|«       ‰‰ j                   ‰<   ‰ jK                  «        ‰ jM                  t        j                   ‰‰«      «       y)zw
        Adds or updates a replacement for a symbol.
        Use this instead of `self.replacements[a] = tgt`.
        Nr½   F©Úfloordiv_inequalityz2set_replacement: solve for %s in %s == %s gives %sz:skipped set_replacement %s = %s (%s) [%s not subset of %s]T©r&  zVskipped set_replacement %s = %s (%s) [%s not subset of %s (size-oblivious conditions)]Úsymbolic_shape_specializationc            	      óL  •— t        ‰«      ‰j                  j                  ‰g «      D � cg c]  } | j                  «       ‘Œ c} t        ‰«      ‰t	        j
                  t        j                  d¬«      j                  «       «      ‰rt	        j
                  ‰«      dœS d dœS c c} w )Nr½   r  )r¼  r½  rÂ  Úreasonr¢  Ú
user_stack)	r®  r­  rï   r„  r   r]  r8   r�  r^  )rT  rÄ   r¡  rJ   rw  Úuser_tbs    €€€€€rM   râ   z+ShapeEnv._set_replacement.<locals>.<lambda>ì  s‡   ø€ Ü" 1›gØ26×2EÑ2E×2IÑ2IÈ!ÈRÓ2PÖQ¨Q §¡¥ÒQÜ! #›YØ!Ü'×6Ñ6Ô7H×7PÑ7PÐVWÔ7X×7`Ñ7`Ó7bÓcÙHO¤*×";Ñ";¸GÓ"Dñ%€ ð VZñ%€ ùâQs   ªB!r`  zSpecializing %s to %sr   ÚSPECIALIZATIONrt  zset_replacement %s = %s (%s) %s)'r¡  rï   rÇ   rR   r  r‡  rJ  r  r1   rv  r  r  rf   rd  rü  r/   r  r}   r~   r3   r.   r  r-   r   r£  ræ  rÔ   ri  r%   Úextract_stackr   r›  Úprint_specializationsrn  r­  r„  r  r&  r   )rJ   rÄ   rw  r¡  Ú	tgt_boundÚ	src_boundr~  rv  Úrat_b_boundÚb_boundÚtgt_bound_soÚsrc_bound_sor€  s   ````        @rM   rÜ  zShapeEnv._set_replacement„  sA  ü€ ð �$×#Ñ#×'Ñ'¨¨4Ó0Ò0Øô ˜!œUŸ\™\Ô*Ð*Ð*à×7Ò7Ô@YÐZ]Ô@^Øð ˆ	Ø�×!Ñ!Ò!Ø×)Ñ)¨!Ñ,ˆIð ×(Ñ(¨Ó-ˆIØ×%Ñ% a¨Ô3ð ×%Ñ% iÔ0´S¸×9IÑ9IÓ5JÈaÒ5OÜœ˜c×.Ñ.Ó/Ó0�äœeŸh™h q¨#Ó.°ÀuÔM�Ø�=Ø—H‘H—N‘NÐ#WÐYZÐ\]Ð_bÐdeÔfð #'×"2Ñ"2°1°Q±4Ó"8�KÜ)¬)°K×4EÑ4EÓ*FÌ
ÐS^×SdÑSdÓHeÓf�GØ×-Ñ-¨a°Ô9Ø $× 0Ñ 0°Ó 5�IØ$×-Ñ-¨iÔ8Ð8Ð8ð( �D—N‘NÑ"¤z°#´u·|±|Ô'DØ—‘×"Ñ" 3Õ'Ü˜C¤§¡Ô.°3¸$¿.¹.Ñ3HØ—‘×"Ñ" 1Ô%ð ×%Ñ% iÔ0Ø—‘—‘Ð[Ð]^Ð`cÐehÐjsÐu~ÔØØ�d—n‘nÑ$Ø#×/Ñ/°ÀDÐ/ÓI�Ø#×/Ñ/°À$Ð/ÓG�Ø#×,Ñ,¨\Ô:Ø—H‘H—N‘Nð $WØXYÐ[^Ð`cÐeqÐsôAàä�cœEŸM™M¬5¯;©;Ð7Ô8ô %×2Ñ2Ó4ˆGÜØ/÷õ
ô ×+Ò+Ø—‘× Ñ Ð!8¸$×:MÑ:MÈaÑ:PÐQRÑ:S×:XÑ:XÓ:ZÐ\_Ô`Ø—‘—‘Ð/¸D�ÔAÜ�‰Ð2°A°s¸CÀÔKØ"ˆ×Ñ˜!ÑØ×$Ñ$Ô&ð 	×ÑœeŸh™h q¨#Ó.Õ/rN   c                 óZ   — | j                   j                  |«       | j                  «        y rG   )r¢  ræ  r&  r¦  s     rM   Ú_add_divisiblezShapeEnv._add_divisible  s    € Ø�‰×Ñ˜4Ô Ø×$Ñ$Õ&rN   c                 ó&  — || j                   vr|S | j                   |   }|j                  D �ci c]  }|| j                  |«      “Œ }}| j                   |   j                  |«      \  }}|r| j	                  ||d«       | j                   |   S c c}w )z²
        Implements a DSU-like algorithm to find the variable that represents a
        Also handles transitive non-identity replacements.

        a: b + c
        c: d
        Úfind)r¡  rf   r1  Ú	_xreplacerÜ  )rJ   rÄ   rH  rT  Úcur_replaceÚreplacedÚchangeds          rM   r1  zShapeEnv._find  s™   € ð �D×%Ñ%Ñ%ØˆHØ×Ñ Ñ"ˆØ14×1AÑ1AÖB¨A�q˜$Ÿ*™* Q›-Ñ'ÐBˆÐBØ ×-Ñ-¨aÑ0×:Ñ:¸;ÓGÑˆ�'ÙØ×!Ñ! ! X¨vÔ6Ø× Ñ  Ñ#Ð#ùò	 Cs   ®Bc           	      ó^  ‡ — t        |t        j                  «      sJ ‚t        |t        j                  «      ryt	        |j
                  «      }t        |«      dkD  s
J d|› �«       ‚t        |«      dkD  ryˆ fd„}t        ||d¬«      }|j                  }|j                  }‰ j                  |«       t        |t        j                  «      sy|j                  t        «      �sO	 |j                  t        «      j!                  |j                  t        «      «      }t        |«      dkD  rt#        d„ |D «       «      rt$        ‚d	„ } |||«      r#‰ j'                  |‰ j)                  |«      d
«       nÂ |||«      r#‰ j'                  |‰ j)                  |«      d«       n–t+        ||d   d¬«      }|�ƒt-        d„ t        j.                  |d   «      D «       «      r[‰ j)                  |d   «      }	t        t1        |	«      «      dk(  }
|
r.‰ j'                  t3        t        j4                  |d   «      |	d«       |j                  t        «      �rÈt7        t9        |j                  t        «      «      «      }	 t+        ||d¬«      }|��Ž|d   dk(  �r…‰ j;                  |«       |j<                  \  }}t        |t        j>                  «      �rJt        |t        j@                  «      �r/t        |j<                  «      dk(  �r|j<                  \  }}t        |t        j>                  «      rít        |t        j4                  «      rÓ‰ jC                  |«      rÂ|t        jD                  ||«      z  }‰ jG                  «       jH                  jJ                  }‰ jM                  |tO        jP                  ‰ jR                  |   tU        jV                  |«      «      «       |‰ jX                  v r‰ jX                  j[                  |«       ‰ j'                  |||z  d«       yy# t$        $ r Y �Œëw xY w# t$        $ r Y yw xY w)zŠ
        The relational guard is guarded to be true.  Use this information to
        simplify shapes (i.e. a == b or a % 5 == 0)
        Nr   z3The expression should not be static by this point: é   c                 óÜ   •— | ‰j                   v xr t        d„ ‰j                   |    D «       «      }‰j                  | d¬«      xs t        j                  }| j
                  }|rd||fS d||fS )Nc              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wrG   )r›  ©r_  rT  s     rM   ra  zHShapeEnv._maybe_guard_rel.<locals>._smart_symbol_sort.<locals>.<genexpr>3  s   è ø€ Ò0bÀa°·±×1AÑ0bùs   ‚TrV  r½   r   )r­  rl  rg  r¢   rŠ   r„  )rH  Úhas_only_ephemeral_sourcesr  r„  rJ   s       €rM   Ú_smart_symbol_sortz5ShapeEnv._maybe_guard_rel.<locals>._smart_symbol_sort1  ss   ø€ à�T×(Ñ(Ð(Òb¬SÑ0bÈ4×K^ÑK^Ð_`ÑKaÔ0bÓ-bð 'ð —>‘> !°�>Ó5ÒD¼¿¹ˆDØ—6‘6ˆDá3�A¸DÀ$ÐGÐG¸¸DÀ$ÐGÐGrN   T)rx  rè  c              3   ó:   K  — | ]  }|j                   d k7  –— Œ y­wrç  r˜  rÈ  s     rM   ra  z,ShapeEnv._maybe_guard_rel.<locals>.<genexpr>H  s   è ø€ Ò3\Àq°A·I±IÀµNÑ3\ùs   ‚c                 óœ   — t        | t        j                  «      r2t        | «      rt        |«      syt	        | t
        j                  «      ryyr×  )rÇ   rR   r  rq  r=   r;   r—  )r  r	  s     rM   Útrivial_solvez0ShapeEnv._maybe_guard_rel.<locals>.trivial_solveY  s:   € Ü! #¤u§|¡|Ô4Ü0°Ô5Ô>SÐTWÔ>XØ#'Ü)¨#¬t¯z©zÔ:Ø#'ð !rN   Útrivial_lhsÚtrivial_rhsFry  c              3   ó4   K  — | ]  }|j                   –— Œ y ­wrG   )r8  )r_  r3  s     rM   ra  z,ShapeEnv._maybe_guard_rel.<locals>.<genexpr>j  s   è ø€ Ò,b¸a¨Q¯\­\Ñ,bùrb  r½   r2  rù   Údivisibility).rÇ   rR   r%  r)  rÁ   rf   r  ry  r  r	  Ú_refine_rangesr  rL  r)   rM  r(   rf  rË  r-  rÜ  r1  r/   rl  Úpreorder_traversalrq  r	   r  rd  rü  r‹  rK   ÚNumberr1  rÞ  rL  r†  rÈ   rÑ   rv  r2   Úfloordivr  r3   Úwrapr£  ræ  )rJ   rÑ   Úfreer˜  r  r	  Úfloor_div_atomsr›  rv  rç  ÚokÚmod_exprÚpÚqrH  Úi0ÚdÚi1s   `                 rM   Ú_maybe_guard_relzShapeEnv._maybe_guard_rel  st  ø€ ô ˜$¤§	¡	Ô*Ð*Ð*ô
 �dœEŸH™HÔ%Øä�D×%Ñ%Ó&ˆä�4‹y˜1Š}ÐZÐ SÐTXÐSYÐZÓZˆ}äˆt‹9�qŠ=Øô	Hô �dÐ 2¸DÔAˆØ�h‰hˆØ�h‰hˆà×Ñ˜DÔ!ô ˜$¤§¡Ô)Øà�x‰xœ�}ð*Ø"%§)¡)¬HÓ"5×";Ñ";¸C¿I¹IÄhÓ<OÓ"P�Ü�Ó'¨!Ò+´Ñ3\ÈOÔ3\Ô0\Ü-Ð-ò !ñ !  cÔ*Ø×)Ñ)¨#¨t¯z©z¸#«ÀÕNÙ" 3¨Ô,Ø×)Ñ)¨#¨t¯z©z¸#«ÀÕNä! $¨¨Q©ÀUÔK�AØ�}¬Ñ,bÄ5×C[ÑC[Ð\]Ð^_Ñ\`ÓCaÔ,bÔ)bØ"&§*¡*¨Q¨q©TÓ"2˜Ü Ô!6°wÓ!?Ó@ÀAÑE˜ÙØ ×1Ñ1´$´u·|±|ÀTÈ!ÁWÓ2MÈwÐX_Ô`ð �8‰8”C�=ÜœD §¡¬C£Ó1Ó2ˆHðÜ˜d HÀ%ÔH�Ø‘= Q q¡T¨Q£YØ×'Ñ'¨Ô1ð $Ÿ=™=‘D�A�qÜ! !¤U§\¡\Õ2´zÀ!ÄUÇYÁYÕ7OÔTWÐXY×X^ÑX^ÓT_ÐcdÓTdØ !§¡™˜˜2ô ' q¬%¯,©,Ô7Ü& r¬5¯<©<Ô8Ø ×3Ñ3°BÔ7ð !"¤E§I¡I¨a°£OÑ 3˜AØ!%×!<Ñ!<Ó!>×!CÑ!C×!HÑ!H˜Bð !×5Ñ5°bÔ:Q×:ZÑ:ZØ $× 1Ñ 1°"Ñ 5´{×7GÑ7GÈÓ7Jó;ô ð  " T§^¡^Ñ3Ø $§¡× 2Ñ 2°2Ô 6Ø ×1Ñ1°"°a¸"±f¸nÔMñ 	øôI 'ò ÚðûôD 'ò ØØðús&   Ã#EP É/FP  Ð	PÐPÐ 	P,Ð+P,c                 óB   — | j                   rdnd}t        |t        «      S )Nrù   r   )r„  r3   r0   )rJ   r  s     rM   r™  zShapeEnv._default_value_range–  s   € Ø×-Ò-‘°1ˆÜ˜5¤&Ó)Ð)rN   c                 ó,   — t        t         t        «      S rG   )r3   r0   r|  s    rM   r‡  z)ShapeEnv._default_unspecified_value_rangeš  s   € ÜœF˜7¤FÓ+Ð+rN   c                 ó  — t        |j                  t        «      «      }t        |«      D ]D  }|j                  \  }}t        ||«      }t        j                  |d«      }| j                  |«       ŒF | j                  |«      S r�   )
r:  rM  r(   r¿   rK   r)   rR   r  rì  r×  )rJ   rÑ   Ú
floor_divsrS  rè  r•  r¨  Úeq_exprs           rM   Ú_simplify_floor_divzShapeEnv._simplify_floor_div�  ss   € ä˜4Ÿ:™:¤hÓ/Ó0ˆ
ô ˜:Ó&ò 	(ˆBØŸG™G‰MˆD�'Ü˜4 Ó)ˆHÜ—h‘h˜x¨Ó+ˆGà×Ñ˜wÕ'ð	(ð �}‰}˜TÓ"Ð"rN   c                 óÄ   — | j                   rT| j                  dxx   dz  cc<   t        ddi | j                  ¥|› d|› �ddœ¥«       t        j                  d||d	¬
«       y y )NÚignored_backward_guardr½   rå  Úevaluate_expr_frozenr  rù   )Úignored_guardÚversionz>Ignored guard %s == %s, this could result in accuracy problemsTrt  )ry  r¯  r9   r—  r}   rn  )rJ   rÑ   rø  s      rM   Ú_check_frozenzShapeEnv._check_frozen­  st   € Ø�;Š;Ø�L‰LÐ1Ó2°aÑ7Ó2ÜØØ&ðØ—n‘nðà(, v¨T°,°Ð%@ð  !òô
ô �K‰KÐXÐZ^Ð`lÐy}ˆKÕ~ð rN   rx  c                 ó”  — d }t        j                  «       }	 |�y|j                  j                  t	        «       vrJt        j                  |j                  j                  |j                  |j                  j                  «      }n|j                  }|�Œy~d}t        j                  «       }|rdt        |d   «      z   }d}|r)|r'ddj                  t        j                  |«      «      z   }|rLt        j                   r<t#        j$                  d¬«      }|ddj                  |j'                  «       «      z   z  }n|r|dz  }|||fS # ~w xY w)	Nr×   z at r¾   zM
User Stack (most recent call last):
  (snipped, see stack below for prefix)
T)Úcppz
C++ stack trace:
z?
For C++ stack trace, run with TORCHDYNAMO_EXTENDED_DEBUG_CPP=1)r°   rô  r÷  rø  rµ   rm  ÚFrameSummaryrù  Úco_namerõ  r%   r‚  r7   r  Úformat_listr›  Úextended_debug_cppr8   r�  r¯  )rJ   rx  ry  rú  rz  r€  r{  Ú	cpp_stacks           rM   rw  zShapeEnv._get_stack_summary¾  sH  € ØˆÜ×$Ñ$Ó&ˆð	ØÐ#Ø—<‘<×+Ñ+Ô3FÓ3HÑHÜ(×5Ñ5ØŸ™×0Ñ0ØŸ™ØŸ™×,Ñ,ó �Hð
 ØŸ™�ð Ñ#ð ð ˆÜ ×.Ñ.Ó0ˆÙØ#¤l°7¸2±;Ó&?Ñ?ˆNàÐÙ™ð<à—‘œ	×-Ñ-¨gÓ6Ó7ñ8ð ñ
 œ×1Ò1Ü)×1Ñ1°dÔ;ˆIØÐ!7¸"¿'¹'À)×BRÑBRÓBTÓ:UÑ!UÑUÑÙØð3ñÐð
 ˜Ð):Ð:Ð:øñ3 ús   ˜A:E ÅEÚforcing_specc           
      ó`  — | j                   j                  t        j                  «      r…t	        |«      }t
        j                  d uxr |t
        j                  k(  }| j                  |«      \  }}}d}	|sd|› d�}	| j                   j                  d|s|n|› d�||t        |«      |	||¬«       y y )Nr×   zA, for more info run with TORCHDYNAMO_EXTENDED_DEBUG_GUARD_ADDED="r”  z%s %s [guard added]%s (%s)%s%sz (forcing_spec)rt  )
r}   r”   r•   ÚINFOr�  r›  Úextended_debug_guard_addedrw  r  r7   )
rJ   rq  rÅ  rÂ  Ústr_grx  ry  rz  r{  rŸ  s
             rM   Ú
_log_guardzShapeEnv._log_guardç  s¾   € Ø�8‰8× Ñ ¤§¡Ô.Ü˜“FˆEÜ×8Ñ8ÀÐDÒsÈÔRX×RsÑRsÑIsˆHØ:>×:QÑ:QÐRZÓ:[Ñ7ˆH�nÐ&7Ø ˆOÙð?Ø?D¸gÀQðHð  ð �H‰H�M‰MØ0Ù*‘°6°(¸/Ð0JØØÜ˜XÓ&ØØ!Ø#ð õ 	ð /rN   )Úsave_tracked_fakes©rÂ  rý  c                óŠ   — 	 | j                  |||||¬«      S # t        $ r! | j                  j                  d||||«       ‚ w xY w)NrÉ  zKfailed during evaluate_expr(%s, hint=%s, size_oblivious=%s, forcing_spec=%s)Ú_evaluate_exprrÄ  r}   rn  )rJ   rý  r‚  rd  r&  rÂ  s         rM   rì  zShapeEnv.evaluate_exprý  sV   € ð	Ø×&Ñ& y°$¸ÀÐ^jÐ&ÓkÐkøÜò 	Ø�H‰H×ÑØ]Ø˜4 °ôð ð	ús	   ‚ ˜*Ac                ó¬
  ‡ ‡‡‡— t        j                  d«      ˆˆˆ fd„«       }d}d}‰ j                  �r|��‰ j                  «       sû|sù |«       }	|	t        j
                  u r%‰ j                  t        j                  |f«      \  }}n¤|	t        j                  u rI‰ j                  t        j                  |f«      \  }
}‰ j                  t        j                  |
f«      \  }}nI‰ j                  t        j                  ||	f«      \  }}‰ j                  t        j                  |f«      \  }}|€J ‚|r‰ j                  |«       d}d}	 ‰j                  r1‰ j                  j!                  d‰«       ‰�‰‰k(  sJ ‰› d‰› �«       ‚‰S ‰}‰ j#                  ||¬«      }|�2‰ j                  j!                  d‰|«       ‰�|‰k(  sJ |› d‰› �«       ‚|S d}d}	|j$                  ‰ j&                  j)                  «       k  sà‰ j#                  |d¬	«      }|j$                  ‰ j&                  j)                  «       k  s¤d}|s‰ j#                  |d¬«      }‰ j*                  rT‰j-                  ‰ j*                  «      xŠj$                  s-t        j/                  d
‰‰«       t1        dˆˆfd„¬«       d}‰}	n/‰ j3                  |j-                  ‰ j&                  «      ||¬«      ‚|}|	€ |«       }	‰ j5                  ||	«       t6        j8                  rOt;        ‰t<        «      r?t;        |t        j>                  t        j@                  f«      rt	        jB                  |«      }|	t        j
                  u r|}n>|	t        j                  u rt	        jB                  |«      }nt	        j>                  ||	«      }|r‰ jE                  |d‰› d‰› �«       |	S ‰ j                  «       sŠt;        |t        jF                  «      r‰ jI                  |«       ‰ jJ                  s>tM        jN                  d¬«      }tQ        ||«      }‰ jR                  jU                  |«       n‰ jE                  |d‰› �«       ‰ j                  «       s³|�Å‰ jW                  d||¬«       |j$                  D ]Œ  }‰ jX                  |xx   dz  cc<   |rŒt6        jZ                  €Œ.‰ jX                  |   t6        jZ                  kD  sŒO‰ j                  j]                  dt6        jZ                  |«       ‰ j_                  |d¬«       ŒŽ |	S ‰ jW                  d||¬«       |	S # t`        $ r |r‰ jc                  |«       ‚ w xY w)zO
        Given an expression, evaluates it, adding guards if necessary
        Nc                  óT   •— ‰ €‰j                  ‰«      S t        j                  ‰ «      S rG   )rg  rR   r±  )r‚  rý  rJ   s   €€€rM   Úcompute_concrete_valz5ShapeEnv._evaluate_expr.<locals>.compute_concrete_val  s&   ø€ àˆ|Ø—~‘~ iÓ0Ð0ä—}‘} TÓ*Ð*rN   Fzeval %s [trivial]rÝ   r{  z eval %s == %s [statically known]T©r:  z.propagate_real_tensors evaluate_expr(%s) -> %srY  c                  óž   •— t        ‰ «      t        ‰«      t        j                  t        j                  d¬«      j                  «       «      dœS r[  r\  )rý  Úunsound_results   €€rM   râ   z)ShapeEnv._evaluate_expr.<locals>.<lambda>m  s=   ø€ Ü(,¨Y«Ü*.¨~Ó*>Ü)3×)BÑ)BÔCT×C\ÑC\ÐbcÔCd×ClÑClÓCnÓ)oñ1€ rN   r`  ri  rb  r  r½   r  zevaluate_expr: r  rÉ  z6symbol_guard_limit_before_specialize=%s exceeded on %szeval [guard suppressed])2r†   r’   r�  r  rR   rú  r  r²   Ú_assertrû  rÔ  Únot_r  r  rk  r}   r~   rÃ  rf   rß  r;  rŸ  rå  rn  r   re  rº  r›  Ú/inject_EVALUATE_EXPR_flip_equality_TESTING_ONLYrÇ   rØ   r  r)  r(  rd  r%  r®  r‡  r8   r�  r#   rž  rÀ   rÇ  r°  Ú$symbol_guard_limit_before_specializer  rì  rÄ  r  )rJ   rý  r‚  rd  r&  rÂ  rÎ  rÈ   r  rø  r@  r¦  ÚeqlrÓ  r!  rÑ   Ústatic_exprÚtransmute_into_runtime_assertrT  rj  rÅ  r¢  rT  rÑ  s   ```                    @rM   rË  zShapeEnv._evaluate_expr
  s  û€ ô 
×	Ñ	˜TÓ	"õ	+ó 
#ð	+ð ˆØˆà×4Ó4ØÑ'Ø×1Ñ1Ô3Ù&á/Ó1ˆLØœuŸz™zÑ)Ø"×;Ñ;¼E¿M¹MÈGÈ:ÓV‘�‘eØ¤§¡Ñ,Ø×6Ñ6´x·}±}ÀwÀjÓQ‘��QØ"×;Ñ;¼E¿M¹MÈCÈ6ÓR‘�‘eà×6Ñ6´x·{±{ÀWÈlÐD[Ó\‘��QØ"×;Ñ;¼E¿M¹MÈCÈ6ÓR‘��eàÐ#Ð#Ð#ñ
 Ø×*Ñ*¨4Ô0ð ˆØˆðE	YØ×"Ò"Ø—‘—‘Ð2°IÔ>ØÐ#Ø$¨Ò,ÐF°°¸4À¸vÐ.FÓFÐ,Ø Ð àˆDà×5Ñ5°dØESð 6ó UˆKàÐ&Ø—‘—‘ÐAÀ9ÈkÔZØÐ#Ø&¨$Ò.ÐJ°;°-¸tÀDÀ6Ð0JÓJÐ.Ø"Ð"à,1Ð)àˆLØ×%Ñ%¨¯©×)=Ñ)=Ó)?Ò?ð  ×6Ñ6°tÈ4Ð6ÓP�Ø ×-Ñ-°·±×1EÑ1EÓ1GÒGØ,0Ð)Ù)Ø04×0KÑ0KØ Ø+/ð 1Ló 1Ð-ð ×0Ò0Ø/8×/AÑ/AÀ$×BZÑBZÓ/[Ð[˜^×iÒiäŸ™Ð$TÐV_ÐaoÔpÜ(Ø4ô)õð 9=Ð5Ø'5™à"×=Ñ=Ø ŸM™M¨$¯/©/Ó:Ø Ø2Gð >ó ð ð $�DàÐ#Ù3Ó5�Ø×Ñ˜t \Ô2ô ×JÒJÜ" 4¬Ô.Ü" 4¬%¯(©(´E·H±HÐ)=Ô>ä—y‘y “�ð œuŸz™zÑ)Ø‘Ø¤§¡Ñ,Ü—I‘I˜d“O‘ä—H‘H˜T <Ó0�á,Ø×)Ñ)ØØ.¨y¨k¸¸nÐ=MÐNôð $Ð#à×,Ñ,Ô.Ü˜a¤§¡Ô+ð ×)Ñ)¨!Ô,à×CÒCô .×5Ñ5¸1Ô=�EÜ& q¨%Ó0�EØ—K‘K×&Ñ& uÕ-ð
 ×-Ñ-¨a°?À9À+Ð1NÔOð ×,Ñ,Ô.ØÐ$Ø—O‘O F¨A¸L�OÔIàŸ^™^ò E˜Ø×1Ñ1°!Ó4¸Ñ9Ó4ò !-Ü"×GÑGÑSØ ×5Ñ5°aÑ8¼6×;fÑ;fÓfð !ŸH™HŸM™MØ XÜ &× KÑ KØ !ôð
 !×.Ñ.¨q¸tÐ.ÕDðEð$ Ðð —‘Ð 9¸1È<�ÔXàÐøô7 ò 	ÙØ×$Ñ$ TÔ*Øð	ús!   Å<T5 ÆAT5 ÇG3T5 ÏBT5 Ô5Uc                 ó8  — | j                   D ]  }|j                  j                  «        Œ | j                  j	                  «       D ]  }|j                  «        Œ | j
                  j	                  «       D ]#  }|D ]  }|j                  j                  «        Œ Œ% y)z°
        Break reference cycles.

        This destroys the stacks. If you really want to keep them, we
        just need some way to break references on code objects.
        N)rž  r¢  Úcleanupr   r¯  r©  )rJ   rÅ  rT  rÆ  rÇ  s        rM   rÚ  zShapeEnv.cleanupÎ  s‰   € ð —‘ò 	ˆAØ�G‰G�O‰OÕð	à×"Ñ"×)Ñ)Ó+ò 	ˆAØ�I‰I�Kð	à×0Ñ0×7Ñ7Ó9ò 	#ˆCØò #�Ø—‘× Ñ Õ"ñ#ñ	#rN   c                 óP  — |}| j                  |«      }|�| j                  j                  d||«       |S | j                  |d¬«      }| j                  s:|j                  | j
                  j                  «       k  r| j                  ||¬«      S | j                  rM|�K| j                  «       s;| j                  t        j                  |f«      \  }}|€J ‚|r| j                  |«       | j                  «       �s| j                  rJ |«       ‚| j                  |t         j"                  «       t%        |t         j&                  «      r| j)                  |«       |}t+        |«      }t-        j.                  d¬«      }	t1        |||	«      }
t3        d„ |j                  D «       d	„ ¬
«      }|r|d   nd}| j4                  j7                  |g «      j9                  |
«       | xj:                  dz  c_        | j=                  «        | j?                  d|d¬«       y| j?                  d|d¬«       y)aQ  Create an assert that is checked at runtime

        Args:
            orig_expr (sympy.Expr): Boolean expression to assert is true
            msg (str): Message to display on assertion failure
            fx_node (Optional, torch.fx.Node): node in ``self.graph`` corresponding
                to the expression, if applicable

        Nz*runtime_assert %s == %s [statically known]TrÏ  rc  r½   r  c              3   óV   K  — | ]!  }t        |t        j                  «      sŒ|–— Œ# y ­wrG   rŠ  r–  s     rM   ra  z0ShapeEnv.defer_runtime_assert.<locals>.<genexpr>  s   è ø€ Òa !¼NÈ1Ìd×N_ÑN_Õ<`œAÑaùr#  c                 ó2   — t        | j                  dd  «      S rD  )rË   r„  rS  s    rM   râ   z/ShapeEnv.defer_runtime_assert.<locals>.<lambda>  s    € ÔqtÐuv×u{Ñu{Ð|}Ð|~Ðuó  rA€ rN   rw  r¾   Úruntime_assertFrÉ  z!runtime_assert [guard suppressed]) rÃ  r}   r~   r†  rf   rß  r;  rì  r�  r  r  r²   rÒ  r  r«  rº  rR   rú  rÇ   r%  r®  rc   r8   r�  r   ry  r©  Ú
setdefaultrÀ   rª  r&  rÇ  )rJ   rý  r¡  rd  rÑ   r×  rT  rÈ   r  r¢  rÇ  ÚcandsÚixs                rM   rd  zShapeEnv.defer_runtime_assertÝ  s  € ð ˆð ×1Ñ1°$Ó7ˆØÐ"Ø�H‰H�N‰NÐGÈÐT_Ô`ØÐð ×.Ñ.¨tÀ4Ð.ÓHˆØ×?Ò?ÀH×DYÑDYÐ]a×]lÑ]l×]qÑ]qÓ]sÒDsà×%Ñ% h¸Ð%Ó@Ð@ð ×0Ò0ØÐ#Ø×-Ñ-Ô/à×7Ñ7¼¿¹ÈÀzÓR‰KˆD�%ØÐ#Ð#Ð#ÙØ×*Ñ*¨4Ô0à×(Ñ(Õ*ð ×2Ò2Ð8°DÓ8Ð2à×Ñ˜t¤U§Z¡ZÔ0ô ˜$¤§	¡	Ô*Ø×%Ñ% dÔ+ð ˆIÜ)¨$Ó/ˆDÜ%×-Ñ-°1Ô5ˆEÜ˜t S¨%Ó0ˆBäÑa t×'8Ñ'8Ôañ  hAô  BˆEñ $��r’¨ˆBØ×)Ñ)×4Ñ4°R¸Ó<×CÑCÀBÔGØ×-Ò-°Ñ2Õ-Ø×(Ñ(Ô*Ø�O‰OÐ,¨iÀeˆOÔLð ð �O‰OÐ?ÀÐY^ˆOÔ_àrN   c                 ó®  — | j                  |«      }|j                  D �]4  }t        |t        j                  «      sJ ‚t        | j
                  j                  |d «      t        «      rŒKt        ||«      }|�|j                  r|d   j                  sŒu|\  }}| j                  |   }|j                  |j                  }}t        || j                  «      }	||	j                  k  rit        |t        j                  t        j                  t        j                   f«      r0|	j                  t#        t        |t        j                   «      «      z   }||	j                  kD  rit        |t        j                  t        j$                  t        j&                  f«      r0|	j                  t#        t        |t        j&                  «      «      z
  }|t)        ||«      k(  r�Œ¸| j+                  |t)        ||«      «       | j                  |   j-                  «       r*| j/                  || j                  |   j                  d«       | j0                  j3                  «        �Œ7 y )Nr½   Úrange_refined_to_singleton)r×  rf   rÇ   rR   r  rß  rï   r6   r/   r8  r  r  r   r1   r  r8  r6  rË   r9  r7  r3   rv  r?  rÜ  rÃ  r“   )
rJ   rÑ   r¼  rv  Úr_exprr	  r  r  r   Úrhs_vrs
             rM   r   zShapeEnv._refine_ranges,  sÐ  € Ø�}‰}˜TÓ"ˆà×'Ñ'ó 1	6ˆFÜ˜f¤e§l¡lÔ3Ð3Ð3ä˜$Ÿ/™/×-Ñ-¨f°dÓ;¼\ÔJð ä˜$ Ó'ˆAàˆy ×!2Ò!2°q¸±t·²ð à‰KˆF�CØ×"Ñ" 6Ñ*ˆBØŸ8™8 R§X¡X�5ˆEä   d×&7Ñ&7Ó8ˆFð �v—|‘|Ò#¬
°6¼E¿H¹HÄeÇhÁhÔPU×PXÑPXÐ;YÔ(Zð Ÿ™¤s¬:°f¼e¿h¹hÓ+GÓ'HÑH�Ø�v—|‘|Ò#¬
°6¼E¿H¹HÄeÇhÁhÔPU×PXÑPXÐ;YÔ(ZØŸ™¤s¬:°f¼e¿h¹hÓ+GÓ'HÑH�ð ”[ ¨Ó.Ò.Ùð ×%Ñ% f¬k¸%ÀÓ.GÔHà× Ñ  Ñ(×5Ñ5Ô7Ø×%Ñ% f¨d×.?Ñ.?ÀÑ.G×.MÑ.MÐOkÔlð ×'Ñ'×3Ñ3Ö5ñc1	6rN   )rŠ   rT  rØ  rÙ  c                 ó  — t        ||«      }| j                  j                  |t        j                  «       «      }| j	                  ||«       | j                  |   x}|k7  r-t
        j                  d||j                  |j                  «       y y )Nz"constrain_symbol_range %s [%s, %s])	r3   r  rï   r‚  rv  r}   r  r  r   )rJ   rT  rØ  rÙ  Úupd_vrÚold_vrÚnew_vrs          rM   rÛ  zShapeEnv.constrain_symbol_rangeb  sy   € ô ˜\¨<Ó8ˆØ×"Ñ"×&Ñ& q¬+×*=Ñ*=Ó*?Ó@ˆØ×!Ñ! ! VÔ,Ø×'Ñ'¨Ñ*Ð*ˆF¨vÒ5Ü�H‰HÐ9¸1¸f¿l¹lÈFÏLÉLÕYð 6rN   )r{  r^   r›   N©NN©r›   N)r_  r`  ro  rh  )rÑ   r`  r›   r`  )rÑ   r`  )rÄ   r(  r›   r`  )rÑ   z	sympy.Relr›   N)NNFrG   )rý  r`  )…rO   rP   rQ   r   rØ   r   r   rI   rŽ  Úpropertyr�  r‚  rƒ  r„  r…  r†  r‡  rÊ  rÓ  rË   rÕ  r   rØ  r   rR   r  rS   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  r  r  r  r  r!  r  r“  r&  r   rn   r*  r)  ræ   rB  r9  r>  rƒ  rj  rm  rp  r�  r3   r|  r€  r†  rÞ  rŒ  r  r  r   r"   rå   r!   r]  rl  r1  r¢  r¥  r¨  r#   r\  r'  r®  r  r  r  r  r  r  r  r%  r1   rž  r3  r’   r9  rÃ  rî  rI  r×  rg  rÎ   re  rv  rÜ  r‹  r1  r®  r™  r‡  r´  rº  rw  rÇ  rì  rË  rÚ  rd  r   rÛ  rZ   rN   rM   r^   r^   	  sy  „ ð 04Ø-1ò2]à& t™nð2]ð    S¡	Ñ*ð2]ð
 
ó2]ðv "Ø'+ð
 "'ð !ð &*àð 5:ð 16òIT=ð, ˜T‘Nó-T=ðl ñ2ó ð2ð ñ<ó ð<ð ñ6ó ð6ð ñ1ó ð1ð ñ(ó ð(ð ñIó ðIð ñEó ðEó7VðrK¨°$°s±)Ñ)<ó Kð$$ 3ó $ð ñ&ó ð&ñ ÓðC¨%¯,©,ð C¸u¿z¹zò Có ðCñ Óð7¨¯©ð 7¸#ð 7À$ò 7ó ð7ñ Óð
J¨%¯,©,ð 
J¸u¿|¹|ò 
Jó ð
Jñ Óñ¨5¯<©<ð ¸hÀs¹mð ÐYaÐbeÑYfò ó ðñ& Óð %§*¡*ð °3ð ¸Sò ó ðñ" Óñ9ó ð9òBDñ Óñ1ó ð1ñ Óñ2ó ð2ð ñ	7ó ð	7ñ Óñó ðñ Óñ	+ó ð	+ð.°ð .¸8ÀEÇLÁLÑ;Qó .ð1 §¡ð 1°Tð 1¸dó 1ó1ó/ó&ñ Óð=àð=ð ð=ð 
ˆx˜Ÿ™Ÿ™Ñ&¨Ð,Ñ	-ò	=ó ð=ð:,à—L‘Lð,ð ð,ð 
�%—(‘(—-‘-Ñ	 ó	,ð4( H¨U¯X©X¯]©]Ñ$;ð (Àó (ð
=¨%¯(©(¯-©-ð =¸Dó =ò6ñ Óñ#ó ð#ñ Óñ$ó ð$ð ñ)ó ð)òò	'ð`Ø$,¨S¡Mð`à#)ð`ð .=ð`ð !% U§Z¡ZÑ 0ó	`ðØ7<¸S±zðà28ðð =Lðð 04°E·J±JÑ/?ó	ð4 7;ò
à�L‰Lð
ð ð
ð
 # ?Ñ3ó
ðxÀó ñ Óð 7;òIGà˜#‘ðIGð ˜C‘=ðIGð ð	IGð
 ! ™ðIGð ðIGð # ?Ñ3òIGó ðIGñV Óð (,ò*àð*ð ˜3‘-ð	*ð
 ˜VÑ$ò*ó ð*ñX Óð (,ò#àð#ð ˜3‘-ð	#ð
 ˜VÑ$ò#ó ð#ñJ Óñ

ó ð

ó7ð
°#ð 
À;ó 
ñ ÓñMó ðMñ$ ÓñIó ðIð$9¨¯©ð 9¸$ó 9ñ
 ÓñXó ðXñ$ Óð
 #-§/¡/Ø(,ñ#à�3˜  xÐ/Ñ0ð#ð ð#ð  ð	#ð
 &ð#ð 
ò#ó ð#ñ4 Óð
 #-§/¡/Ø(,Ø#'Ø+0Øñlàðlð ðlð  ð	lð
 &ðlð ˜4‘.ðlð %)ðlð 
òló ðlð\3 5§<¡<ð 3°có 3òFò ñ, &ð	e	ð $(Ø=Að ;?Øàòe	ð �ZÑ ðe	ð ! ¨Ñ!9Ñ:ðe	ð $Ð$6Ñ7ðe	ð 
ˆc‰óe	ðV .2Øòð ˜˜jÑ)Ñ*ó	ò0.òKð MQô ò
ò/òbBó^ñ/ §
¡
ð /¸Dð /È[ó /ð  ñ3 (¨5°Ñ+@Ñ"Að 3ÐX\ð 3ÐinÐo{Ñi|ò 3ó ð3ñ( ˆtƒ_ð"$Ø(ð"$Ø-2°5Ð9hÑ3iÑ-jò"$ó ð"$ðH à;@ÐW\Ø$ÈDØJNòM3Ø ðM3Ø48ðM3ØPTðM3àðM3à.6°u¸U¿Z¹ZÑ7HÑ.IðM3ð ˜u U¨5¯<©<¸Ð+DÑ%EÑFÑGðM3ð 
 ò	M3ó ðM3ð^ ò8ó ð8ð ñ'ó ð'ð ò%ó ð%ñN ˆsƒ^Ø:?ô &ó ð&ñR ˆsƒ^ò]ó ð]ð jnò $6ÐX`ÐaeÑXfó $6òL-ð:{0 .ð {0°|ð {0È#ð {0ÐRVó {0óz'ð ÙÓò$ó ó ð$ñ" ˆsƒ^òzó ðzðz* kó *ð,°+ó ,ð ñ#ó ð#òñ"';¨4ó ';ðR ð °tó ñ, ˆsƒ^Ù¨dÔ3ØHLØ-2ð	ØLQò	 |ð 	Ø&*ð	ØEIò	ó 4ó ð	ð JNØ.3ðBØMRòB¨ð BØ'+ðBØFJóBòH#ñ ¨dÔ3óBó 4ðBð\46 5§:¡:ð 46°$ó 46ñl �tÔÙÓðZ¨¯©ð ZÀCð ZÐWZò Zó ó ñZrN   r^   c                 óf   — t        | t        «      xr  | j                  j                  j                  S rG   )rÇ   r"   rÈ   rÑ   rk  rÙ   s    rM   Ú_is_intrî  l  s"   € Ü�dœFÓ#Ò@¨¯	©	¯©×(@Ñ(@Ð@rN   c                 ó:   — t        | d«      xr || j                  v S )NÚ_dynamo_dynamic_indices)rl  rð  )r3  r¬  s     rM   r?  r?  p  s    € Ü�1Ð/Ó0ÒS°Q¸!×:SÑ:SÐ5SÐSrN   c                   óL   ‡ — e Zd Zdej                  j
                  fˆ fd„Zˆ xZS )ÚPropagateUnbackedSymIntsrô   c                 ój   •— ddl m} t        ‰| �  |«      }t	         |«       j
                  ||«       |S )z]
        Run an FX node, propagating unbacked Symbol bindings to the new fake tensor
        r   )Údetect_fake_mode)Útorch._guardsrô  rH   Úrun_noderw   rð   )rJ   rô   rô  r  rL   s       €rM   rö  z!PropagateUnbackedSymInts.run_nodet  s2   ø€ õ 	3ä‘Ñ! !Ó$ˆÜÑ(Ó*×4Ñ4°a¸Ô@ØˆrN   )rO   rP   rQ   r²   r¤   r  rö  rU   rV   s   @rM   rò  rò  s  s   ø„ ð˜%Ÿ(™(Ÿ-™-÷ ñ rN   rò  c                  ó>  — t        j                  «       } | �†| j                  j                  j	                  t
        j                  j                  t        j                  t        «      «      t
        j                  j                  z   «      s	 | S | j                  } | �Œ†| S rG   )r°   rô  r÷  rø  Ú
startswithÚosr  Údirnamer±   r²   Úseprõ  )rú  s    rM   Ú_find_user_code_framerü    sx   € Ü× Ñ Ó"€EØ
Ð
Ø�|‰|×'Ñ'×2Ñ2Ü�G‰G�O‰OœGŸO™O¬EÓ2Ó3´b·g±g·k±kÑAô
ð à€Lð —‘ˆð Ñ
ð €LrN   c                 óJ  — t        j                  |j                  j                  |j                  |j                  j
                  «      }| j                  d   }|ddj                  t         j                  j                  |g«      j                  «       «      z   z  }|f| _        y )Nr   z(

The following call raised this error:
r×   )rm  r½  r÷  rø  rù  r¾  rK   r  rn  ro  r¯  )r`  rú  Úframe_summaryr¡  s       rM   Ú_blame_user_coderÿ  Š  sˆ   € Ü×*Ñ*Ø�‰× Ñ Ø�‰Ø�‰×Ñó€Mð
 �&‰&�‰)€CØØ5Ø
�‰”	×&Ñ&×0Ñ0°-°ÓA×HÑHÓJÓKñ	Lñ€Cð ˆV€A…FrN   c                   ó.   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zˆ xZS )Ú_PythonPrinterz¶
    Util printer that replaces sympy symbols with their source-level names
    and renders sympy relational operators (e.g., Eq, Ne, Ge, Le) inline
    (i.e., as ==, !=, >, <).
    c                 ó0   •— t         ‰| �  «        || _        y rG   )rH   rI   Úsrc_map)rJ   r  rL   s     €rM   rI   z_PythonPrinter.__init__Ÿ  s   ø€ Ü‰ÑÔØˆ�rN   c                 ó:   — | j                   |j                     d   S r�   )r  r„  ro  s     rM   r¿  z_PythonPrinter._print_Symbol£  s   € Ø�|‰|˜CŸH™HÑ% aÑ(Ð(rN   c                 ó:  — | j                  |j                  t        j                  j                  j	                  |«      «      }|j
                  }| j                  |j                  t        j                  j                  j	                  |«      «      }|› d|› d|› �S rË  )r°  r  rR   ÚprintingrA   rÌ  r	  )rJ   rÑ   r  rÌ  r	  s        rM   rÍ  z _PythonPrinter._print_Relational¦  sx   € Ø×Ñ §¡¬%¯.©.×*CÑ*C×*NÑ*NÈtÓ*TÓUˆØ—‘ˆØ×Ñ §¡¬%¯.©.×*CÑ*C×*NÑ*NÈtÓ*TÓUˆØ��a˜�x˜q  Ð&Ð&rN   )rO   rP   rQ   r  rI   r¿  rÍ  rU   rV   s   @rM   r  r  ˜  s   ø„ ñôò)ö'rN   r  c                 ó"  ‡— | j                   }dj                  ˆfd„|j                  D «       «      }|rt        j	                  d|«       y t        ‰«      }| j                  d   }|dz  }d|j                  |«      › d�d|j                  t        j                  |«      «      › d�g}t        |«      D ]  \  }}|d|d	z   › d
|› �z  }Œ dj                  ˆfd„t        d„ |j                  D «       «      D «       «      }	|d|	› d|› d�z  }|f| _        y )Nrk  c              3   óT   •K  — | ]  }|j                   ‰vsŒ|j                   –— Œ! y ­wrG   r‡  ©r_  rT  r  s     €rM   ra  z(_suggest_torch_checks.<locals>.<genexpr>°  s    øè ø€ ÒP ¸!¿&¹&ÈÒ:O�Q—V•VÑPùs   ƒ(—(z.Unable to find user code corresponding to {%s}r   zG
To fix the error, insert one of the following checks before this call:ztorch._check(r—  rn  r½   rä  c              3   óR   •K  — | ]  }d |› ddj                  ‰|   «      › �–— Œ  y­w)ú`z` with r¸  N)r  r	  s     €rM   ra  z(_suggest_torch_checks.<locals>.<genexpr>¿  s4   øè ø€ ò àð ˆAˆ3ˆg�f—k‘k '¨!¡*Ó-Ð.Ô/ñùs   ƒ$'c              3   ó4   K  — | ]  }|j                   –— Œ y ­wrG   r‡  r–  s     rM   ra  z(_suggest_torch_checks.<locals>.<genexpr>Á  s   è ø€ Ò: 1˜Ÿ�Ñ:ùrb  z3

(These suggested fixes were derived by replacing z in z and its negation.))rE   r  rf   r}   rn  r  rK   r,  rR   r(  r0  ry  )
r`  r  rE   ÚdiffÚprinterr¡  Úsuggested_fixesrê   ÚfixÚ
src_mappeds
    `        rM   Ú_suggest_torch_checksr  ­  s#  ø€ à�6‰6€DØ�9‰9ÓP T×%6Ñ%6ÔPÓP€DÙÜ�‰ÐDÀdÔKØÜ˜WÓ%€GØ
�&‰&�‰)€CØÐUÑU€Cð ˜Ÿ™¨Ó-Ð.¨aÐ0Ø
˜Ÿ™¬¯	©	°$«Ó8Ð9¸Ð;ð€Oô ˜OÓ,ò #‰ˆˆ3Ø��a˜‘c�U˜"˜S˜EÐ"Ñ"‰ð#à—‘ó äÑ:¨×(9Ñ(9Ô:Ó:ôó €Jð ÐBÀ:À,ÈdÐSWÐRXÐXkÐlÑl€CØˆV€A…FrN   c           	      óÌ  — t        «       }|��Wt        | |«       t        t        «      }|j                  j                  «       D �]  \  }}t        j                  |«      D ]ó  \  }}|t        j                  |«      z   }t        |t        j                  «      r2|t        |j                  j                  «         j                  |«       Œjt        |t        j                   «      sŒ…t#        |j$                  «      D ]W  \  }}	t        |	t        j                  «      sŒ!|t        |	j                  j                  «         j                  |› d|› d�«       ŒY Œõ �Œ t'        | |«       yy)zå
    Given a raised data-dependent error, add the following to the error message:
    1. the closest user code location that raised the error;
    2. suggested fixes for the error in terms of live variables at that location.
    Nz.shape[rì  )rü  rÿ  r   rÁ   Úf_localsrí   rþ   Útree_leaves_with_pathÚkeystrrÇ   r²   r"   r�  rÈ   rÑ   rÀ   ræ   r0  r»   r  )
r`  rú  r  ÚvarrU  r  Úleafr„  rê   rÃ   s
             rM   Ú2_suggest_fixes_for_data_dependent_error_non_strictr  Ç  s$  € ô "Ó#€EØÑä˜˜EÔ"ô œdÓ#ˆØŸ™×,Ñ,Ó.ó 		U‰HˆC�ä$×:Ñ:¸3Ó?ò U‘
��dØœVŸ]™]¨4Ó0Ñ0�Ü˜d¤E§L¡LÔ1ØœC §	¡	§¡Ó/Ñ0×7Ñ7¸Õ=Ü ¤e§l¡lÕ3Ü"+¨D¯J©JÓ"7ò U™˜˜3Ü% c¬5¯<©<Õ8Ø#¤C¨¯©¯©Ó$6Ñ7×>Ñ>À$ÀÀwÈqÈcÐQRÐ?SÕTñUòUð		Uô 	˜a Õ)ð' rN   rG   rë  rh  rê  )r   )ùr  Úbuiltinsr­  r†   r°   r¥  r•   rF  rÔ  rù  rq  r¢   Ú	threadingrm  r   Ú
contextlibr   Údataclassesr   r   Úenumr   r—   Útypingr   r	   r
   r   r   r   r   r   r   r   r   r   r   Útyping_extensionsr   r²   Útorch.fxÚtorch.fx.tracebackr¤   rï  Útorch.fx.experimentalr   r›  Útorch.fx.experimental.recordingr   r   r   r   r   Útorch.fx.experimental.sym_noder   r   Útorch._loggingr   r   r    r!   r"   rõ  r#   r$   r%   Útorch.utils._python_dispatchr&   Útorch.utils._sympy.functionsr'   r(   r)   r*   r+   r,   r-   r.   Útorch.utils._sympy.solver/   Útorch.utils._sympy.numbersr0   Útorch.utils._sympy.value_rangesr1   r2   r3   r4   rc  r6   Útorch.utils._tracebackr7   r8   Útorch._utils_internalr9   r    r:   Útorch.utils._pytreerM  Ú_pytreerþ   Útorch.utils._sympy.symbolr;   r<   r=   r>   r+  r?   Ú	InputListr\  Ú	getLoggerrO   r}   rR   Úsympy.printing.strr@   Úsympy.printing.precedencerA   rB   ÚRuntimeErrorrD   rX   Ú_opsr  r  Ú__all__rj   rk   r�   r’   r�  rµ   r·   rØ   r\   rË   ÚIntr]   rd   rå   ÚScalarrÎ   r_   rÕ   rT   rs   rt   rx   r  rw   ry   rc   r-  rS   r<  rh   ri   ræ   rY  rZ  r  rf   rl   rq  rg   rw  rv   rƒ  rŽ  r”  ru   r¿  rÁ  rr   rÍ  rÒ  rm   rb   rÜ  rà  rß  rî  rñ  rö  r¾  r`   ra   r  r  r	  r  r  r  r  r$  r]  r'  rH  rJ  rR  rn   ro   rp   rq   rX  ÚIndicatorTypesro  rq  ru  rs  r
  r€  rE  r  ÚneÚgtÚltÚleÚgerá  râ  Úmodr£  ÚtruedivÚpowrŠ  rK  ÚroundÚtruncre   rž  r   r¤  r©  rÁ  rÆ  rÏ  Úlocalrë  r€  r^   rî  r?  ÚInterpreterrò  rü  rÿ  r  r  r  r  rZ   rN   rM   ú<module>rG     s:	  ðòó Û Û Û Û Û Û Û Û 	Û 	Û 
Û Û Ý #Ý %ß (Ý Û ÷÷ ÷ õ õ (ã Û ß )Ð )Ý 3÷õ ÷ =ß 7÷ ,Ñ +ß <Ñ <Ý F÷÷ ó õ /Ý -ß nÓ nÝ 9ß BÝ 0Ý 6ß $Ð $ß GÑ Gå %áÝ9à€	Ø
€à€g×Ñ˜Ó!€ã Ý )ß <ô ,ô ô	 Lô 	ð ‡z�z‡~�~×Ñ€ò
€ð &Ð Ø!Ð ò_ò
!ñJ ˆ4ƒð.˜S ™Xò .ó ð.ô0	˜|ô 	ð,¨ó ,ð ˆE�L‰L˜#ÐÑ€ð#˜X c™]ð #¨t°C©yó #ñ	��e—l‘l CÐ'Ñ(ð 	°H¸S±Mð 	ÈSó 	ð 
ˆu�|‰|˜UŸ^™^¨U¯]©]¸CÀÈÐLÑ	M€ð�ð ˜4ó ð
�u˜S &˜[Ñ)ð ¨dó ð* 8€ˆiÓ 7ð˜u U§]¡]°DÐ%8Ñ9ð ¸dó óIò0ð0: %§(¡(§-¢-ó 0:ðl˜5Ÿ8™8Ÿ=š=ð ¨Tó ð,. ð .°,ó .ð.# |ð #¸ó #ðL0 %§*¢*ð 0°·²ó 0ð0˜˜d G˜mÑ,ð °ó ò"BðY˜˜f e§l¢lÐ2Ñ3ð Y¸ÀÇÂÑ8Mó Yð0
I�e˜F E§J¢J°·²Ð<Ñ=ð 
IÀ#ÀeÇlÂlÑBSó 
Ið=˜% ¨¯ªÐ 4Ñ5ð =¸$ó =ò
gð x°·²Ñ'=ó òñ �$Ô÷3ð 3ó ð3ñ �$Ô÷'ð 'ó ð'ñ �$Ô÷+ð +ó ð+ñ �$Ô÷!ð !ó ð!óYòvò4ð˜U 4¨ =Ñ1ð °dó ò2	ò	òOò9ðD¨%¯,ª,ð DÀcð DÐY\ó Dò'%ñRF h¨s¡mð FÀÈ#Áó Fð DHò )=˜x¨™}ð )=°8¸C±=ó )=ðV%�u—|‘|ð %¨¯©ð %¸ó %ñb˜ó òòòòLòGð *.ô mòDô�ô ñb �$Ô÷ð ó ðñ �$ÔôH˜Zó Hó ðHñ4 �$Ôô;˜jó ;ó ð;ð2 Ð,Ð.EÀtÐKÑL€á
�$ÔôZC˜ó ZCó ðZCòzbò*ð°ó ñ �$Ô÷	ð 	ó ð	ñ �$Ôô@˜ó @ó ð@ñ` �$ÔôPÐ6ó Pó ðPñB �$Ôô%Ð5ó %ó ð%ð"�U˜3 ¨¨x¸¸wÐFÑGð "ÈDó "ð
 4Ð5€á
ˆ3ƒñó ðò-ò
Oòð>.¨u¯zªzð .¸e¿jºjó .ðC¨e¯m©mð CÀÇÁó CðØ	ˆ8�<Š<ðàˆ(�+Š+ðð 	ˆ(�+Š+ðð 	ˆ(�+Š+ð	ð
 	ˆ(�+Š+ðð 	ˆ(�+Š+ðð 	ˆ(�+Š+ðð 
ˆ3ðð 
ˆ3ðð 
ˆ8�<Š<ðð �—’ðð �×!Ò!ðð ˆx×Òðð �H—L’Lðð (Ð)Jðð  ˆT�ZŠZð!ð" ˆt�yŠyð#ð$ —*’*Ø—’Ø—’Ø(HØ—.’.Ø—N’NØ—*’*Ø×"Ò"Ø×$Ò$Ø�~Š~ò7€ó>1ñp �$Ô÷#ð #ó ð#ô �Zô  ô
#?˜ô #?ôLMÐ0ô Mô
@ *ô @÷0Y
ñ Y
ðx €i‡o‚oÓ€ñ �$Ô÷2ð 2ó ð2÷c1Zñ c1ZòLcAòTô	˜uŸx™x×3Ò3ô 	òòô'�U—^’^×'Ò'×2Ñ2ô 'ò*ó4*rN   