Ë
    3êñi~0  ã                   óÜ   — d dl Z d dlmZ d dlZd dlmZ d dlmZmZ d dl	m
Z
mZ ddlmZ ddlmZ g d	¢Z G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ dee«      Zy)é    N)ÚAny)ÚTensor)Ú
functionalÚinit)Ú	ParameterÚUninitializedParameteré   )ÚLazyModuleMixin)ÚModule)ÚBilinearÚIdentityÚ
LazyLinearÚLinearc                   ó@   ‡ — e Zd ZdZdededdfˆ fd„Zdedefd„Zˆ xZS )	r   a  A placeholder identity operator that is argument-insensitive.

    Args:
        args: any argument (unused)
        kwargs: any keyword argument (unused)

    Shape:
        - Input: :math:`(*)`, where :math:`*` means any number of dimensions.
        - Output: :math:`(*)`, same shape as the input.

    Examples::

        >>> m = nn.Identity(54, unused_argument1=0.1, unused_argument2=False)
        >>> input = torch.randn(128, 20)
        >>> output = m(input)
        >>> print(output.size())
        torch.Size([128, 20])

    ÚargsÚkwargsÚreturnNc                 ó"   •— t         ‰| �  «        y )N©ÚsuperÚ__init__)Úselfr   r   Ú	__class__s      €úY/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torch/nn/modules/linear.pyr   zIdentity.__init__+   s   ø€ Ü‰ÑÕó    Úinputc                 ó   — |S ©z(
        Runs the forward pass.
        © ©r   r   s     r   ÚforwardzIdentity.forward.   s	   € ð ˆr   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r!   Ú__classcell__©r   s   @r   r   r      s5   ø„ ñð(˜cð ¨Sð °Tõ ð˜Vð ¨÷ r   r   c            	       óˆ   ‡ — e Zd ZU dZddgZeed<   eed<   eed<   	 	 	 ddedededdfˆ fd„Z	dd	„Z
d
edefd„Zdefd„Zˆ xZS )r   aC  Applies an affine linear transformation to the incoming data: :math:`y = xA^T + b`.

    This module supports :ref:`TensorFloat32<tf32_on_ampere>`.

    On certain ROCm devices, when using float16 inputs this module will use :ref:`different precision<fp16_on_mi200>` for backward.

    Args:
        in_features: size of each input sample
        out_features: size of each output sample
        bias: If set to ``False``, the layer will not learn an additive bias.
            Default: ``True``

    Shape:
        - Input: :math:`(*, H_\text{in})` where :math:`*` means any number of
          dimensions including none and :math:`H_\text{in} = \text{in\_features}`.
        - Output: :math:`(*, H_\text{out})` where all but the last dimension
          are the same shape as the input and :math:`H_\text{out} = \text{out\_features}`.

    Attributes:
        weight: the learnable weights of the module of shape
            :math:`(\text{out\_features}, \text{in\_features})`. The values are
            initialized from :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})`, where
            :math:`k = \frac{1}{\text{in\_features}}`
        bias:   the learnable bias of the module of shape :math:`(\text{out\_features})`.
                If :attr:`bias` is ``True``, the values are initialized from
                :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})` where
                :math:`k = \frac{1}{\text{in\_features}}`

    Examples::

        >>> m = nn.Linear(20, 30)
        >>> input = torch.randn(128, 20)
        >>> output = m(input)
        >>> print(output.size())
        torch.Size([128, 30])
    Úin_featuresÚout_featuresÚweightNÚbiasr   c                 ó&  •— ||dœ}t         ‰| �  «        || _        || _        t	        t        j                  ||ffi |¤Ž«      | _        |r%t	        t        j                  |fi |¤Ž«      | _        n| j                  dd «       | j                  «        y ©N©ÚdeviceÚdtyper,   )r   r   r)   r*   r   ÚtorchÚemptyr+   r,   Úregister_parameterÚreset_parameters)r   r)   r*   r,   r0   r1   Úfactory_kwargsr   s          €r   r   zLinear.__init__`   s‡   ø€ ð %+°UÑ;ˆÜ‰ÑÔØ&ˆÔØ(ˆÔÜÜ�K‰K˜ {Ð3ÑF°~ÑFó
ˆŒñ Ü!¤%§+¡+¨lÑ"M¸nÑ"MÓNˆD�Ià×#Ñ# F¨DÔ1Ø×ÑÕr   c                 óL  — t        j                  | j                  t        j                  d«      ¬«       | j
                  �dt        j                  | j                  «      \  }}|dkD  rdt        j                  |«      z  nd}t        j                  | j
                  | |«       yy)úW
        Resets parameters based on their initialization used in ``__init__``.
        é   )ÚaNr   r	   )r   Úkaiming_uniform_r+   ÚmathÚsqrtr,   Ú_calculate_fan_in_and_fan_outÚuniform_)r   Úfan_inÚ_Úbounds       r   r5   zLinear.reset_parametersu   sx   € ô 	×Ñ˜dŸk™k¬T¯Y©Y°q«\Õ:Ø�9‰9Ð Ü×:Ñ:¸4¿;¹;ÓG‰IˆF�AØ-3°aªZ�AœŸ	™	 &Ó)Ò)¸QˆEÜ�M‰M˜$Ÿ)™) e V¨UÕ3ð !r   r   c                 óX   — t        j                  || j                  | j                  «      S r   )ÚFÚlinearr+   r,   r    s     r   r!   zLinear.forward‚   s   € ô �x‰x˜˜tŸ{™{¨D¯I©IÓ6Ð6r   c                 óX   — d| j                   › d| j                  › d| j                  du› �S )ú@
        Return the extra representation of the module.
        zin_features=ú, out_features=ú, bias=N)r)   r*   r,   ©r   s    r   Ú
extra_reprzLinear.extra_reprˆ   s:   € ð ˜d×.Ñ.Ð/¨¸t×?PÑ?PÐ>QÐQXÐY]×YbÑYbÐjnÐYnÐXoÐpÐpr   ©TNN©r   N©r"   r#   r$   r%   Ú__constants__ÚintÚ__annotations__r   Úboolr   r5   r!   ÚstrrK   r&   r'   s   @r   r   r   5   s‚   ø… ñ#ðJ # NÐ3€MØÓØÓØƒNð ØØñ àð ð ð ð ð	 ð 
õ ó*4ð7˜Vð 7¨ó 7ðq˜C÷ qr   r   c            	       ó8   ‡ — e Zd Z	 	 	 ddedededdfˆ fd„Zˆ xZS )ÚNonDynamicallyQuantizableLinearNr)   r*   r,   r   c                 ó.   •— t         ‰| �  |||||¬«       y )N)r,   r0   r1   r   )r   r)   r*   r,   r0   r1   r   s         €r   r   z(NonDynamicallyQuantizableLinear.__init__•   s"   ø€ ô 	‰ÑØ˜¨D¸Àuð 	õ 	
r   rL   )r"   r#   r$   rP   rR   r   r&   r'   s   @r   rU   rU   ”   s>   ø„ ð
 ØØñ

àð

ð ð

ð ð	

ð 
÷

ñ 

r   rU   c                   óš   ‡ — e Zd ZU dZg d¢Zeed<   eed<   eed<   eed<   	 	 	 ddedededed	df
ˆ fd
„Z	dd„Z
deded	efd„Zd	efd„Zˆ xZS )r   aç  Applies a bilinear transformation to the incoming data: :math:`y = x_1^T A x_2 + b`.

    Args:
        in1_features: size of each first input sample, must be > 0
        in2_features: size of each second input sample, must be > 0
        out_features: size of each output sample, must be > 0
        bias: If set to ``False``, the layer will not learn an additive bias.
            Default: ``True``

    Shape:
        - Input1: :math:`(*, H_\text{in1})` where :math:`H_\text{in1}=\text{in1\_features}` and
          :math:`*` means any number of additional dimensions including none. All but the last dimension
          of the inputs should be the same.
        - Input2: :math:`(*, H_\text{in2})` where :math:`H_\text{in2}=\text{in2\_features}`.
        - Output: :math:`(*, H_\text{out})` where :math:`H_\text{out}=\text{out\_features}`
          and all but the last dimension are the same shape as the input.

    Attributes:
        weight: the learnable weights of the module of shape
            :math:`(\text{out\_features}, \text{in1\_features}, \text{in2\_features})`.
            The values are initialized from :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})`, where
            :math:`k = \frac{1}{\text{in1\_features}}`
        bias:   the learnable bias of the module of shape :math:`(\text{out\_features})`.
                If :attr:`bias` is ``True``, the values are initialized from
                :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})`, where
                :math:`k = \frac{1}{\text{in1\_features}}`

    Examples::

        >>> m = nn.Bilinear(20, 30, 40)
        >>> input1 = torch.randn(128, 20)
        >>> input2 = torch.randn(128, 30)
        >>> output = m(input1, input2)
        >>> print(output.size())
        torch.Size([128, 40])
    )Úin1_featuresÚin2_featuresr*   rX   rY   r*   r+   Nr,   r   c                 ó6  •— ||dœ}t         ‰| �  «        || _        || _        || _        t        t        j                  |||ffi |¤Ž«      | _        |r%t        t        j                  |fi |¤Ž«      | _	        n| j                  dd «       | j                  «        y r.   )r   r   rX   rY   r*   r   r2   r3   r+   r,   r4   r5   )	r   rX   rY   r*   r,   r0   r1   r6   r   s	           €r   r   zBilinear.__init__Î   s‘   ø€ ð %+°UÑ;ˆÜ‰ÑÔØ(ˆÔØ(ˆÔØ(ˆÔÜÜ�K‰K˜ |°\ÐBÑUÀnÑUó
ˆŒñ Ü!¤%§+¡+¨lÑ"M¸nÑ"MÓNˆD�Ià×#Ñ# F¨DÔ1Ø×ÑÕr   c                 óX  — | j                   dk  rt        d| j                   › d�«      ‚dt        j                  | j                  j                  d«      «      z  }t        j                  | j                  | |«       | j                  �#t        j                  | j                  | |«       yy)r8   r   z0in1_features must be > 0, but got (in1_features=ú)r	   N)	rX   Ú
ValueErrorr<   r=   r+   Úsizer   r?   r,   )r   rB   s     r   r5   zBilinear.reset_parametersæ   s’   € ð ×Ñ Ò!ÜØBÀ4×CTÑCTÐBUÐUVÐWóð ð ”D—I‘I˜dŸk™k×.Ñ.¨qÓ1Ó2Ñ2ˆÜ�‰�d—k‘k E 6¨5Ô1Ø�9‰9Ð Ü�M‰M˜$Ÿ)™) e V¨UÕ3ð !r   Úinput1Úinput2c                 óZ   — t        j                  ||| j                  | j                  «      S r   )rD   Úbilinearr+   r,   )r   r_   r`   s      r   r!   zBilinear.forwardó   s!   € ô �z‰z˜& &¨$¯+©+°t·y±yÓAÐAr   c           	      ór   — d| j                   › d| j                  › d| j                  › d| j                  du› �S )rG   zin1_features=z, in2_features=rH   rI   N)rX   rY   r*   r,   rJ   s    r   rK   zBilinear.extra_reprù   sL   € ð
 ˜D×-Ñ-Ð.¨o¸d×>OÑ>OÐ=Pð QØ ×-Ñ-Ð.¨g°d·i±iÀtÐ6KÐ5LðNð	
r   rL   rM   rN   r'   s   @r   r   r   ¢   s—   ø… ñ#òJ E€MØÓØÓØÓØƒNð ØØñ àð ð ð ð ð	 ð
 ð ð 
õ ó04ðB˜fð B¨fð B¸ó Bð
˜C÷ 
r   r   c                   ób   ‡ — e Zd ZU dZeZeed<   eed<   	 d
dede	ddfˆ fd„Z
dˆ fd„Zdd	„Zˆ xZS )r   a  A :class:`torch.nn.Linear` module where `in_features` is inferred.

    In this module, the `weight` and `bias` are of :class:`torch.nn.UninitializedParameter`
    class. They will be initialized after the first call to ``forward`` is done and the
    module will become a regular :class:`torch.nn.Linear` module. The ``in_features`` argument
    of the :class:`Linear` is inferred from the ``input.shape[-1]``.

    Check the :class:`torch.nn.modules.lazy.LazyModuleMixin` for further documentation
    on lazy modules and their limitations.

    Args:
        out_features: size of each output sample
        bias: If set to ``False``, the layer will not learn an additive bias.
            Default: ``True``

    Attributes:
        weight: the learnable weights of the module of shape
            :math:`(\text{out\_features}, \text{in\_features})`. The values are
            initialized from :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})`, where
            :math:`k = \frac{1}{\text{in\_features}}`
        bias:   the learnable bias of the module of shape :math:`(\text{out\_features})`.
                If :attr:`bias` is ``True``, the values are initialized from
                :math:`\mathcal{U}(-\sqrt{k}, \sqrt{k})` where
                :math:`k = \frac{1}{\text{in\_features}}`


    r+   r,   Nr*   r   c                 ó†   •— ||dœ}t         ‰| �  ddd«       t        di |¤Ž| _        || _        |rt        di |¤Ž| _        y y )Nr/   r   Fr   )r   r   r   r+   r*   r,   )r   r*   r,   r0   r1   r6   r   s         €r   r   zLazyLinear.__init__%  sP   ø€ ð %+°UÑ;ˆô 	‰Ñ˜˜A˜uÔ%ä,Ñ>¨~Ñ>ˆŒØ(ˆÔÙä.Ñ@°Ñ@ˆD�Ið r   c                 ód   •— | j                  «       s| j                  dk7  rt        ‰| �  «        yyy)r8   r   N)Úhas_uninitialized_paramsr)   r   r5   )r   r   s    €r   r5   zLazyLinear.reset_parameters4  s2   ø€ ð
 ×,Ñ,Ô.°4×3CÑ3CÀqÒ3HÜ‰GÑ$Õ&ð 4IÐ.r   c                 óˆ  — | j                  «       r¤t        j                  «       5  |j                  d   | _        | j
                  j                  | j                  | j                  f«       | j                  �&| j                  j                  | j                  f«       | j                  «        ddd«       | j                  dk(  rs|j                  d   | j
                  j                  d   k7  r5t        d|j                  d   › d| j
                  j                  d   › �«      ‚|j                  d   | _        yy# 1 sw Y   ŒŒxY w)zW
        Infers ``in_features`` based on ``input`` and initializes parameters.
        éÿÿÿÿNr   z%The in_features inferred from input: z/ is not equal to in_features from self.weight: )rg   r2   Úno_gradÚshaper)   r+   Úmaterializer*   r,   r5   ÚAssertionErrorr    s     r   Úinitialize_parametersz LazyLinear.initialize_parameters<  s  € ð
 ×(Ñ(Ô*Ü—‘“ñ (Ø#(§;¡;¨r¡?�Ô Ø—‘×'Ñ'¨×):Ñ):¸D×<LÑ<LÐ(MÔNØ—9‘9Ð(Ø—I‘I×)Ñ)¨4×+<Ñ+<Ð*>Ô?Ø×%Ñ%Ô'÷(ð ×Ñ˜qÒ Ø�{‰{˜2‰ $§+¡+×"3Ñ"3°BÑ"7Ò7Ü$Ø;¸E¿K¹KÈ¹OÐ;Lð MEà—{‘{×(Ñ(¨Ñ,Ð-ð/óð ð
  %Ÿ{™{¨2™ˆDÕð !÷(ð (ús   ¥BD8Ä8ErL   rM   )r"   r#   r$   r%   r   Úcls_to_becomer   rQ   rP   rR   r   r5   rn   r&   r'   s   @r   r   r     sM   ø… ñð8 €Mà"Ó"Ø
 Ó ð HLñAØðAØ'+ðAà	õAõ'÷/r   r   )r<   Útypingr   r2   r   Útorch.nnr   rD   r   Útorch.nn.parameterr   r   Úlazyr
   Úmoduler   Ú__all__r   r   rU   r   r   r   r   r   ú<module>rv      sl   ðã Ý ã Ý ß *ß @å !Ý ò€ôˆvô ô>WqˆVô Wqô~
 fô 
ô^
ˆvô ^
ôBL/� &õ L/r   