ó
    "Eñi=.  ã            !       ó  • S 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	  Sr
SrSrS	rS
rSr\R                    " S S5      5       r\R$                  R'                  SSSS9SSSSS.S\\\R(                        S\S\S\\\\R.                  4      S\\   S\\   S\\\\4      S\\   S\\   S\\   S\\   S\\   S \S!\\   S"\R(                  4S# jj5       r\R6                  SSSSS.S\\R(                     S\S\S\\\\R.                  4      S\\   S\\   S\\\\4      S\\   S\\   S\\   S\\   S\\   S \S!\\   S"\R(                  4S$ jj5       r\R$                  R'                  S%SS&S9SSSSS.S\\\R(                        S\S'\\   S(\\\\\R.                  4         S\\   S\\   S\\\\4      S\\   S\\   S\\   S\\   S\\   S \S!\\   S"\\R(                     4S) jj5       r\R6                  SSSSS.S\\R(                     S\S'\\   S(\\\\\R.                  4         S\\   S\\   S\\\\4      S\\   S\\   S\\   S\\   S\\   S \S!\\   S"\\R(                     4S* jj5       rg)+a4  Implementation of symbolic FX ops to represent arbitrary ONNX ops.

This module provides a way to create symbolic FX operators that can represent
arbitrary ONNX operators.

The operators are called "symbolic" because they don't do any actual computation
but instead serve as placeholders in the computation graph.

Each implementation contains two parts: A "real" implementation that produce all
zeros based on the input shape and dtype, and a "fake" implementation that does more
or less the same thing but is required by the `torch.library.custom_op` interface.
é    N)ÚSequence)ÚOptionalÚUnion)Ú_dtype_mappingsÚiÚfÚsÚisÚfsÚssc                   ó  • \ rS rSr% Sr\\   \S'   \\   \S'   \\\	\	4      \S'   \\	   \S'   \\
   \S'   \\   \S'   \S	\\\\	\
\\\\	   \\
   \\   \\   4   4   S
S 4S j5       rS
\\\\	\
\\\	   \\
   \\   4   4   4S jrSrg)ÚEncodedAttrsé   aÃ  Class to encode attributes from dictionary into lists of FX compatible attributes.

Since FX does not support dictionaries, we need to encode the attributes into
lists. This class provides a way to encode and decode the attributes.

Attributes:
    attr_keys: List of attribute keys.
    attr_types: List of attribute types. Values can be "i" (int), "f" (float),
        "s" (string), "is" (int sequence), "fs" (float sequence), or "ss" (string sequence).
    attr_pos: List of tuples representing the start and end positions of each
        attribute in the corresponding list.
    attr_ints: List of integer attributes.
    attr_floats: List of float attributes.
    attr_strs: List of string attributes.
Ú	attr_keysÚ
attr_typesÚattr_posÚ	attr_intsÚattr_floatsÚ	attr_strsÚattrsÚreturnc           	      ó

  • U " / / / / / / S9nUR                  5        GH  u  p4UR                  R                  U5        [        U[        5      (       ap  [        UR                  5      nUR                  R                  U5        UR                  R                  XUS-   45        UR                  R                  [        5        M¦  [        U[        5      (       aq  [        UR                  5      nUR                  R                  U5        UR                  R                  XUS-   45        UR                  R                  [        5        GM,  [        U[        5      (       aq  [        UR                  5      nUR                  R                  U5        UR                  R                  XUS-   45        UR                  R                  [        5        GM²  [        U[         5      (       Ga.  [        U5      S:X  a  [#        SU 35      e[%        S U 5       5      (       a”  [        UR                  5      nUR                  R'                  U Vs/ s H  n[        U5      PM     sn5        UR                  R                  XU[        U5      -   45        UR                  R                  [(        5        GM�  [        US   [        5      (       a”  [        UR                  5      nUR                  R'                  U Vs/ s H  n[	        U5      PM     sn5        UR                  R                  XU[        U5      -   45        UR                  R                  [*        5        GM<  [        US   [        5      (       a”  [        UR                  5      nUR                  R'                  U Vs/ s H  n[        U5      PM     sn5        UR                  R                  XU[        U5      -   45        UR                  R                  [,        5        GMè  [#        SU 35      e[#        SU S[/        U5       35      e   [        UR                  5      [        UR                  5      :w  a7  [1        S	[        UR                  5       S
[        UR                  5       35      e[        UR                  5      [        UR                  5      :w  a7  [1        S[        UR                  5       S
[        UR                  5       35      eU$ s  snf s  snf s  snf )N)r   r   r   r   r   r   é   r   zEmpty sequence for attribute c              3   óB   #   • U  H  n[        U[        5      v •  M     g 7f)N)Ú
isinstanceÚfloat)Ú.0Úelems     ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/onnx/ops/_symbolic_impl.pyÚ	<genexpr>Ú)EncodedAttrs.from_dict.<locals>.<genexpr>e   s   é € Ð=º1°4”z $¬×.Ð.º1ùs   ‚z(Unsupported sequence type for attribute zUnsupported attribute type for z: z5Mismatch between number of attribute keys and types: z != z9Mismatch between number of attribute keys and positions: )Úitemsr   Úappendr   ÚintÚlenr   r   r   Ú	_INT_TYPEr   r   Ú_FLOAT_TYPEÚstrr   Ú_STRING_TYPEr   Ú
ValueErrorÚanyÚextendÚ_FLOAT_SEQ_TYPEÚ_INT_SEQ_TYPEÚ_STRING_SEQ_TYPEÚtypeÚAssertionError)Úclsr   ÚencodedÚkÚvÚ	start_posr   s          r   Ú	from_dictÚEncodedAttrs.from_dict8   s  € ñ" ØØØØØØñ
ˆð —K‘K—M‰DˆAØ×Ñ×$Ñ$ QÔ'Ü˜!œS×!Ñ!Ü × 1Ñ 1Ó2�	Ø×!Ñ!×(Ñ(¨Ô+Ø× Ñ ×'Ñ'¨À±MÐ(BÔCØ×"Ñ"×)Ñ)¬)Ö4Ü˜Aœu×%Ñ%Ü × 3Ñ 3Ó4�	Ø×#Ñ#×*Ñ*¨1Ô-Ø× Ñ ×'Ñ'¨À±MÐ(BÔCØ×"Ñ"×)Ñ)¬+×6Ü˜Aœs×#Ñ#Ü × 1Ñ 1Ó2�	Ø×!Ñ!×(Ñ(¨Ô+Ø× Ñ ×'Ñ'¨À±MÐ(BÔCØ×"Ñ"×)Ñ)¬,×7Ü˜Aœx×(Ò(Ü�q“6˜Q“;Ü$Ð'DÀQÀCÐ%HÓIÐIÜÑ=¹1Ó=×=Ñ=Ü # G×$7Ñ$7Ó 8�IØ×'Ñ'×.Ñ.ÉÓ/JÊÀ´°d¶ÉÑ/JÔKØ×$Ñ$×+Ñ+¨YÄCÈÃFÑ8JÐ,KÔLØ×&Ñ&×-Ñ-¬o×>Ü  !¡¤c×*Ñ*Ü # G×$5Ñ$5Ó 6�IØ×%Ñ%×,Ñ,ÁAÓ-FÂA¸D¬c°$®iÁAÑ-FÔGØ×$Ñ$×+Ñ+¨YÄCÈÃFÑ8JÐ,KÔLØ×&Ñ&×-Ñ-¬m×<Ü  !¡¤c×*Ñ*Ü # G×$5Ñ$5Ó 6�IØ×%Ñ%×,Ñ,ÁAÓ-FÂA¸D¬c°$®iÁAÑ-FÔGØ×$Ñ$×+Ñ+¨YÄCÈÃFÑ8JÐ,KÔLØ×&Ñ&×-Ñ-Ô.>×?ä$Ð'OÐPQÈsÐ%SÓTÐTä Ð#BÀ1À#ÀRÌÈQËÀyÐ!QÓRÐRñM "ôN ˆw× Ñ Ó!¤S¨×);Ñ);Ó%<Ó<Ü ØGÌÈG×L]ÑL]ÓH^ÐG_Ð_cÔdgÐho×hzÑhzÓd{Ðc|Ð}óð ô ˆw× Ñ Ó!¤S¨×)9Ñ)9Ó%:Ó:Ü ØKÌCÐPW×PaÑPaÓLbÐKcÐcgÔhkÐls×l|Ñl|Óh}Ðg~Ðóð ð ˆùò3 0Kùò
 .Gùò
 .Gs   ÉS6
Ë2S;
ÎT 
c                 óþ  • 0 n[        U R                  5       GH`  u  p#U R                  U   nU[        :X  a#  U R                  U R
                  U   S      X'   MB  U[        :X  a#  U R                  U R
                  U   S      X'   Mo  U[        :X  a#  U R                  U R
                  U   S      X'   Mœ  U[        :X  a3  U R                  U R
                  U   S   U R
                  U   S    X'   MÙ  U[        :X  a4  U R                  U R
                  U   S   U R
                  U   S    X'   GM  U[        :X  a4  U R                  U R
                  U   S   U R
                  U   S    X'   GMU  [        SU 35      e   U$ )zNConvert the encoded attributes back to a dictionary for creating an ONNX node.r   r   zUnsupported attribute type: )Ú	enumerater   r   r&   r   r   r'   r   r)   r   r-   r.   r/   r*   )Úselfr   r   ÚkeyÚ	attr_types        r   Úto_dictÚEncodedAttrs.to_dict‚   sj  € ð0 ð 	ô   §¡×/‰FˆAØŸ™¨Ñ*ˆIØœIÓ%Ø!Ÿ^™^¨D¯M©M¸!Ñ,<¸QÑ,?Ñ@�“
ØœkÓ)Ø!×-Ñ-¨d¯m©m¸AÑ.>¸qÑ.AÑB�“
ØœlÓ*Ø!Ÿ^™^¨D¯M©M¸!Ñ,<¸QÑ,?Ñ@�“
ØœoÓ-Ø!×-Ñ-¨d¯m©m¸AÑ.>¸qÑ.AÀDÇMÁMÐRSÑDTÐUVÑDWÐX�“
ØœmÓ+Ø!Ÿ^™^¨D¯M©M¸!Ñ,<¸QÑ,?À$Ç-Á-ÐPQÑBRÐSTÑBUÐV�”
ØÔ.Ó.Ø!Ÿ^™^¨D¯M©M¸!Ñ,<¸QÑ,?À$Ç-Á-ÐPQÑBRÐSTÑBUÐV�”
ä Ð#?À	¸{Ð!KÓLÐLñ 0ð  ˆó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úlistr(   Ú__annotations__Útupler$   r   ÚclassmethodÚdictr   Úboolr   r7   r>   Ú__static_attributes__rA   r@   r   r   r      sþ   ‡ ñð  �C‰yÓØ�S‘	ÓØ�5˜˜c˜‘?Ñ#Ó#Ø�C‰yÓØ�e‘ÓØ�C‰yÓàðGàØØØØØØØ˜‘Ø˜‘Ø˜‘Ø˜‘ð ñ	ð
ñ
ðGð 
óGó ðGðR)à	ØØØØØØ�‰IØ�‰KØ�‰Iðñ	
ð	ñ

÷)r@   r   zonnx_symbolic::_symbolicrA   a  (Tensor?[] inputs, str op_type, int onnx_dtype, *, SymInt[] shape, str[] attr_keys, str[] attr_types, int[][] attr_pos, int[] attr_ints, float[] attr_floats, str[] attr_strs, str[] metadata_props_keys, str[] metadata_props_values, str domain='', int? version=None) -> Tensor)Úmutates_argsÚschemaÚ )Úmetadata_props_keysÚmetadata_props_valuesÚdomainÚversionÚinputsÚop_typeÚ
onnx_dtypeÚshaper   r   r   r   r   r   rQ   rR   rS   rT   r   c                ó¨   ^• [         R                  " T[        R                  ;   U4S j5        [         R                  " U[        R                  T   S9$ )Nc                  ó\   >• T  S[        [        R                  R                  5       5       3$ ©Nz3 is invalid as an ONNX data type. Valid values are ©rG   r   ÚONNX_DTYPE_TO_TORCH_DTYPEÚkeys©rW   s   €r   Ú<lambda>Ú_symbolic.<locals>.<lambda>Ì   óG   ø€ �:�,ÐQÔRVÔWf÷  XAñ  XA÷  XFñ  XFó  XHó  SIð  RJñ  Kr@   ©Údtype©ÚtorchÚ_checkr   r]   Úzeros©rU   rV   rW   rX   r   r   r   r   r   r   rQ   rR   rS   rT   s     `           r   Ú	_symbolicrj   ®   sH   ø€ ô8 
‡L‚LØ”o×?Ñ?Ñ?ô 	Kôô �;Š;Ø”_×>Ñ>¸zÑJñð r@   c                ó¨   ^• [         R                  " T[        R                  ;   U4S j5        [         R                  " U[        R                  T   S9$ )Nc                  ó\   >• T  S[        [        R                  R                  5       5       3$ r[   r\   r_   s   €r   r`   Ú_.<locals>.<lambda>ç   rb   r@   rc   re   ri   s     `           r   Ú_rn   Ó   sH   ø€ ô$ 
‡L‚LØ”o×?Ñ?Ñ?ô 	Kôô �;Š;Ø”_×>Ñ>¸zÑJñð r@   z"onnx_symbolic::_symbolic_multi_outa  (Tensor?[] inputs, str op_type, int[] onnx_dtypes, *, SymInt[][] shapes, str[] attr_keys, str[] attr_types, int[][] attr_pos, int[] attr_ints, float[] attr_floats, str[] attr_strs, str[] metadata_props_keys, str[] metadata_props_values, str domain='', int? version=None) -> Tensor[]Úonnx_dtypesÚshapesc                ó`  ^^^• / n[         R                  " [        T5      [        T5      :H  UU4S j5        [        TT5       Hg  u  nm[         R                  " T[        R
                  ;   U4S j5        UR                  [         R                  " U[        R
                  T   S95        Mi     U$ )Nc                  ó:   >• S[        T5       S[        T 5       S3$ ©NzNumber of shapes (z$) must match number of ONNX dtypes (Ú)©r%   ©ro   rp   s   €€r   r`   Ú%_symbolic_multi_out.<locals>.<lambda>  ó#   ø€ Ð$¤S¨£[ MÐ1UÔVYÐZeÓVfÐUgÐghÑir@   c                  ó\   >• T  S[        [        R                  R                  5       5       3$ r[   r\   r_   s   €r   r`   rw     óG   ø€ �z�lÐ"UÔVZÔ[j÷  \Eñ  \E÷  \Jñ  \Jó  \Ló  WMð  VNñ  Or@   rc   ©rf   rg   r%   Úzipr   r]   r#   rh   ©rU   rV   ro   rp   r   r   r   r   r   r   rQ   rR   rS   rT   ÚoutputsrX   rW   s     ``            @r   Ú_symbolic_multi_outr   ð   s“   ú€ ð8 €GÜ	‡L‚LÜˆF‹”s˜;Ó'Ñ'Ýiôô ! ¨Ö5ÑˆˆzÜ�ŠØœ/×CÑCÑCô Oô	
ð 	�‰Ü�KŠKØœ_×FÑFÀzÑRñö	
ñ 6ð €Nr@   c                ó`  ^^^• / n[         R                  " [        T5      [        T5      :H  UU4S j5        [        TT5       Hg  u  nm[         R                  " T[        R
                  ;   U4S j5        UR                  [         R                  " U[        R
                  T   S95        Mi     U$ )Nc                  ó:   >• S[        T5       S[        T 5       S3$ rs   ru   rv   s   €€r   r`   rm   3  rx   r@   c                  ó\   >• T  S[        [        R                  R                  5       5       3$ r[   r\   r_   s   €r   r`   rm   8  rz   r@   rc   r{   r}   s     ``            @r   rn   rn     s“   ú€ ð$ €GÜ	‡L‚LÜˆF‹”s˜;Ó'Ñ'Ýiôô ! ¨Ö5ÑˆˆzÜ�ŠØœ/×CÑCÑCô Oô	
ð 	�‰Ü�KŠKØœ_×FÑFÀzÑRñö	
ñ 6ð €Nr@   )rF   ÚdataclassesÚcollections.abcr   Útypingr   r   rf   Útorch.onnx.opsr   r&   r'   r)   r.   r-   r/   Ú	dataclassr   ÚlibraryÚ	custom_opÚTensorr(   r$   ÚSymIntrI   r   rj   Úregister_fakern   rG   r   rA   r@   r   Ú<module>r�      sÔ  ðñó Ý $ß "ã Ý *ð €	Ø€Ø€Ø€Ø€ØÐ ð ×Ñ÷Kð Kó ðKð\ ‡�×ÑØØð	ð	 ð 
ð. *,Ø+-ØØ!òØ�X˜eŸl™lÑ+Ñ,ðàðð ðð
 �E˜#˜uŸ|™|Ð+Ñ,Ñ-ðð ˜‰}ðð ˜‘ðð �u˜S #˜X‘Ñ'ðð ˜‰}ðð ˜%‘ðð ˜‰}ðð " #™ðð $ C™=ðð ðð �c‰]ðð  ‡\�\ô!ó
ðð4 ×Ñð *,Ø+-ØØ!òØ�U—\‘\Ñ"ðàðð ðð
 �E˜#˜uŸ|™|Ð+Ñ,Ñ-ðð ˜‰}ðð ˜‘ðð �u˜S #˜X‘Ñ'ðð ˜‰}ðð ˜%‘ðð ˜‰}ðð " #™ðð $ C™=ðð ðð �c‰]ðð  ‡\�\ô!ó ðð8 ‡�×ÑØ(Øð	ð	 ð 
ð. *,Ø+-ØØ!ò Ø�X˜eŸl™lÑ+Ñ,ð àð ð ˜#‘ð ð
 �X˜e C¨¯©Ð$5Ñ6Ñ7Ñ8ð ð ˜‰}ð ð ˜‘ð ð �u˜S #˜X‘Ñ'ð ð ˜‰}ð ð ˜%‘ð ð ˜‰}ð ð " #™ð ð $ C™=ð ð ð ð �c‰]ð ð  
ˆ%�,‰,Ñô! ó
ð ðF ×"Ñ"ð *,Ø+-ØØ!ò"Ø�U—\‘\Ñ"ð"àð"ð ˜#‘ð"ð
 �X˜e C¨¯©Ð$5Ñ6Ñ7Ñ8ð"ð ˜‰}ð"ð ˜‘ð"ð �u˜S #˜X‘Ñ'ð"ð ˜‰}ð"ð ˜%‘ð"ð ˜‰}ð"ð " #™ð"ð $ C™=ð"ð ð"ð �c‰]ð"ð  
ˆ%�,‰,Ñô!"ó #ñ"r@   