+
    ˜°³j/J  ã                   ój  a € Ru tJ0 t R t^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^RIHt ]P&                  t]P(                  tRvt] ^ k R	s. s] ^k ]P0                  ! 4       t]P4                  ! 4       t]! 4       s]! ]P<                  R
4      '       d   ]P<                  P>                  t MR R lt ]! ]P<                  R4      '       d   ]P<                  PB                  t"MR R lt"R t#R t$R t%R R lt&R R lt' ! R R](4      t)R R lt*R R lt+RwR R llt,R R  lt-R! R" lt.RwR# R$ llt/RwR% R& llt0RxR' R( llt1R) R* lt2R+ R, lt3RyR- R. llt4RwR/ R0 llt5R1 R2 lt6R3 R4 lt7R5 R6 lt8RwR7 R8 llt9 ! R9 R:4      t: ! R; R<4      t;R= t<R> R? lt=RzR@ RA llt>RB RC lt?RzRD RE llt@RF RG ltARH RI ltBRJ RK ltCRL RM ltDRN RO ltERP RQ ltF^RRIG5 ^RRIH5 . RSNRTNRUNRVNRWNRXNRYNRZNR[NR\NR]NR^NR_NR`NRaNRbNRcNRdNReNRfNRgNR:NRhNRiNRjNRkNRlNRmNRnNRoNRpNRqNRrNRsNRtNtIR# ){zH
This package enables an interface for accessing MTIA backend in python
N)ÚCallable©ÚAny)ÚTensor)Ú	is_fbcodeÚis_prod)Ú_LazySeedTracker©ÚDevice)Ú_get_device_indexFÚ_mtia_exchangeDevicec                ó0   € V ^8„  d   QhR\         R\         /# ©é   ÚdeviceÚreturn©Úint)Úformats   "ÚT/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/mtia/__init__.pyÚ__annotate__r   )   s   € ÷ Hñ H¤ð H¬ñ Hó    c                 ó*   € V ^ 8  d   R# \        R4      h©é    z)PyTorch was compiled without MTIA supportéÿÿÿÿ©ÚRuntimeError©r   s   &r   Ú_exchange_devicer   )   ó   € Ø�AŒ:ØˆIÜÐFÓGÐGr   Ú_mtia_maybeExchangeDevicec                ó0   € V ^8„  d   QhR\         R\         /# r   r   )r   s   "r   r   r   3   s   € ÷ Hñ H¤sð H¬sñ Hr   c                 ó*   € V ^ 8  d   R# \        R4      hr   r   r   s   &r   Ú_maybe_exchange_devicer$   3   r    r   c                  ó   € \        4        R # ©N)Ú
_lazy_init© r   r   Úinitr)   9   s   € Ü†Lr   c                 ó<   € \         ;'       d    \        4       '       * # )z9Return whether PyTorch's MTIA state has been initialized.)Ú_initializedÚ_is_in_bad_forkr(   r   r   Úis_initializedr-   =   s   € ä×1Ð1¤Ó 1Ô1Ð1r   c                 óú  € \         ;_uu_ 4        \        4       '       d   V ! 4       uuR R R 4       # VP                  RR4      '       d+   \        P	                  V \
        P                  ! 4       4       MlVP                  RR4      '       d+   \        P                  V \
        P                  ! 4       4       M*\        P                  V \
        P                  ! 4       34       R R R 4       R #   + '       g   i     R # ; i)NÚseed_allFÚseed)
Ú_initialization_lockr-   ÚgetÚ_lazy_seed_trackerÚqueue_seed_allÚ	tracebackÚformat_stackÚ
queue_seedÚ_queued_callsÚappend)ÚcallableÚkwargss   &,r   Ú
_lazy_callr<   B   sŸ   € ß	Ö	Ü×ÒÙ“:÷ 
Ò	ð
 �z‰z˜* e×,Ò,Ü"×1Ñ1°(¼I×<RÒ<RÓ<TÕUØ—‘˜F E×*Ò*Ü"×-Ñ-¨h¼	×8NÒ8NÓ8PÕQä×$Ñ$ h´	×0FÒ0FÓ0HÐ%IÔJ÷ 
×	×	Ò	ús   �C)±C)Á	AC)ÂAC)Ã)C:	c                ó$   € V ^8„  d   QhR\         /# ©r   r   ©Úbool)r   s   "r   r   r   P   s   € ÷ (ñ (œñ (r   c                  ó>   € \         P                  P                  4       # r&   )ÚtorchÚ_CÚ_mtia_isInBadForkr(   r   r   r,   r,   P   s   € Ü�8‰8×%Ñ%Ó'Ð'r   c                ó   € V ^8„  d   QhRR/# ©r   r   Nr(   )r   s   "r   r   r   T   s   € ÷ ;ñ ;�Dñ ;r   c            
      óˆ  € \        4       '       g   \        \        R 4      '       d   R# \        ;_uu_ 4        \        4       '       d    RRR4       R# \	        4       '       d   \        R4      h\        4       '       g   \        R4      h\        4       '       d(   \        4       '       d    ^ RI
Hp  V P                  4        \        P                  P!                  4        R\        n        \$        P'                  R \(        P+                  4        4       4        \$         F  w  r V! 4        K  	  \5        \        R 4       RsRRR4       R#   \         d     L˜i ; i  \,         d2   pR\/        T4       RR	P1                  T4       2p\3        T4      ThRp?ii ; i  \5        \        R 4       i ; i  + '       g   i     R# ; i)
Úis_initializingNzwCannot re-initialize MTIA in forked subprocess. To use MTIA with multiprocessing, you must use the 'spawn' start methodzÖTorch not compiled with MTIA enabled. Ensure you have `import mtia.host_runtime.torch_mtia.dynamic_library` in your python src file and include `//mtia/host_runtime/torch_mtia:torch_mtia` as your target dependency!)Úcxx_resource_managerTc              3   ó8   "  € T F  q'       g   K  Vx € K  	  R # 5ir&   r(   )Ú.0Úcallss   & r   Ú	<genexpr>Ú_lazy_init.<locals>.<genexpr>�   s   é € ÐXÑ0N uÓRWŸUšUÓ0Nùs   ‚	�
z6MTIA call failed lazily at initialization with error: z(

MTIA call was originally invoked at:

Ú )r-   ÚhasattrÚ_tlsr1   r,   r   Ú_is_compiledÚAssertionErrorr   r   Úlibfb.py.cxx_resourcesrI   ÚinstallÚModuleNotFoundErrorrB   rC   Ú
_mtia_initrH   r8   Úextendr3   Ú	get_callsÚ	ExceptionÚstrÚjoinÚDeferredMtiaCallErrorÚdelattrr+   )rI   Úqueued_callÚorig_tracebackÚeÚmsgs        r   r'   r'   T   sƒ  € ä×Òœ7¤4Ð):×;Ò;Ùß	Ö	ô ×ÒØ÷ 
Ñ	ô ×ÒÜðIóð ô �~Š~Ü ð*óð ô �;Š;œ7Ÿ9š9ðÝGà$×,Ñ,Ô.ô
 	�‰×ÑÔð  $ŒÔä×ÑÑXÔ0B×0LÑ0LÔ0NÓXÔXð	-ß/<Ñ+�ð<Ù–Mñ 0=ô ”DÐ+Ô,Øˆ÷o 
Ñ	øô> 'ô áðûô  !ô <àPÔQTÐUVÓQWÐPXð YCØCEÇ7Á7È>ÓCZÐB[ð]ð ô 0°Ó4¸!Ð;ûð<ûô ”DÐ+Õ,ú÷m 
×	Ð	úss   ·F0ÁAF0Â*EÃ AF0ÄFÄ$EÄ+FÄ/F0ÅEÅF0ÅEÅF0ÅF	Å',F	ÆF	ÆFÆF-Æ-F0Æ0G	c                   ó   € ] tR t^’tRtR# )r]   r(   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r(   r   r   r]   r]   ’   s   † Ûr   r]   c                ó$   € V ^8„  d   QhR\         /# r>   r?   )r   s   "r   r   r   –   s   € ÷ $ñ $”dñ $r   c                 ó>   € \         P                  P                  4       # )z*Return true if compiled with MTIA support.)rB   rC   Ú_mtia_isBuiltr(   r   r   rR   rR   –   s   € ä�8‰8×!Ñ!Ó#Ð#r   c                ó$   € V ^8„  d   QhR\         /# r>   r?   )r   s   "r   r   r   ›   s   € ÷ ñ ”dñ r   c                 ó@   € \        4       '       g   R# \        4       ^ 8„  # )z'Return true if MTIA device is availableF)rR   Údevice_countr(   r   r   Úis_availablero   ›   s   € ä�>Š>Ùä‹>˜AÑÐr   c                ó(   € V ^8„  d   QhR\         RR/# ©r   r   r   Nr	   )r   s   "r   r   r   £   s   € ÷ 2ñ 2œð 2¨$ñ 2r   c                óÊ   € \         P                  P                  V 4      ;_uu_ 4        \         P                  P	                  4       uuRRR4       #   + '       g   i     R# ; i)z?Waits for all jobs in all streams on a MTIA device to complete.N)rB   Úmtiar   rC   Ú_mtia_deviceSynchronizer   s   &r   Úsynchronizeru   £   s6   € ä	�‰×	Ñ	˜6×	"Õ	"Ü�x‰x×/Ñ/Ó1÷ 
#×	"×	"Ó	"ús   ¨AÁA"	c                ó$   € V ^8„  d   QhR\         /# r>   r   )r   s   "r   r   r   ©   s   € ÷ +ñ +”cñ +r   c                 ó>   € \         P                  P                  4       # )z,Return the number of MTIA devices available.)rB   rC   Ú_mtia_getDeviceCountr(   r   r   rn   rn   ©   s   € ä�8‰8×(Ñ(Ó*Ð*r   c                ó$   € V ^8„  d   QhR\         /# r>   r   )r   s   "r   r   r   ®   s   € ÷ &ñ &œñ &r   c                 ó>   € \         P                  P                  4       # )z0Return the index of a currently selected device.)rB   rC   Ú_mtia_getDevicer(   r   r   Úcurrent_devicer|   ®   s   € ô �8‰8×#Ñ#Ó%Ð%r   c                ó0   € V ^8„  d   QhR\         R\        /# r   ©r
   ÚStream)r   s   "r   r   r   ´   s   € ÷ 
7ñ 
7œ6ð 
7¬Vñ 
7r   c                óZ   € \        V RR7      p\        P                  P                  V4      # )a;  Return the currently selected :class:`Stream` for a given device.

Args:
    device (torch.device or int, optional): selected device. Returns
        the currently selected :class:`Stream` for the current device, given
        by :func:`~torch.mtia.current_device`, if :attr:`device` is ``None``
        (default).
T©Úoptional)r   rB   rC   Ú_mtia_getCurrentStream)r   Ú
device_idxs   & r   Úcurrent_streamr…   ´   s%   € ô # 6°DÔ9€JÜ�8‰8×*Ñ*¨:Ó6Ð6r   c                ó0   € V ^8„  d   QhR\         R\        /# r   r~   )r   s   "r   r   r   Á   s   € ÷ 	Uñ 	Uœ6ð 	U¬Vñ 	Ur   c                óV   € \         P                  P                  \        V RR7      4      # )a%  Return the default :class:`Stream` for a given device.

Args:
    device (torch.device or int, optional): selected device. Returns
        the default :class:`Stream` for the current device, given by
        :func:`~torch.mtia.current_device`, if :attr:`device` is ``None``
        (default).
Tr�   )rB   rC   Ú_mtia_getDefaultStreamr   r   s   &r   Údefault_streamr‰   Á   s!   € ô �8‰8×*Ñ*Ô+<¸VÈdÔ+SÓTÐTr   c                óN   € V ^8„  d   QhR\         R,          R\         R\        RR/# )r   ÚenabledNÚstacksÚmax_entriesr   )r[   r   )r   s   "r   r   r   Í   s6   € ÷ Eñ EÜ�4�ZðEÜ),ðEÜFIðEà	ñEr   c                ój   € \        4       '       g   R# \        P                  P                  WV4       R# )ay  Enable/Disable the memory profiler on MTIA allocator

Args:
    enabled (all or state, optional) selected device. Returns
        statistics for the current device, given by current_device(),
        if device is None (default).

    stacks ("python" or "cpp", optional). Select the stack trace to record.

    max_entries (int, optional). Maximum number of entries to record.
N)r-   rB   rC   Ú_mtia_recordMemoryHistory)r‹   rŒ   r�   s   &&&r   Úrecord_memory_historyr�   Í   s$   € ô ×ÒÙÜ	‡H�H×&Ñ& w¸ÖDr   c                óF   € V ^8„  d   QhR\         \        \        3,          /# r>   )Údictr[   r   )r   s   "r   r   r   à   s   € ÷ +ñ +”$”sœC�x•.ñ +r   c                 ó>   € \         P                  P                  4       # )z4Return a dictionary of MTIA memory allocator history)rB   rC   Ú_mtia_memorySnapshotr(   r   r   Úsnapshotr•   à   s   € ô �8‰8×(Ñ(Ó*Ð*r   c                ób   € V ^8„  d   QhR\         \        \        \        \        .R3,          RR/# )r   ÚobserverNr   )r   r   )r   s   "r   r   r   æ   s/   € ÷ 7ñ 7ÜœœS¤#¤sÐ+¨TÐ1Õ2ð7à	ñ7r   c                óD   € \         P                  P                  V 4       R# )z9Attach an out-of-memory observer to MTIA memory allocatorN)rB   rC   Ú_mtia_attachOutOfMemoryObserver)r—   s   &r   Úattach_out_of_memory_observerrš   æ   s   € ô 
‡H�H×,Ñ,¨XÖ6r   c                ó$   € V ^8„  d   QhR\         /# )r   Úincluding_emulationr?   )r   s   "r   r   r   í   s   € ÷ ñ ¬4ñ r   c                ó   € R# )zLReturn a bool indicating if the current MTIA device supports dtype bfloat16.Tr(   )rœ   s   &r   Úis_bf16_supportedrž   í   s   € ár   c                óR   € V ^8„  d   QhR\         R\        \        \        3,          /# r   )r
   Útupler   )r   s   "r   r   r   ò   s&   € ÷ Xñ X¤&ð X´E¼#¼s¸(µOñ Xr   c                óV   € \         P                  P                  \        V RR7      4      # )a  Return capability of a given device as a tuple of (major version, minor version).

Args:
    device (torch.device or int, optional) selected device. Returns
        statistics for the current device, given by current_device(),
        if device is None (default).
Tr�   )rB   rC   Ú_mtia_getDeviceCapabilityr   r   s   &r   Úget_device_capabilityr£   ò   ó"   € ô �8‰8×-Ñ-Ô.?ÀÐQUÔ.VÓWÐWr   c                ó   € V ^8„  d   QhRR/# rF   r(   )r   s   "r   r   r   ý   s   € ÷ 'ñ '�Tñ 'r   c                 ó>   € \         P                  P                  4       # )zEmpty the MTIA device cache.)rB   rC   Ú_mtia_emptyCacher(   r   r   Úempty_cacher¨   ý   s   € ä�8‰8×$Ñ$Ó&Ð&r   c                ó$   € V ^8„  d   QhR\         /# )r   Ústream©r   )r   s   "r   r   r     s   € ÷ ,ñ ,”vñ ,r   c                óP   € V f   R# \         P                  P                  V 4       R# )a  Set the current stream. This is a wrapper API to set the stream.
    Usage of this function is discouraged in favor of the ``stream``
    context manager.

Args:
    stream (Stream): selected stream. This function is a no-op
        if this argument is ``None``.
N)rB   rC   Ú_mtia_setCurrentStream©rª   s   &r   Ú
set_streamr¯     s   € ð ‚~ÙÜ	‡H�H×#Ñ# FÖ+r   c                ó(   € V ^8„  d   QhR\         RR/# rq   r	   )r   s   "r   r   r     s   € ÷ 
)ñ 
)”vð 
) $ñ 
)r   c                ól   € \        V 4      p V ^ 8¼  d"   \        P                  P                  V 4       R# R# )z‘Set the current device.

Args:
    device (torch.device or int): selected device. This function is a no-op
        if this argument is negative.
N)r   rB   rC   Ú_mtia_setDevicer   s   &r   Ú
set_devicer³     s,   € ô ˜vÓ&€FØ�„{ä�‰× Ñ  Ö(ñ r   c                óR   € V ^8„  d   QhR\         R\        \        \        3,          /# r   )r
   r’   r[   r   )r   s   "r   r   r     s&   € ÷ Xñ X¤&ð X´D¼¼c¸µNñ Xr   c                óV   € \         P                  P                  \        V RR7      4      # )zäReturn a dictionary of MTIA device properties

Args:
    device (torch.device or int, optional) selected device. Returns
        statistics for the current device, given by current_device(),
        if device is None (default).
Tr�   )rB   rC   Ú_mtia_getDevicePropertiesr   r   s   &r   Úget_device_propertiesr·     r¤   r   c                   óN   a € ] tR tRt o RtV 3R lR ltR tV 3R lR ltRtV t	R	# )
r   i(  z¼Context-manager that changes the selected device.

Args:
    device (torch.device or int): device index to select. It's a no-op if
        this argument is a negative integer or ``None``.
c                ó    <€ V ^8„  d   QhRS[ /# )r   r   r   )r   Ú__classdict__s   "€r   r   Údevice.__annotate__0  s   ø€ ÷ ñ ™sñ r   c                ó8   € \        VR R7      V n        RV n        R# )Tr�   Nr   )r   ÚidxÚprev_idx)Úselfr   s   &&r   Ú__init__Údevice.__init__0  s   € Ü$ V°dÔ;ˆŒØˆŽr   c                ób   € \         P                  P                  V P                  4      V n        R # r&   )rB   rC   r!   r½   r¾   )r¿   s   &r   Ú	__enter__Údevice.__enter__4  s   € äŸ™×:Ñ:¸4¿8¹8ÓDˆŽr   c                ó,   <€ V ^8„  d   QhRS[ RS[ RS[ /# ©r   ÚtypeÚvaluer5   r   )r   rº   s   "€r   r   r»   8  s"   ø€ ÷ ñ ™Sð ©ð ¹ñ r   c                ób   € \         P                  P                  V P                  4      V n        R # )F)rB   rC   r!   r¾   r½   )r¿   rÇ   rÈ   r5   s   &&&&r   Ú__exit__Údevice.__exit__8  s   € ä—8‘8×5Ñ5°d·m±mÓDˆŒÙr   )r½   r¾   N)
rd   re   rf   rg   Ú__doc__rÀ   rÃ   rÊ   rh   Ú__classdictcell__©rº   s   @r   r   r   (  s$   ø‡ € ñ÷ð òE÷ö r   r   c                   óZ   a € ] tR tRt o RtV 3R lR ltR tV 3R lR ltV 3R ltR	t	V t
R
# )ÚStreamContexti>  a  Context-manager that selects a given stream.

All MTIA kernels queued within its context will be enqueued on a selected
stream.

Args:
    Stream (Stream): selected stream. This manager is a no-op if it's
        ``None``.
.. note:: Streams are per-device.
c                ó.   <€ V ^8„  d   QhRS[ R,          /# )r   rª   Nr«   )r   rº   s   "€r   r   ÚStreamContext.__annotate__L  s   ø€ ÷ 
ñ 
™v¨�}ñ 
r   c                óê  € R V n         Wn        \        R R4      V n        \        P
                  P                  4       '       g   V P                  f   RV n        \        P
                  P                  4       '       g   R M\        P                  P                  R 4      V n	        \        P
                  P                  4       '       g
   R V n
        R # \        P                  P                  R 4      V n
        R # )NTr   )Ú
cur_streamrª   r   r½   rB   ÚjitÚis_scriptingrs   r‰   Úsrc_prev_streamÚdst_prev_stream)r¿   rª   s   &&r   rÀ   ÚStreamContext.__init__L  s«   € ØˆŒØŒÜ$ T¨4Ó0ˆŒÜ�y‰y×%Ñ%×'Ò'Ø�x‰xÒØ�”ô Ÿ	™	×.Ñ.×0Ò0‰D´e·j±j×6OÑ6OÐPTÓ6Uð 	Ôô Ÿ	™	×.Ñ.×0Ò0ˆDð 	ÖÜ6;·j±j×6OÑ6OÐPTÓ6Uð 	Ör   c                óê  € V P                   pVe   V P                  R8X  d   R # \        P                  P	                  R 4      V n        V P
                  P                  VP                  8w  dU   \        VP                  4      ;_uu_ 4        \        P                  P	                  VP                  4      V n        R R R 4       \        P                  P                  V4       R #   + '       g   i     L1; i©Nr   )	rª   r½   rB   rs   r…   r×   r   rØ   r¯   )r¿   rÔ   s   & r   rÃ   ÚStreamContext.__enter__[  sŸ   € à—[‘[ˆ
àÒ §¡¨R¤ÙÜ$Ÿz™z×8Ñ8¸Ó>ˆÔð ×Ñ×&Ñ&¨*×*;Ñ*;Ô;Ü˜
×)Ñ)×*Õ*Ü',§z¡z×'@Ñ'@À×ARÑARÓ'S�Ô$÷ +ä�
‰
×Ñ˜jÖ)÷ +×*ús   Â
/C"Ã"C2	c                ó,   <€ V ^8„  d   QhRS[ RS[ RS[ /# rÆ   r   )r   rº   s   "€r   r   rÒ   j  s"   ø€ ÷ 4ñ 4™Sð 4©ð 4¹ñ 4r   c                ó:  € V P                   pVe   V P                  R8X  d   R # V P                  P                  VP                  8w  d*   \        P
                  P                  V P                  4       \        P
                  P                  V P                  4       R # rÛ   )rª   r½   r×   r   rB   rs   r¯   rØ   )r¿   rÇ   rÈ   r5   rÔ   s   &&&& r   rÊ   ÚStreamContext.__exit__j  sj   € à—[‘[ˆ
àÒ §¡¨R¤Ùð ×Ñ×&Ñ&¨*×*;Ñ*;Ô;Ü�J‰J×!Ñ! $×"6Ñ"6Ô7Ü�
‰
×Ñ˜d×2Ñ2Ö3r   c                ó4   <€ V ^8„  d   Qh/ S[ R,          ;R&   # )r   NrÔ   r«   )r   rº   s   "€r   r   rÒ   >  s   ø‡ ‚ ñ ˜•Ñò r   )rÔ   rØ   r½   r×   rª   N)rd   re   rf   rg   rÌ   rÀ   rÃ   rÊ   Ú__annotate_func__rh   rÍ   rÎ   s   @r   rÐ   rÐ   >  s+   ø‡ € ñ	÷
ð 
ò*÷4ð 4÷Y ƒ r   rÐ   c                óF   € \         P                  P                  WV4       R# )zÒset stream specified by the stream id, device index and
    device type

Args: stream_id (int): stream id in stream pool
      device_index (int): device index in topo
      device_type (int): enum device type
N)rB   rC   Ú_mtia_setStream)Ú	stream_idÚdevice_indexÚdevice_types   &&&r   Ú_set_stream_by_idrç   x  s   € ô 
‡H�H×Ñ˜Y°kÖBr   c                ó>   € V ^8„  d   QhR\         R,          R\        /# )r   rª   Nr   )r   rÐ   )r   s   "r   r   r   ƒ  s   € ÷ !ñ !”6˜D•=ð !¤]ñ !r   c                ó   € \        V 4      # )a  Wrap around the Context-manager StreamContext that selects a given stream.

Arguments:
    stream (Stream): selected stream. This manager is a no-op if it's
        ``None``.
.. note:: In eager mode stream is of type Stream class while in JIT it doesn't support torch.mtia.stream
)rÐ   r®   s   &r   rª   rª   ƒ  s   € ô ˜Ó Ð r   c                ó0   € V ^8„  d   QhR\         R\        /# r   )r
   r   )r   s   "r   r   r   Ž  s   € ÷ )ñ )œ&ð )¬fñ )r   c                ó†   € \        4        \        V RR7      pVf   \        4       p\        V,          pVP	                  4       # )aC  Returns the random number generator state of the specified MTIA device as a ByteTensor.

Args:
    device (torch.device or int, optional): The device to return the RNG state of.
        Default: ``'mtia'`` (i.e., ``torch.device('mtia')``, the current mtia device).

.. warning::
    This function eagerly initializes MTIA.
Tr�   )r'   r   r|   Údefault_generatorsÚ	get_state)r   r½   Údefault_generators   &  r   Úget_rng_staterï   Ž  s<   € ô „LÜ
˜F¨TÔ
2€CØ
‚{ÜÓˆÜ*¨3Õ/ÐØ×&Ñ&Ó(Ð(r   c                ó:   € V ^8„  d   QhR\         \        ,          /# r>   ©Úlistr   )r   s   "r   r   r      s   € ÷ ñ œ4¤�<ñ r   c                 óf   € \        \        4       4       U u. uF  p \        V 4      NK  	  pp V# u up i )zRReturns a list of ByteTensor representing the random number states of all devices.)Úrangern   rï   )ÚiÚresultss     r   Úget_rng_state_allr÷      s/   € ä).¬|«~Ô)>Ó?Ñ)> AŒ}˜QÖÑ)>€GÐ?Ø€Nùò @s   –.c                ó4   € V ^8„  d   QhR\         R\        RR/# )r   Ú	new_stater   r   N)r   r
   )r   s   "r   r   r   ¦  s!   € ÷ ñ œVð ¬Vð Àñ r   c                óH  a a€ \        4       '       gP   \        P                  P                  4       ;_uu_ 4        S P	                  \        P
                  R7      o RRR4       \        VRR7      oSf   \        4       oVV 3R lp\        V4       R#   + '       g   i     L?; i)a$  Sets the random number generator state of the specified MTIA device.

Args:
    new_state (torch.ByteTensor): The desired state
    device (torch.device or int, optional): The device to set the RNG state.
        Default: ``'mtia'`` (i.e., ``torch.device('mtia')``, the current mtia device).
)Úmemory_formatNTr�   c                  óD   <€ \         S,          p V P                  S4       R # r&   )rì   Ú	set_state)rî   r½   rù   s    €€r   ÚcbÚset_rng_state.<locals>.cb¸  s   ø€ Ü.¨sÕ3ÐØ×#Ñ# IÖ.r   )	r-   rB   rC   Ú_DisableFuncTorchÚcloneÚcontiguous_formatr   r|   r<   )rù   r   rþ   r½   s   f& @r   Úset_rng_stater  ¦  sp   ù€ ô ×ÒÜ�X‰X×'Ñ'×)Õ)ð "Ÿ™´e×6MÑ6M˜ÓNˆI÷ *ô
 ˜F¨TÔ
2€CØ
‚{ÜÓˆö/ô ˆr†N÷ *×)ús   ¹!BÂB!	c                ó>   € V ^8„  d   QhR\         \        ,          RR/# )r   Ú
new_statesr   Nrñ   )r   s   "r   r   r   ¿  s   € ÷  ñ  ¤$¤v¥,ð  °4ñ  r   c                óD   € \        V 4       F  w  r\        W!4       K  	  R# )z�Sets the random number generator state of all devices.

Args:
    new_states (Iterable of torch.ByteTensor): The desired state for each device.
N)Ú	enumerater  )r  rõ   Ústates   &  r   Úset_rng_state_allr	  ¿  s   € ô ˜jÖ)‰ˆÜ�eÖó *r   c                ó(   € V ^8„  d   QhR\         RR/# ©r   r0   r   Nr   )r   s   "r   r   r   É  s   € ÷ ñ ”cð ˜dñ r   c                óD   a € \        S 4      o V 3R lp\        VRR7       R# )au  Sets the seed for generating random numbers for the current MTIA device.
It's safe to call this function if MTIA is not available; in that case, it is silently ignored.

Args:
    seed (int): The desired seed.

.. warning::
    If you are working with a multi-GPU model, this function is insufficient
    to get determinism.  To seed all GPUs, use :func:`manual_seed_all`.
c                  óX   <€ \        4       p \        V ,          pVP                  S4       R # r&   )r|   rì   Úmanual_seed)r½   rî   r0   s     €r   rþ   Úmanual_seed.<locals>.cbÖ  s$   ø€ ÜÓˆÜ.¨sÕ3ÐØ×%Ñ% dÖ+r   T©r0   N©r   r<   ©r0   rþ   s   f r   r  r  É  s   ø€ ô ˆt‹9€Dõ,ô
 ˆr˜×r   c                ó(   € V ^8„  d   QhR\         RR/# r  r   )r   s   "r   r   r   Þ  s   € ÷ "ñ "œ#ð " $ñ "r   c                óD   a € \        S 4      o V 3R lp\        VRR7       R# )zÊSets the seed for generating random numbers on all MTIA devices.
It's safe to call this function if MTIA is not available; in that case, it is silently ignored.

Args:
    seed (int): The desired seed.
c                  óx   <€ \        \        4       4       F!  p \        V ,          pVP                  S4       K#  	  R # r&   )rô   rn   rì   r  )rõ   rî   r0   s     €r   rþ   Úmanual_seed_all.<locals>.cbç  s-   ø€ Ü”|“~Ö&ˆAÜ 2°1Õ 5ÐØ×)Ñ)¨$Ö/ó 'r   T©r/   Nr  r  s   f r   Úmanual_seed_allr  Þ  s   ø€ ô ˆt‹9€Dõ0ô
 ˆr˜D×!r   c                ó$   € V ^8„  d   QhR\         /# r>   r   )r   s   "r   r   r   ï  s   € ÷ %ñ %Œcñ %r   c                 ó"   € R p \        V RR7      # )ad  Sets the seed for generating random numbers to a random number for the current MTIA device.
It's safe to call this function if MTIA is not available; in that case, it is silently ignored.

.. warning::
    If you are working with a multi-GPU model, this function will only initialize
    the seed on one GPU.  To initialize all GPUs, use :func:`seed_all`.
c                  óP   € \        4       p \        V ,          pVP                  4       # r&   )r|   rì   r0   )r½   rî   s     r   rþ   Úseed.<locals>.cbø  s$   € ÜÓˆÜ.¨sÕ3ÐØ ×%Ñ%Ó'Ð'r   Tr  ©r<   ©rþ   s    r   r0   r0   ï  s   € ò(ô
 �b˜tÔ$Ð$r   c                ó$   € V ^8„  d   QhR\         /# r>   r   )r   s   "r   r   r      s   € ÷ )ñ )”#ñ )r   c                 ó"   € R p \        V RR7      # )zµSets the seed for generating random numbers to a random number on all MTIA devices.

It's safe to call this function if MTIA is not available; in that case, it is silently ignored.
c                  ó¶   € ^ p Rp\        \        4       4       F=  p\        V,          pV'       g   VP                  4       p RpK,  VP	                  V 4       K?  	  V # )r   FT)rô   rn   rì   r0   r  )Úrandom_seedÚseededrõ   rî   s       r   rþ   Úseed_all.<locals>.cb  sT   € ØˆØˆÜ”|“~Ö&ˆAÜ 2°1Õ 5ÐßØ/×4Ñ4Ó6�Ø’à!×-Ñ-¨kÖ:ñ 'ð Ðr   Tr  r  r  s    r   r/   r/      s   € ò
ô �b 4Ô(Ð(r   c                ó$   € V ^8„  d   QhR\         /# r>   r   )r   s   "r   r   r     s   € ÷ 2ñ 2”cñ 2r   c                 ó`   € \        4        \        4       p \        V ,          P                  4       # )zvReturns the current random seed of the current MTIA device.

.. warning::
    This function eagerly initializes MTIA.
)r'   r|   rì   Úinitial_seed)r½   s    r   r'  r'    s%   € ô „LÜ
Ó
€CÜ˜cÕ"×/Ñ/Ó1Ð1r   )Ú*r)   ro   r-   ru   rn   r|   r…   r‰   Úmemory_statsÚmax_memory_allocatedÚmemory_allocatedÚreset_peak_memory_statsr£   r·   r�   r•   rš   r¨   r³   r¯   rª   r  rï   r	  r÷   r  r  r0   r/   r'  rž   Ú	MTIAGraphÚgraphÚgraph_pool_handlec                ó
  € V ^8„  d   Qh/ ^ \         9   d+   \        \        P                  P                  R3,          ;R&   ^\         9   d:   \
        \        \        . R3,          \
        \        ,          3,          ,          ;R&   # )r   .rì   Nr8   )Ú__conditional_annotations__r    rB   rC   Ú	Generatorrò   r   r[   )r   s   "r   r   r      sg   € ÷ ñ ÷. 8Ò 7”Eœ%Ÿ(™(×,Ñ,¨cÐ1Õ2Ñ 7ñ/÷6ò ŒtÜ	Œ(�2�t�8Õ
œd¤3�iÐ
'Õ(õñ ò7r   r(   r&   )ÚallÚpythonr   )T)rs   )Kr1  rÌ   Ú	threadingr5   Úcollections.abcr   Útypingr   rB   r   Útorch._environmentr   r   Útorch._utilsr   Útorch.typesr
   Ú_utilsr   ÚEventr   rì   r+   r8   ÚlocalrQ   ÚLockr1   r3   rP   rC   r   r   r!   r$   r)   r-   r<   r,   r'   rZ   r]   rR   ro   ru   rn   r|   r…   r‰   r�   r•   rš   rž   r£   r¨   r¯   r³   r·   r   rÐ   rç   rª   rï   r÷   r  r	  r  r  r0   r/   r'  ÚmemoryÚ
mtia_graphÚ__all__r   )r1  s   @r   Ú<module>rB     s  øðöó Û Ý $Ý ã Ý ß 1Ý )Ý å %ð 	�‰€Ø	�‰€ð 68Ð Ó 7ð €ð ð ó ð ‡‚Ó€Ø —~’~Ó'Ð Ù%Ó'Ð ñ ˆ5�8‰8Ð+×,Ò,Ø—x‘x×4Ñ4ÑõHñ ˆ5�8‰8Ð0×1Ò1Ø"ŸX™X×?Ñ?ÑõHòò2ò
Kõ(õ;ô|	˜Iô 	õ$õ
÷2õ+õ
&÷
7÷	U÷Eõ&+õ7÷÷
Xõ'õ
,õ
)÷X÷ñ ÷,74ñ 74òtCõ!÷)õ$÷õ2 õõ*"õ"%õ")õ*2ô Ü ð$Ø
ð$àð$ð ð$ð ð	$ð
 ð$ð ð$ð ð$ð ð$ð ð$ð ð$ð ð$ð ð$ð ð$ð ð$ð ð$ð  ð!$ð" $ð#$ð$ ð%$ð& ð'$ð( ð)$ð* ð+$ð, ð-$ð. ð/$ð0 ð1$ð2 ð3$ð4 ð5$ð6 ð7$ð8 ð9$ð: ð;$ð< ð=$ð> ð?$ð@ ðA$ðB ðC$ðD ðE$ðF ðG$‚r   