ó
    Eñi16  ã                   óÈ  • S SK r S SKrS SKrS SKJr  S SKJrJr  S SKrS SKJrJ	r	J
r
Jr  S SKJr  SSKJrJr  \R                  r\" S5      SS	.S
\R"                  S\\   S\4S jj5       rS\\\R*                  4   S\S\S\S\4
S jrS r\
S\R2                  \
   S\\
   S\S\S\S\R:                  S0rS r\" 5       r S\RB                  S\4S jr"S\\#   S\\   4S jr$g) é    N)ÚGenericAlias)ÚOptionalÚUnion)ÚdeviceÚdtypeÚTensorÚtypes)Ú
exposed_iné   )Ú_OPAQUE_TYPESÚis_opaque_typeztorch.library)Úop_nameÚprototype_functionr   Úreturnc               óÊ
  ^^^^^^^• SnU R                   mSm[        R                  " U 5      mU4S jmS[        4UUU4S jjmS[        [
        [        [           [        4   S4   S[        [        [        R                  S4   [        4   4U4S	 jjmS
[
        [        [           [        4   S[        [        R                  [        4   4UU4S jjm/ n[        5       nSn[        TR                  R                  5       5       GHÙ  u  nu  p‰[        U	5      (       d  T" S5        U	R                   [        R"                  R$                  :X  a  U(       d  UR'                  S5        SnU	R(                  [        R"                  R*                  L a  T" SU S35        T" U	R(                  5      u  p«SnU
[,        ;  añ  [/        U
5      (       a  [0        U
   R2                  nOÖU
[4        R6                  R8                  :X  a  T" SU S35        O«[;        U
S5      (       ab  U
R<                  [        L aO  [?        U
5      nSnU[,        ;   a  SU S3nT" SU SU	R(                   SU S[,        RA                  5        S3	5        O8T" SU SU	R(                   S[,        RA                  5        S35        O	[,        U
   nUc  [C        SU 35      e[        U5      [        L a;  X:w  a  [E        S5      eURG                  S5      (       a  SU S U[I        S5      S  3nO;X�;   a6  URG                  S5      (       d  T" SU S!35        SU S U[I        S5      S  3nURK                  U5        U	RL                  [        R"                  R*                  L a  UR'                  U S"U 35        GMš  SnU	RL                  b*  [O        U	RL                  [P        [R        [        45      (       a  [        U	RL                  5      nO×[O        U	RL                  [        [4        RT                  45      (       a  S#U	RL                   S#3nO—[O        U	RL                  [4        RV                  5      (       aL  [        U	RL                  5      nS$nURG                  U5      (       d  [C        S%U< S&35      eU[I        U5      S nO"T" SU S'[        U	RL                  5       S(35        UR'                  U S"U S)U 35        GMÜ     X:w  a(  [        U5      U-
  n[I        U5      S*:”  a  T" U S+35        T" TRX                  5      u  nn[[        UT5      nUb  U S,S-R]                  U5       S.U 3$ S,S-R]                  U5       S.U 3$ )/aÞ  Parses the schema of a given function with type hints. The schema is inferred from the
function's type hints, and can be used to define a new operator.

We make the following assumptions:

* None of the outputs alias any of the inputs or each other.
* | String type annotations "device, dtype, Tensor, types" without library specification are
  | assumed to be torch.*. Similarly, string type annotations "Optional, List, Sequence, Union"
  | without library specification are assumed to be typing.*.
* | Only the args listed in ``mutates_args`` are being mutated. If ``mutates_args`` is "unknown",
  | it assumes that all inputs to the operator are being mutates.

Callers (e.g. the custom ops API) are responsible for checking these assumptions.

Args:
    prototype_function: The function from which to infer a schema for from its type annotations.
    op_name (Optional[str]): The name of the operator in the schema. If ``name`` is None, then the
        name is not included in the inferred schema. Note that the input schema to
        ``torch.library.Library.define`` requires a operator name.
    mutates_args ("unknown" | Iterable[str]): The arguments that are mutated in the function.

Returns:
    The inferred schema.

Example:
    >>> def foo_impl(x: torch.Tensor) -> torch.Tensor:
    >>>     return x.sin()
    >>>
    >>> infer_schema(foo_impl, op_name="foo", mutates_args={})
    foo(Tensor x) -> Tensor
    >>>
    >>> infer_schema(foo_impl, mutates_args={})
    (Tensor x) -> Tensor
ÚunknownNc                 ó(   >• [        SU  ST S35      e)Nzinfer_schema(func): z Got func with signature Ú))Ú
ValueError)ÚwhatÚsigs    €ÚX/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/_library/infer_schema.pyÚerror_fnÚinfer_schema.<locals>.error_fnF   s    ø€ ÜÐ/°¨vÐ5NÈsÈeÐSTÐUÓVÐVó    Úannotation_typec                 óX   >•  [        U TT5      $ ! [         a    T" SU  S35         g f = f)NzUnsupported type annotation z. It is not a type.)ÚevalÚ	Exception)r   r   Ú
pf_globalsÚ	pf_localss    €€€r   Úconvert_type_stringÚ)infer_schema.<locals>.convert_type_stringI   s<   ø€ ð	Ü˜¨°YÓ?Ð?øÜó 	ÙØ.¨Ð.?Ð?RÐSöð	ús   ƒ �)¨)Útys.r   c                 óŒ   >• / nSnU  H"  nT" U5      u  p4UR                  U5        X$-  nM$     U(       a  [        U5      S4$ U S4$ )NFT)ÚappendÚtuple)r$   ÚresÚchangedÚtyÚ
ty_changedÚunstringify_types        €r   Úunstringify_typesÚ'infer_schema.<locals>.unstringify_typesQ   sV   ø€ ð ˆØˆÛˆBÙ-¨bÓ1‰NˆBØ�J‰J�rŒNØÑ!ŠGñ ö Ü˜“:˜tÐ#Ð#à˜�:Ðr   r*   c                 óè   >• [        U [        5      (       a
  T" U 5      S4$ [        R                  " U 5      =n(       a2  T" [        R                  " U 5      5      u  p#U(       a  [        X5      S4$ U S4$ )NTF)Ú
isinstanceÚstrÚtypingÚ
get_originÚget_argsr   )r*   ÚoriginÚargsÚargs_changedr"   r-   s       €€r   r,   Ú&infer_schema.<locals>.unstringify_type_   sk   ø€ ô �bœ#×ÑÙ& rÓ*¨DÐ0Ð0Ü×(Ò(¨Ó,Ð,ˆVÕ,Ù!2´6·?²?À2Ó3FÓ!GÑˆDÞÜ# FÓ1°4Ð7Ð7à�5ˆyÐr   Fz>We do not support positional-only args, varargs, or varkwargs.Ú*Tz
Parameter z must have a type annotation.zª's type cannot be inferred from the schema as it is a ScriptObject. Please manually specify the schema using the `schema=` kwarg with the actual type of the ScriptObject.Ú
__origin__z

zFor example, z.

z has unsupported type z]. We do not support Tuple inputs in schema. As a workaround, please try to use List instead. zThe valid types are: Ú.ú. The valid types are: zschema_type is None for param zomutates_args must either be a sequence of the names of the arguments that are mutated or the string 'unknown'. r   zTensor(az!)zM is in mutable_args but only Tensors or collections of Tensors can be mutatedÚ Ú"ztorch.zdtype repr z must start with 'torch.'z' has an unsupported default value type z;. Please file an issue on GitHub so we can prioritize this.Ú=r   z» in mutates_args were not found in the custom op's signature. mutates_args should contain the names of all args that the custom op mutates, or just the string 'unknown' if you don't know.Ú(ú, z) -> )/Ú__globals__ÚinspectÚ	signaturer1   r'   r   ÚtypeÚobjectr2   ÚAnyÚboolÚsetÚ	enumerateÚ
parametersÚitemsÚsupported_paramÚkindÚ	ParameterÚKEYWORD_ONLYr&   Ú
annotationÚemptyÚSUPPORTED_PARAM_TYPESr   r   Ú
class_nameÚtorchÚ_CÚScriptObjectÚhasattrr:   Útuple_to_listÚkeysÚAssertionErrorr   Ú
startswithÚlenÚaddÚdefaultr0   ÚintÚfloatr   r   Úreturn_annotationÚparse_returnÚjoin)r   Úmutates_argsr   ÚUNKNOWN_MUTATESÚparamsÚ	seen_argsÚsaw_kwarg_only_argÚidxÚnameÚparamr   Ú_Úschema_typeÚ	list_typeÚexample_type_strÚdefault_reprÚ
dtype_reprÚ	torch_dotÚmutates_args_not_seenrb   Úretr"   r   r    r!   r   r,   r-   s                        @@@@@@@r   Úinfer_schemarv      sV  þ€ ðT  €OØ#×/Ñ/€JØ€Iô ×
Ò
Ð.Ó
/€CõWð¬S÷ ñ ðÜ”5œœf™¤sÐ*Ñ+¨SÐ0Ñ1ðä	Œu”V—Z‘Z �_Ñ%¤tÐ+Ñ	,÷ðœU¤4¬¡<´Ð#4Ñ5ð ¼%ÄÇ
Á
ÌDÐ@PÑ:Q÷ ð ð €FÜ“€IØÐÜ'¨¯©×(<Ñ(<Ó(>×?Ñˆ‰]ˆdÜ˜u×%Ñ%ÙÐUÔVà�:‰:œ×*Ñ*×7Ñ7Ó7æ%Ø—‘˜cÔ"Ø%)Ð"à×Ñœw×0Ñ0×6Ñ6Ò6Ù�z $ Ð'DÐEÔFñ .¨e×.>Ñ.>Ó?ÑˆàˆØÔ"7Ó7Ü˜o×.Ñ.Ü+¨OÑ<×GÑG‘Ø ¤E§H¡H×$9Ñ$9Ó9ÙØ   ð 'Zð Zõô ˜¨×6Ñ6Ø#×.Ñ.´%Ò7ä)¨/Ó:�	Ø#)Ð àÔ 5Ó5Ø)6°y°kÀÐ'GÐ$ÙØ   Ð&<¸U×=MÑ=MÐ<Nð Orà'Ð(Ø+Ô,A×,FÑ,FÓ,HÐ+IÈðLõñ Ø   Ð&<¸U×=MÑ=MÐ<Nð O,Ü,A×,FÑ,FÓ,HÐ+IÈðLõô
 0°Ñ@ˆKàÑÜ Ð#AÀ$ÀÐ!HÓIÐIä�Ó¤Ò$ØÓ.Ü ðOóð ð ×%Ñ% h×/Ñ/Ø (¨¨¨R°¼CÀ»M¸OÐ0LÐ/MÐN�øØÓ!Ø×)Ñ)¨(×3Ñ3ÙØ   Ð&sÐtôð % S E¨¨K¼¸H»¸Ð,HÐ+IÐJˆKØ�‰�dÔØ�=‰=œG×-Ñ-×3Ñ3Ò3à�M‰M˜[˜M¨¨4¨&Ð1×2àˆLØ�}‰}Ñ$¬
°5·=±=Ä3ÌÌtÐBT×(UÑ(UÜ" 5§=¡=Ó1‘Ü˜EŸM™M¬C´·±Ð+>×?Ñ?Ø!" 5§=¡= /°Ð3‘Ü˜EŸM™M¬5¯;©;×7Ñ7Ü  §¡Ó/�
Ø$�	Ø!×,Ñ,¨Y×7Ñ7Ü(Ø% j¡^Ð3LÐMóð ð  *¬#¨i«.Ð*:Ð;‘áØ   Ð&MÌdÐSX×S`ÑS`ÓNaÐMbð cPð Qôð
 �M‰M˜[˜M¨¨4¨&°°,°Ð@×Añw @ðx Ó&Ü # LÓ 1°IÑ =ÐÜÐ$Ó%¨Ó)ÙØ(Ð)ð *Uð Vôñ ,¨C×,AÑ,AÓBÑÐ�qÜ
Ð(¨(Ó
3€CØÑØ�˜!˜DŸI™I fÓ-Ð.¨e°C°5Ð9Ð9Øˆt�y‰y˜Ó Ð!  s eÐ,Ð,r   Ú	base_typeÚcpp_typeÚ	list_baseÚoptional_base_listÚoptional_list_basec                 ó–  ^• U T4[         R                  U    T S34/nS[        [        [         R                  4   4S jnU(       a!  UR                  U4S jU" U 5       5       5        U(       a2  UR                  U4S jU" [         R                  U    5       5       5        U(       a!  UR                  U4S jU" U 5       5       5        U$ )NÚ?Útypc                 ó¶   • [         R                  U    [         R                  U    [        [        R
                  R                  U 45      [        [        U 45      4$ ©N)r2   ÚSequenceÚListr   ÚcollectionsÚabcÚlist)r~   s    r   Úderived_seq_typesÚ(derived_types.<locals>.derived_seq_typesè   sF   € ä�O‰O˜CÑ Ü�K‰K˜ÑÜœŸ™×1Ñ1°C°6Ó:Üœ ˜vÓ&ð	
ð 	
r   c              3   ó0   >#   • U  H  oT S 34v •  M     g7f)z[]N© ©Ú.0Úseq_typrx   s     €r   Ú	<genexpr>Ú derived_types.<locals>.<genexpr>ñ   s   øé € ð 
Ú6R¨7˜˜
 "�oÕ&Ò6Rùs   ƒc              3   ó2   >#   • U  H  nUT S 34v •  M     g7f)z?[]Nr‰   rŠ   s     €r   r�   rŽ   õ   s'   øé € ð 
ò I�ð ˜˜
 #Ð&Õ'âHùs   ƒc              3   óT   >#   • U  H  n[         R                  U   T S 34v •  M     g7f)z[]?N)r2   r   rŠ   s     €r   r�   rŽ   û   s-   øé € ð 
â7�ô �_‰_˜WÑ%¨(¨°3Ð'7Õ8Ú7ùs   ƒ%()r2   r   r   rE   Ú_SpecialFormÚextend)rw   rx   ry   rz   r{   Úresultr†   s    `     r   Úderived_typesr”   Û   sÃ   ø€ ð 
�HÐä	�‰˜Ñ	#¨ z° ^Ð4ðP€Fð
œu¤T¬6×+>Ñ+>Ð%>Ñ?ô 
ö Ø�‰ô 
Ù6GÈ	Ô6Ró
ô 	
ö Ø�‰ô 
ñ -¬V¯_©_¸YÑ-GÔHó
ô 	
ö
 Ø�‰ô 
á,¨YÔ7ó
ô 	
ð €Mr   c                  óÄ  • [         SSSS4[        SSSS4[        SSSS4[        SSSS4[        SSSS4[
        R                  SSSS4[        S	SSS4[        S
SSS4/n [        R                  R                  5       (       a5  SSKJn  U R                  [        R                   " ["        U5      SSSS45        / nU  H  nUR%                  ['        U6 5        M     [)        U5      $ )Nr   TFÚSymIntra   rH   r1   ÚScalarÚ
ScalarTypeÚDevicer   )Ú	GroupName)r   r`   ra   rH   r1   r	   ÚNumberr   r   rU   ÚdistributedÚis_availableÚ"torch.distributed.distributed_c10drš   r&   r2   ÚcastrE   r’   r”   Údict)Údatarš   r“   Úlines       r   Úget_supported_param_typesr£     sæ   € ô 
�˜4  uÐ-Ü	ˆh˜˜e TÐ*Ü	�˜˜u dÐ+Ü	ˆv�t˜U DÐ)Ü	ˆe�U˜E 5Ð)Ü	�‰�x  u¨eÐ4Ü	�˜e U¨EÐ2Ü	�˜5 %¨Ð/ð
R€Dô ×Ñ×%Ñ%×'Ñ'Ý@à�‰”V—[’[¤ yÓ1°5¸%ÀÈÐNÔOà€FÛˆØ�‰”m TÐ*Ö+ñ ä�‹<Ðr   r   zTensor[]r–   ra   rH   r—   c                 óô  • U c  gU [         R                  R                  L a  U" S5        [        R                  " U 5      nU[
        La&  U [        ;  a  U" SU  S[         S35        [        U    $ [        R                  " U 5      nU H"  nU[        ;  d  M  U" SU  S[         S35        M$     SR                  U Vs/ s H  n[        U   PM     sn5      n[        U5      S:X  a  SU-   S	-   nSU-   S	-   $ s  snf )
Nz()z7No return type annotation was provided. Please add one.zReturn has unsupported type r<   r;   rA   r   r@   r   )
rC   rO   rR   r2   r3   r'   ÚSUPPORTED_RETURN_TYPESr4   rd   r]   )rQ   r   r5   r6   ÚargÚ	output_tys         r   rc   rc   %  s  € ØÑØà”W×&Ñ&×,Ñ,Ò,ÙÐJÔKä×Ò˜zÓ*€FØ”UÒØÔ3Ó3ÙØ.¨z¨lð ;(Ü(>Ð'?¸qðBôô
 & jÑ1Ð1ä�?Š?˜:Ó&€DÛˆØÔ,Õ,ÙØ.¨z¨lð ;(Ü(>Ð'?¸qðBöñ ð —	‘	Á$ÓGÂ$¸3Ô1°#Ô6Á$ÑGÓH€Iô ˆ4ƒy�Aƒ~Ø˜)‘O cÑ)ˆ	Ø�‰?˜SÑ Ð ùò Hs   Â<C5rl   c                 ó„   • U R                   [        R                  R                  [        R                  R                  4;   $ r€   )rN   rC   rO   ÚPOSITIONAL_OR_KEYWORDrP   )rl   s    r   rM   rM   H  s6   € Ø�:‰:Ü×Ñ×/Ñ/Ü×Ñ×&Ñ&ðñ ð r   Ú
tuple_typec                 ó<  • [        U SS5      nU [        R                  L d  U [        L d	  US:X  d  Uc  [        $ [        U5      S:X  a  [        US      $ [        U5      S:X  a  US   [        L a  [        US      $ [        [        R                  [        U5            $ )zu
Convert `tuple_type` into a list type with the same type arguments. Assumes that `tuple_type` is typing.Tuple type.
Ú__args__Nr‰   r   r   é   )Úgetattrr2   ÚTupler'   r…   r]   ÚEllipsisr   )rª   Ú	type_argss     r   rY   rY   O  s–   € ô ˜
 J°Ó5€Ið 	”f—l‘lÒ"ØœÒØ˜‹?ØÑô ˆÜ	ˆY‹˜1Ó	ä�I˜a‘LÑ!Ð!Ü	ˆY‹˜1Ó	 ¨1¡´Ò!9Ü�I˜a‘LÑ!Ð!ä”F—L‘L¤ yÓ!1Ñ2Ñ3Ð3r   )%rƒ   rC   r2   r	   r   r   r   rU   r   r   r   Útorch.utils._exposed_inr
   Úopaque_objectr   r   Ú_TestTensorÚCallabler1   rv   rE   r‘   rH   r”   r£   r‚   r…   r`   ra   r›   r¥   rc   rS   rO   rM   r'   rY   r‰   r   r   Ú<module>r¶      sB  ðã Û Û Ý ß "ã ß .Ó .Ý .ç 8ð
 �l‰l€ñ ˆOÓð "òC-ØŸ™ðC-ð
 �c‰]ðC-ð 	ôC-ó ðC-ðL$Ø�T˜6×.Ñ.Ð.Ñ/ð$àð$ð ð$ð ð	$ð
 ô$òNð2 ˆHØ
‡K�K�Ñ˜Øˆ�L�*ØˆØ	ˆ7Øˆ&Ø	‡L�L�(ðÐ ò!ñ@ 2Ó3Ð ð˜7×,Ñ,ð °ô ð4˜d 5™kð 4¨d°4©jõ 4r   