§
    “©ºj
  ã                   ó¢   — d dl mZ d dlmZmZ d dlmZ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 d d
lmZ  G d„ de¦  «        ZdS )é    )Ú	Generator)ÚAbstractContextManagerÚcontextmanager)ÚAnyÚLiteralN)Úapply_to_collection)ÚTensor)ÚModule)Úoverride)Ú_convert_fp_tensorÚ_DtypeContextManager)Ú	Precisionc                   óü   — e Zd ZU dZdZed         ed<   dded         ddfd„Zede	de	fd	„¦   «         Z
edefd
„¦   «         Zedefd„¦   «         Zeeded         fd„¦   «         ¦   «         Zededefd„¦   «         ZdS )ÚHalfPrecisionz¦Plugin for training with half precision.

    Args:
        precision: Whether to use ``torch.float16`` (``'16-true'``) or ``torch.bfloat16`` (``'bf16-true'``).

    ú16-true)ú	bf16-truer   Ú	precisionÚreturnNc                 óZ   — || _         |dk    rt          j        nt          j        | _        d S )Nr   )r   ÚtorchÚbfloat16Úfloat16Ú_desired_input_dtype)Úselfr   s     úx/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/pytorch_lightning/plugins/precision/half.pyÚ__init__zHalfPrecision.__init__&   s+   € Ø"ˆŒØ6?À;Ò6NÐ6N¥E¤N NÕTYÔTaˆÔ!Ð!Ð!ó    Úmodulec                 ó8   — |                      | j        ¬¦  «        S )N)Údtype)Útor   )r   r   s     r   Úconvert_modulezHalfPrecision.convert_module*   s   € à�yŠy˜tÔ8ˆyÑ9Ô9Ð9r   c                 ó*   — t          | j        ¦  «        S ©N)r   r   ©r   s    r   Útensor_init_contextz!HalfPrecision.tensor_init_context.   s   € å# DÔ$=Ñ>Ô>Ð>r   c                 ó*   — |                       ¦   «         S r$   )r&   r%   s    r   Úmodule_init_contextz!HalfPrecision.module_init_context2   s   € à×'Ò'Ñ)Ô)Ð)r   )NNNc              #   óÆ   K  — t          j        ¦   «         }t          j        | j        ¦  «         	 dV — t          j        |¦  «         dS # t          j        |¦  «         w xY w)z§A context manager to change the default tensor type when tensors get created during the module's forward.

        See: :meth:`torch.set_default_tensor_type`

        N)r   Úget_default_dtypeÚset_default_dtyper   )r   Údefault_dtypes     r   Úforward_contextzHalfPrecision.forward_context6   sf   è è € õ Ô/Ñ1Ô1ˆÝÔ Ô 9Ñ:Ô:Ð:ð	3ØˆEˆEˆEåÔ# MÑ2Ô2Ð2Ð2Ð2ø�EÔ# MÑ2Ô2Ð2Ð2øøøs   °A
 Á
A Údatac                 óF   — t          |t          t          | j        ¬¦  «        S )N)Úfunctionr    Údst_type)r   r   r	   r   )r   r.   s     r   Úconvert_inputzHalfPrecision.convert_inputE   s   € å" 4Õ2DÍFÐ]aÔ]vÐwÑwÔwÐwr   )r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   r
   r"   r   r&   r(   r   r   r-   r   r2   © r   r   r   r      sX  € € € € € € ðð ð 2;€IˆwÐ-Ô.Ð:Ð:Ñ:ðbð b 'Ð*@Ô"Að bÐRVð bð bð bð bð ð: Vð :°ð :ð :ð :ñ „Xð:ð ð?Ð%;ð ?ð ?ð ?ñ „Xð?ð ð*Ð%;ð *ð *ð *ñ „Xð*ð Øð3 Ð+;Ô!<ð 3ð 3ð 3ñ „^ñ „Xð3ð ðx #ð x¨#ð xð xð xñ „Xðxð xð xr   r   )Úcollections.abcr   Ú
contextlibr   r   Útypingr   r   r   Úlightning_utilitiesr   r	   Útorch.nnr
   Útyping_extensionsr   Ú(lightning_fabric.plugins.precision.utilsr   r   Ú-pytorch_lightning.plugins.precision.precisionr   r   r8   r   r   ú<module>rA      s  ðð &Ð %Ð %Ð %Ð %Ð %Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø Ð Ð Ð Ð Ð Ð Ð à €€€Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &à ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ð ]Ø CÐ CÐ CÐ CÐ CÐ Cð+xð +xð +xð +xð +x�Iñ +xô +xð +xð +xð +xr   