Ë
    ÄÓ^j�  ã                  óÜ   — U d dl mZ d dlZd dlZ ej                  e«      Zi Zded<   	 	 	 	 	 	 dd„Z		 	 	 	 dd„Z
dd„Zdd„Z	 	 	 	 	 	 dd	„Z	 	 	 	 	 	 dd
„Zdd„Zdd„Z	 	 	 	 	 	 dd„Zdd„Zy)é    )ÚannotationsNz2dict[torch._ops.OpOverload, torch._ops.OpOverload]Ú_manual_out_variant_registryc                ó   — |t         | <   y)z0Register a functional op -> out variant mapping.N)r   )Úfunctional_opÚout_ops     úf/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/_library/_out_variant.pyÚregister_out_variantr	      s   € ð
 39Ô  Ò/ó    c                ó,   — t         j                  | «      S )z;Return the manually registered out variant for op, or None.)r   Úget)Úops    r   Úlookup_manual_out_variantr      s   € ô (×+Ñ+¨BÓ/Ð/r
   c                óœ   — | j                   j                  d«      d   }|j                  d«      ryt        d„ | j                  D «       «       S )zd
    A schema is functional if no argument is written to and the name doesn't
    end with '_'.
    ú::éÿÿÿÿÚ_Fc              3  ó4   K  — | ]  }|j                   –— Œ y ­w©N)Úis_write)Ú.0Úargs     r   ú	<genexpr>z!_is_functional.<locals>.<genexpr>'   s   è ø€ Ò< C�3—<•<Ñ<ùs   ‚)ÚnameÚsplitÚendswithÚanyÚ	arguments)ÚschemaÚop_names     r   Ú_is_functionalr       sH   € ð
 �k‰k×Ñ Ó% bÑ)€GØ×Ñ˜ÔØÜÑ<¨6×+;Ñ+;Ô<Ó<Ð<Ð<r
   c                óN   — | j                   d uxr | j                   j                  S r   )Ú
alias_infor   )r   s    r   Ú_is_mutable_argr#   *   s    € Ø�>‰> Ð%ÒA¨#¯.©.×*AÑ*AÐAr
   c                óÊ  — | j                   D �cg c]  }t        |«      rŒ|‘Œ }}|j                   D �cg c]  }t        |«      rŒ|‘Œ }}t        |«      t        |«      k7  ryt        ||«      D ]h  \  }}|j                  |j                  k7  r yt        |j                  «      t        |j                  «      k7  r y|j                  |j                  k7  sŒh y yc c}w c c}w )zOCompare two schemas by their non-mutable arguments (name, type, default value).FT)r   r#   ÚlenÚzipr   ÚstrÚtypeÚdefault_value)Úschema_aÚschema_br   Únon_mutable_args_aÚnon_mutable_args_bÚaÚbs          r   Ú_signatures_matchr0   .   sÊ   € ð
 *2×);Ñ);ÖX #Ä?ÐSVÕCWš#ÐXÐÐXØ)1×);Ñ);ÖX #Ä?ÐSVÕCWš#ÐXÐÐXÜ
ÐÓ¤#Ð&8Ó"9Ò9ØÜÐ&Ð(:Ó;ò ‰ˆˆ1Ø�6‰6�Q—V‘VÒÙÜˆq�v‰v‹;œ#˜aŸf™f›+Ò%ÙØ�?‰?˜aŸo™oÓ-Ùðð ùò YùÚXs   �C C´C ÁC c                óH  — t        | j                  «      dk(  ryt        | j                  «      t        |«      k7  ryt        | j                  |«      D ]N  \  }}|j                  �|j                  € y|j                  j                  |j                  j                  k7  sŒN y y)zFOut variant must return either nothing or the mutable args themselves.r   TF)r%   Úreturnsr&   r"   Ú
before_set)r   Úmutable_argsÚretr   s       r   Ú_has_valid_out_variant_returnsr6   A   s‹   € ô
 ˆ6�>‰>Ó˜aÒØä
ˆ6�>‰>Óœc ,Ó/Ò/Øô ˜Ÿ™¨Ó5ò ‰ˆˆSØ�>‰>Ð! S§^¡^Ð%;ÙØ�>‰>×$Ñ$¨¯©×(AÑ(AÓAÙð	ð
 r
   c                ó„   — | j                   }|j                  D �cg c]  }t        |«      sŒ|j                  ‘Œ c}S c c}w )z5Get the names of out arguments for an out variant op.)Ú_schemar   r#   r   )r   r   r   s      r   Úget_out_arg_namesr9   U   s0   € à�^‰^€FØ &× 0Ñ 0ÖI˜´OÀCÕ4HˆC�H‹HÒIÐIùÒIs   ›=¬=c                ór  — | j                   }t        |«      st        d| › d|› �«      ‚| j                  }|j                  j                  d«      d   }t        t        t        j                  |«      |«      }|j                  «       D ]©  }t        j                  j                  |j                  vrŒ*|j                   }t        ||«      sŒC|j                  D �cg c]  }t        |«      sŒ|‘Œ }}t!        |«      t!        |j"                  «      k7  rŒŠt%        ||«      st        d|› d|› �«      ‚|c S  yc c}w )zU
    Given a functional operator overload, return its corresponding out variant.
    z#Failed to find out variant for op 'z&' as its schema is not functional. 
  r   é   zOut variant z^ has invalid returns. Expected either no returns or returns that alias the mutable args, got: N)r8   r    ÚRuntimeErrorÚ	namespacer   r   ÚgetattrÚtorchÚopsÚop_overloadsÚTagÚoutÚtagsr0   r   r#   r%   r2   r6   )	r   r   r=   r   Útorch_packetÚ	candidateÚcandidate_schemar   r4   s	            r   Úto_out_variantrH   [   sC  € ð �Z‰Z€Fä˜&Ô!ÜØ1°"°ð 6Ø�ðó
ð 	
ð —‘€IØ�k‰k×Ñ Ó% aÑ(€GÜœ7¤5§9¡9¨iÓ8¸'ÓB€Lð "×.Ñ.Ó0ò ˆ	ä�9‰9�=‰= 	§¡Ñ.Øà$×,Ñ,Ðä  Ð)9Ô:Øð ,×5Ñ5ö
Ø¼ÈÕ9MŠCð
ˆð 
ô ˆ|Ó¤ F§N¡NÓ 3Ò3Øä-Ð.>ÀÔMÜØ˜y˜kð *à(Ð)ð+óð ð Òð1ð4 ùò
s   ÃD4Ã)D4c           	     ó’   — t        | «      }|€ t        | «      }t        d| › d|xs d› �«      ‚||k7  rt        d| › d|› d|› d�«      ‚y)	z•
    Checks that to_out_variant returns the expected out variant for a functional op.
    Raises AssertionError if the out variant is not valid.
    Nz#We did not find an out variant for at  . Some common mistakes include:
  1. The out variant is missing the torch.Tag.out tag.
  2. The out variant is not an overload of the original op (e.g., 'op.out' or 'op.overload_out') 
  3. The out variant's input arguments does not match the functional op's signature (excluding the mutable args).
  4. The original operator is not functional.
Overloads tagged with out:
z  (none)zto_out_variant(z) returned z, but expected z8. The out variant name does not match the functional op.)rH   Ú_get_out_variants_infoÚAssertionError)r   Úexpected_out_opr   Útagged_infos       r   Úcheck_out_variantrN   Š   sŠ   € ô ˜MÓ*€FØ€~Ü,¨]Ó;ˆÜØ1°-°ð A+ð Ò(˜jÐ)ð+ó
ð 	
ð �Ò ÜØ˜m˜_¨K¸°xð @Ø+Ð,ð -EðFó
ð 	
ð !r
   c                óª  — | j                   }| j                  j                  j                  d«      d   }t	        t	        t
        j                  |«      |«      }g }|j                  «       D ]V  }t	        ||«      }t
        j                  j                  |j                  v sŒ6|j                  d|› d|j                  › �«       ŒX dj                  |«      S )zBCollect information about overloads tagged with out for debugging.r   r;   z  - z: ú
)r=   r8   r   r   r>   r?   r@   Ú	overloadsrB   rC   rD   ÚappendÚjoin)r   r=   r   rE   Úoverloads_infoÚoverload_namerF   s          r   rJ   rJ   ¥   s·   € à×'Ñ'€IØ×#Ñ#×(Ñ(×.Ñ.¨tÓ4°QÑ7€GÜœ7¤5§9¡9¨iÓ8¸'ÓB€Là "€NØ%×/Ñ/Ó1ò OˆÜ˜L¨-Ó8ˆ	ä�9‰9�=‰=˜IŸN™NÒ*Ø×!Ñ! D¨¨°r¸)×:KÑ:KÐ9LÐ"MÕNð	Oð �9‰9�^Ó$Ð$r
   )r   útorch._ops.OpOverloadr   rV   ÚreturnÚNone)r   rV   rW   ztorch._ops.OpOverload | None)r   útorch._C.FunctionSchemarW   Úbool)r   ztorch._C.ArgumentrW   rZ   )r*   rY   r+   rY   rW   rZ   )r   rY   r4   zlist[torch._C.Argument]rW   rZ   )r   rV   rW   z	list[str])r   rV   rL   rV   rW   rX   )rW   r'   )Ú
__future__r   Úloggingr?   Ú	getLoggerÚ__name__Úlogr   Ú__annotations__r	   r   r    r#   r0   r6   r9   rH   rN   rJ   © r
   r   ú<module>rb      sÝ   ðÞ "ã ã ð €g×Ñ˜Ó!€ð
 TVÐ ÐPÓ Uð9Ø(ð9à!ð9ð 
ó9ð0Øð0à!ó0ó=óBðØ%ðà%ðð 
óð&Ø#ðà)ðð 
óó(Jó,ð^
Ø(ð
Ø;Pð
à	ó
ô6%r
   