§
    “©ºjô  ã                  ó¢   — d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dlZ	d dl
mZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ  G d„ de¦  «        ZdS )é    )Úannotations)ÚAnyN)ÚTensor)Úoverride)ÚCheckpointIO)Ú_StrategyRegistry)Ú_DEVICE)Ú	Precision)ÚStrategyÚ
TBroadcastc                  ó&  ‡ — e Zd ZdZdZ	 	 	 	 d+d,ˆ fd„Zed-d„¦   «         Zed.d/d„¦   «         Ze	ed0d„¦   «         ¦   «         Z
ed1d„¦   «         Ze	ed2d „¦   «         ¦   «         Zed3d!„¦   «         Zed4d5d'„¦   «         Zeed6d*„¦   «         ¦   «         Zˆ xZS )7ÚSingleDeviceStrategyz7Strategy that handles communication on a single device.Úsingle_deviceÚcpuNÚdevicer	   Úacceleratorú.pl.accelerators.accelerator.Accelerator | NoneÚcheckpoint_ioúCheckpointIO | NoneÚprecision_pluginúPrecision | Nonec                óä   •— t          ¦   «                              |||¬¦  «         t          |t          j        ¦  «        st          j        |¦  «        }|| _        d| _        d| _        d| _        d S )N)r   r   r   r   é   )	ÚsuperÚ__init__Ú
isinstanceÚtorchr   Ú_root_deviceÚglobal_rankÚ
local_rankÚ
world_size)Úselfr   r   r   r   Ú	__class__s        €úz/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/pytorch_lightning/strategies/single_device.pyr   zSingleDeviceStrategy.__init__#   sj   ø€ õ 	‰Œ×Ò [ÀÐ`pÐÑqÔqÐqÝ˜&¥%¤,Ñ/Ô/ð 	*Ý”\ &Ñ)Ô)ˆFØ"ˆÔØˆÔØˆŒØˆŒˆˆó    ÚtensorúAny | TensorÚargsr   ÚkwargsÚreturnc                ó   — |S )a¡  Reduces a tensor from several distributed processes to one aggregated tensor. Since this strategy only
        operates with a single device, the reduction is simply the identity.

        Args:
            tensor: the tensor to sync and reduce
            *args: ignored
            **kwargs: ignored

        Return:
            the unmodified input as reduction is not needed for single process operation

        © )r"   r&   r(   r)   s       r$   ÚreducezSingleDeviceStrategy.reduce2   s	   € ð ˆr%   Fr   Úgroupú
Any | NoneÚ
sync_gradsÚboolc                ó   — |S )z&Perform a all_gather on all processes.r,   )r"   r&   r.   r0   s       r$   Ú
all_gatherzSingleDeviceStrategy.all_gatherB   s	   € ð ˆr%   útorch.devicec                ó   — | j         S ©N)r   ©r"   s    r$   Úroot_devicez SingleDeviceStrategy.root_deviceG   s   € ð Ô Ð r%   ÚNonec                óf   — | j         €
J d¦   «         ‚| j                              | j        ¦  «         d S )Nz-self.model must be set before self.model.to())ÚmodelÚtor8   r7   s    r$   Úmodel_to_devicez$SingleDeviceStrategy.model_to_deviceL   s6   € àŒzÐ%Ð%Ð'VÑ%Ô%Ð%ØŒ
�Š�dÔ&Ñ'Ô'Ð'Ð'Ð'r%   c                ó   — dS )NTr,   r7   s    r$   Úis_global_zeroz#SingleDeviceStrategy.is_global_zeroQ   s	   € ð ˆtr%   c                ó   — d S r6   r,   )r"   r(   r)   s      r$   ÚbarrierzSingleDeviceStrategy.barrierV   s   € àˆr%   r   Úobjr   ÚsrcÚintc                ó   — |S r6   r,   )r"   rB   rC   s      r$   Ú	broadcastzSingleDeviceStrategy.broadcastZ   s   € àˆ
r%   Ústrategy_registryr   c                óJ   — |                      | j        | | j        ¬¦  «         d S )N)Údescription)ÚregisterÚstrategy_nameÚ__name__)ÚclsrG   s     r$   Úregister_strategiesz(SingleDeviceStrategy.register_strategies^   s9   € ð 	×"Ò"ØÔØØœð 	#ñ 	
ô 	
ð 	
ð 	
ð 	
r%   )r   NNN)r   r	   r   r   r   r   r   r   )r&   r'   r(   r   r)   r   r*   r'   )NF)r&   r   r.   r/   r0   r1   r*   r   )r*   r4   )r*   r9   )r*   r1   )r(   r   r)   r   r*   r9   )r   )rB   r   rC   rD   r*   r   )rG   r   r*   r9   )rL   Ú
__module__Ú__qualname__Ú__doc__rK   r   r   r-   r3   Úpropertyr8   r=   r?   rA   rF   ÚclassmethodrN   Ú__classcell__)r#   s   @r$   r   r      sƒ  ø€ € € € € ØAÐAà#€Mð  ØFJØ-1Ø-1ðð ð ð ð ð ð ð ðð ð ñ „Xðð ðð ð ð ñ „Xðð Øð!ð !ð !ñ „Xñ „Xð!ð ð(ð (ð (ñ „Xð(ð Øðð ð ñ „Xñ „Xðð ðð ð ñ „Xðð ðð ð ð ñ „Xðð Øð
ð 
ð 
ñ „Xñ „[ð
ð 
ð 
ð 
ð 
r%   r   )Ú
__future__r   Útypingr   r   r   Útyping_extensionsr   Úpytorch_lightningÚplÚlightning_fabric.pluginsr   Úlightning_fabric.strategiesr   Ú lightning_fabric.utilities.typesr	   Ú#pytorch_lightning.plugins.precisionr
   Ú%pytorch_lightning.strategies.strategyr   r   r   r,   r%   r$   ú<module>r_      s  ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &à Ð Ð Ð Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FðG
ð G
ð G
ð G
ð G
˜8ñ G
ô G
ð G
ð G
ð G
r%   