ó
    EñinB  ã                   óD  • S SK Jr  S SKJrJrJr  S SKrS SKJr  S SKJ	r	  S SK
Jr  SSKJr  SS	KJrJrJr  SS
KJr  SSKJrJr  SSKJrJrJrJr  SSKJrJrJr  / SQr " S S\R@                  5      r! " S S\RD                  5      r#S\$\%   S\$\%   S\\   S\&S\&S\S\#4S jr'S\SSSS .r( " S! S"\5      r) " S# S$\5      r* " S% S&\5      r+ " S' S(\5      r,\" S)S*9\" S+S, 4S-9SS.S/S0.S\\\)\4      S\&S\&S\S\#4
S1 jj5       5       r-\" S2S*9\" S+S3 4S-9SS.S/S0.S\\\*\4      S\&S\&S\S\#4
S4 jj5       5       r.\" S5S*9\" S+S6 4S-9SS.S/S0.S\\\+\4      S\&S\&S\S\#4
S7 jj5       5       r/\" S8S*9\" S+S9 4S-9SS.S/S0.S\\\,\4      S\&S\&S\S\#4
S: jj5       5       r0g);é    )Úpartial)ÚAnyÚOptionalÚUnionN)ÚTensor)Úshufflenetv2é   )ÚImageClassificationé   )Úregister_modelÚWeightsÚWeightsEnum)Ú_IMAGENET_CATEGORIES)Ú_ovewrite_named_paramÚhandle_legacy_interface)ÚShuffleNet_V2_X0_5_WeightsÚShuffleNet_V2_X1_0_WeightsÚShuffleNet_V2_X1_5_WeightsÚShuffleNet_V2_X2_0_Weightsé   )Ú_fuse_modulesÚ_replace_reluÚquantize_model)	ÚQuantizableShuffleNetV2Ú#ShuffleNet_V2_X0_5_QuantizedWeightsÚ#ShuffleNet_V2_X1_0_QuantizedWeightsÚ#ShuffleNet_V2_X1_5_QuantizedWeightsÚ#ShuffleNet_V2_X2_0_QuantizedWeightsÚshufflenet_v2_x0_5Úshufflenet_v2_x1_0Úshufflenet_v2_x1_5Úshufflenet_v2_x2_0c                   óJ   ^ • \ rS rSrS\S\SS4U 4S jjrS\S\4S jrS	rU =r	$ )
ÚQuantizableInvertedResidualé#   ÚargsÚkwargsÚreturnNc                 ól   >• [         TU ]  " U0 UD6  [        R                  R	                  5       U l        g ©N)ÚsuperÚ__init__ÚnnÚ	quantizedÚFloatFunctionalÚcat©Úselfr&   r'   Ú	__class__s      €Úi/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/models/quantization/shufflenetv2.pyr,   Ú$QuantizableInvertedResidual.__init__$   s)   ø€ Ü‰Ò˜$Ð) &Ò)Ü—<‘<×/Ñ/Ó1ˆ�ó    Úxc                 óB  • U R                   S:X  a=  UR                  SSS9u  p#U R                  R                  X R                  U5      /SS9nO:U R                  R                  U R	                  U5      U R                  U5      /SS9n[
        R                  " US5      nU$ )Nr   r   )Údim)ÚstrideÚchunkr0   Úbranch2Úbranch1r   Úchannel_shuffle)r2   r7   Úx1Úx2Úouts        r4   ÚforwardÚ#QuantizableInvertedResidual.forward(   s†   € Ø�;‰;˜!ÓØ—W‘W˜Q A�WÐ&‰FˆBØ—(‘(—,‘, §L¡L°Ó$4Ð5¸1�,Ð=‰Cà—(‘(—,‘, §¡¨Q£°·±¸a³ÐAÀq�,ÐIˆCä×*Ò*¨3°Ó2ˆàˆ
r6   )r0   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r,   r   rB   Ú__static_attributes__Ú__classcell__©r3   s   @r4   r$   r$   #   s5   ø† ð2˜cð 2¨Sð 2°T÷ 2ð	˜ð 	 F÷ 	ò 	r6   r$   c                   óf   ^ • \ rS rSrS\S\SS4U 4S jjrS\S\4S jrSS	\\	   SS4S
 jjr
SrU =r$ )r   é4   r&   r'   r(   Nc                 óæ   >• [         TU ]  " US[        0UD6  [        R                  R
                  R                  5       U l        [        R                  R
                  R                  5       U l	        g )NÚinverted_residual)
r+   r,   r$   ÚtorchÚaoÚquantizationÚ	QuantStubÚquantÚDeQuantStubÚdequantr1   s      €r4   r,   Ú QuantizableShuffleNetV2.__init__6   sP   ø€ Ü‰Ò˜$ÐXÔ2MÐXÐQWÒXÜ—X‘X×*Ñ*×4Ñ4Ó6ˆŒ
Ü—x‘x×,Ñ,×8Ñ8Ó:ˆ�r6   r7   c                 ól   • U R                  U5      nU R                  U5      nU R                  U5      nU$ r*   )rS   Ú_forward_implrU   )r2   r7   s     r4   rB   ÚQuantizableShuffleNetV2.forward;   s1   € Ø�J‰J�q‹MˆØ×Ñ˜qÓ!ˆØ�L‰L˜‹OˆØˆr6   Úis_qatc                 ó°  • U R                   R                  5        H!  u  p#US;   d  M  Uc  M  [        U/ SQ/USS9  M#     U R                  5        Hƒ  n[	        U5      [
        L d  M  [        UR                  R                   R                  5       5      S:”  a  [        UR                  SS// S	Q/USS9  [        UR                  / SQS
S// SQ/USS9  M…     g)a  Fuse conv/bn/relu modules in shufflenetv2 model

Fuse conv+bn+relu/ conv+relu/conv+bn modules to prepare for quantization.
Model is modified in place.

.. note::
    Note that this operation does not change numerics
    and the model after modification is in floating point
)Úconv1Úconv5N)Ú0Ú1Ú2T)Úinplacer   r^   r_   )r`   Ú3Ú4rb   rc   )Ú5Ú6Ú7)	Ú_modulesÚitemsr   ÚmodulesÚtyper$   Úlenr=   r<   )r2   rZ   ÚnameÚms       r4   Ú
fuse_modelÚ"QuantizableShuffleNetV2.fuse_modelA   s¹   € ð —}‘}×*Ñ*Ö,‰GˆDØÐ)Õ)¨a«mÜ˜a¢/Ð!2°FÀDÔIñ -ð —‘–ˆAÜ�A‹wÔ5Ô5Ü�q—y‘y×)Ñ)×/Ñ/Ó1Ó2°QÓ6Ü! !§)¡)¨s°C¨jº/Ð-JÈFÐ\`ÒaÜØ—I‘IÚ$ s¨C j²/ÐBØØ ô	ò	  r6   )rU   rS   r*   )rD   rE   rF   rG   r   r,   r   rB   r   Úboolrn   rH   rI   rJ   s   @r4   r   r   4   sL   ø† ð;˜cð ;¨Sð ;°T÷ ;ð
˜ð  Fô ñ ¨$¡ð ¸4÷ ó r6   r   Ústages_repeatsÚstages_out_channelsÚweightsÚprogressÚquantizer'   r(   c                ó`  • UbM  [        US[        UR                  S   5      5        SUR                  ;   a  [        USUR                  S   5        UR                  SS5      n[	        X40 UD6n[        U5        U(       a  [        Xv5        Ub  UR                  UR                  USS95        U$ )NÚnum_classesÚ
categoriesÚbackendÚfbgemmT)rt   Ú
check_hash)	r   rk   ÚmetaÚpopr   r   r   Úload_state_dictÚget_state_dict)rq   rr   rs   rt   ru   r'   ry   Úmodels           r4   Ú_shufflenetv2r�   Z   s¡   € ð ÑÜ˜f m´S¸¿¹ÀlÑ9SÓ5TÔUØ˜Ÿ™Ó$Ü! &¨)°W·\±\À)Ñ5LÔMØ�j‰j˜ HÓ-€Gä# NÑRÈ6ÑR€EÜ�%ÔÞÜ�uÔ&àÑØ×Ñ˜g×4Ñ4¸hÐSWÐ4ÐXÔYà€Lr6   )r   r   rz   zdhttps://github.com/pytorch/vision/tree/main/references/classification#post-training-quantized-modelsz’
        These weights were produced by doing Post Training Quantization (eager mode) on top of the unquantized
        weights listed below.
    )Úmin_sizerx   ry   ÚrecipeÚ_docsc                   ód   • \ rS rSr\" S\" \SS90 \ES\R                  SSSS	.0S
SS.ES9r
\
rSrg)r   é€   zShttps://download.pytorch.org/models/quantized/shufflenetv2_x0.5_fbgemm-00845098.pthéà   ©Ú	crop_sizeiÛ úImageNet-1Kg#Ûù~jüL@gR¸…ëñS@©zacc@1zacc@5g{®Gáz¤?gj¼t“ø?©Ú
num_paramsÚunquantizedÚ_metricsÚ_opsÚ
_file_size©ÚurlÚ
transformsr|   © N)rD   rE   rF   rG   r   r   r
   Ú_COMMON_METAr   ÚIMAGENET1K_V1ÚIMAGENET1K_FBGEMM_V1ÚDEFAULTrH   r•   r6   r4   r   r   €   s[   † Ù"ØaÙÐ.¸#Ñ>ð
Øð
à!Ø5×CÑCàØ#Ø#ñ ðð Øò
ñÐð" #ƒGr6   r   c                   ód   • \ rS rSr\" S\" \SS90 \ES\R                  SSSS	.0S
SS.ES9r
\
rSrg)r   é•   zQhttps://download.pytorch.org/models/quantized/shufflenetv2_x1_fbgemm-1e62bb32.pthr‡   rˆ   iÌÄ" rŠ   g×£p=
Q@gh‘í|?åU@r‹   g�Âõ(\�Â?gyé&1¬@rŒ   r’   r•   N)rD   rE   rF   rG   r   r   r
   r–   r   r—   r˜   r™   rH   r•   r6   r4   r   r   •   s[   † Ù"Ø_ÙÐ.¸#Ñ>ð
Øð
à!Ø5×CÑCàØ#Ø#ñ ðð Øò
ñÐð" #ƒGr6   r   c                   óh   • \ rS rSr\" S\" \SSS90 \ESS\R                  SS	S
S.0SSS.ES9r
\
rSrg)r   éª   zShttps://download.pytorch.org/models/quantized/shufflenetv2_x1_5_fbgemm-d7401f05.pthr‡   éè   ©r‰   Úresize_sizeú+https://github.com/pytorch/vision/pull/5906iv5 rŠ   gÙÎ÷SR@gÍÌÌÌÌ¬V@r‹   g‹lçû©ñÒ?gÇK7‰A`@©rƒ   r�   rŽ   r�   r�   r‘   r’   r•   N)rD   rE   rF   rG   r   r   r
   r–   r   r—   r˜   r™   rH   r•   r6   r4   r   r   ª   ó`   † Ù"ØaÙÐ.¸#È3ÑOð
Øð
àCØ!Ø5×CÑCàØ#Ø#ñ ðð Øò
ñÐð$ #ƒGr6   r   c                   óh   • \ rS rSr\" S\" \SSS90 \ESS\R                  SS	S
S.0SSS.ES9r
\
rSrg)r   éÀ   zShttps://download.pytorch.org/models/quantized/shufflenetv2_x2_0_fbgemm-5cac526c.pthr‡   rž   rŸ   r¡   iÌÒp rŠ   g-²�ï§ÖR@g¬Zd;W@r‹   g-²�ï§â?g‘í|?5Þ@r¢   r’   r•   N)rD   rE   rF   rG   r   r   r
   r–   r   r—   r˜   r™   rH   r•   r6   r4   r   r   À   r£   r6   r   Úquantized_shufflenet_v2_x0_5)rl   Ú
pretrainedc                 óp   • U R                  SS5      (       a  [        R                  $ [        R                  $ ©Nru   F)Úgetr   r˜   r   r—   ©r'   s    r4   Ú<lambda>r¬   Ú   ó1   € à�z‰z˜* e×,Ñ,ô 0×DÑDð :ä+×9Ñ9ð:r6   )rs   TF©rs   rt   ru   c                 ón   • U(       a  [         O[        R                  U 5      n [        / SQ/ SQ4XUS.UD6$ )aå  
Constructs a ShuffleNetV2 with 0.5x output channels, as described in
`ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design
<https://arxiv.org/abs/1807.11164>`__.

.. note::
    Note that ``quantize = True`` returns a quantized model with 8 bit
    weights. Quantized models only support inference and run on CPUs.
    GPU inference is not yet supported.

Args:
    weights (:class:`~torchvision.models.quantization.ShuffleNet_V2_X0_5_QuantizedWeights` or :class:`~torchvision.models.ShuffleNet_V2_X0_5_Weights`, optional): The
        pretrained weights for the model. See
        :class:`~torchvision.models.quantization.ShuffleNet_V2_X0_5_QuantizedWeights` below for
        more details, and possible values. By default, no pre-trained
        weights are used.
    progress (bool, optional): If True, displays a progress bar of the download to stderr.
        Default is True.
    quantize (bool, optional): If True, return a quantized version of the model.
        Default is False.
    **kwargs: parameters passed to the ``torchvision.models.quantization.ShuffleNet_V2_X0_5_QuantizedWeights``
        base class. Please refer to the `source code
        <https://github.com/pytorch/vision/blob/main/torchvision/models/quantization/shufflenetv2.py>`_
        for more details about this class.

.. autoclass:: torchvision.models.quantization.ShuffleNet_V2_X0_5_QuantizedWeights
    :members:

.. autoclass:: torchvision.models.ShuffleNet_V2_X0_5_Weights
    :members:
    :noindex:
©é   é   r±   )é   é0   é`   r¥   é   r®   )r   r   Úverifyr�   ©rs   rt   ru   r'   s       r4   r   r   Ö   sB   € öd 7?Õ2ÔD^×fÑfÐgnÓo€GÜÚÒ*ðØ4;ÐYañØekñð r6   Úquantized_shufflenet_v2_x1_0c                 óp   • U R                  SS5      (       a  [        R                  $ [        R                  $ r©   )rª   r   r˜   r   r—   r«   s    r4   r¬   r¬     r­   r6   c                 ón   • U(       a  [         O[        R                  U 5      n [        / SQ/ SQ4XUS.UD6$ )aå  
Constructs a ShuffleNetV2 with 1.0x output channels, as described in
`ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design
<https://arxiv.org/abs/1807.11164>`__.

.. note::
    Note that ``quantize = True`` returns a quantized model with 8 bit
    weights. Quantized models only support inference and run on CPUs.
    GPU inference is not yet supported.

Args:
    weights (:class:`~torchvision.models.quantization.ShuffleNet_V2_X1_0_QuantizedWeights` or :class:`~torchvision.models.ShuffleNet_V2_X1_0_Weights`, optional): The
        pretrained weights for the model. See
        :class:`~torchvision.models.quantization.ShuffleNet_V2_X1_0_QuantizedWeights` below for
        more details, and possible values. By default, no pre-trained
        weights are used.
    progress (bool, optional): If True, displays a progress bar of the download to stderr.
        Default is True.
    quantize (bool, optional): If True, return a quantized version of the model.
        Default is False.
    **kwargs: parameters passed to the ``torchvision.models.quantization.ShuffleNet_V2_X1_0_QuantizedWeights``
        base class. Please refer to the `source code
        <https://github.com/pytorch/vision/blob/main/torchvision/models/quantization/shufflenetv2.py>`_
        for more details about this class.

.. autoclass:: torchvision.models.quantization.ShuffleNet_V2_X1_0_QuantizedWeights
    :members:

.. autoclass:: torchvision.models.ShuffleNet_V2_X1_0_Weights
    :members:
    :noindex:
r°   )r³   ét   rž   iÐ  r¶   r®   )r   r   r·   r�   r¸   s       r4   r    r      óB   € öd 7?Õ2ÔD^×fÑfÐgnÓo€GÜÚÒ,ðØ6=Ð[cñØgmñð r6   Úquantized_shufflenet_v2_x1_5c                 óp   • U R                  SS5      (       a  [        R                  $ [        R                  $ r©   )rª   r   r˜   r   r—   r«   s    r4   r¬   r¬   J  r­   r6   c                 ón   • U(       a  [         O[        R                  U 5      n [        / SQ/ SQ4XUS.UD6$ )aå  
Constructs a ShuffleNetV2 with 1.5x output channels, as described in
`ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design
<https://arxiv.org/abs/1807.11164>`__.

.. note::
    Note that ``quantize = True`` returns a quantized model with 8 bit
    weights. Quantized models only support inference and run on CPUs.
    GPU inference is not yet supported.

Args:
    weights (:class:`~torchvision.models.quantization.ShuffleNet_V2_X1_5_QuantizedWeights` or :class:`~torchvision.models.ShuffleNet_V2_X1_5_Weights`, optional): The
        pretrained weights for the model. See
        :class:`~torchvision.models.quantization.ShuffleNet_V2_X1_5_QuantizedWeights` below for
        more details, and possible values. By default, no pre-trained
        weights are used.
    progress (bool, optional): If True, displays a progress bar of the download to stderr.
        Default is True.
    quantize (bool, optional): If True, return a quantized version of the model.
        Default is False.
    **kwargs: parameters passed to the ``torchvision.models.quantization.ShuffleNet_V2_X1_5_QuantizedWeights``
        base class. Please refer to the `source code
        <https://github.com/pytorch/vision/blob/main/torchvision/models/quantization/shufflenetv2.py>`_
        for more details about this class.

.. autoclass:: torchvision.models.quantization.ShuffleNet_V2_X1_5_QuantizedWeights
    :members:

.. autoclass:: torchvision.models.ShuffleNet_V2_X1_5_Weights
    :members:
    :noindex:
r°   )r³   é°   i`  iÀ  r¶   r®   )r   r   r·   r�   r¸   s       r4   r!   r!   F  r½   r6   Úquantized_shufflenet_v2_x2_0c                 óp   • U R                  SS5      (       a  [        R                  $ [        R                  $ r©   )rª   r   r˜   r   r—   r«   s    r4   r¬   r¬   ‚  r­   r6   c                 ón   • U(       a  [         O[        R                  U 5      n [        / SQ/ SQ4XUS.UD6$ )aå  
Constructs a ShuffleNetV2 with 2.0x output channels, as described in
`ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design
<https://arxiv.org/abs/1807.11164>`__.

.. note::
    Note that ``quantize = True`` returns a quantized model with 8 bit
    weights. Quantized models only support inference and run on CPUs.
    GPU inference is not yet supported.

Args:
    weights (:class:`~torchvision.models.quantization.ShuffleNet_V2_X2_0_QuantizedWeights` or :class:`~torchvision.models.ShuffleNet_V2_X2_0_Weights`, optional): The
        pretrained weights for the model. See
        :class:`~torchvision.models.quantization.ShuffleNet_V2_X2_0_QuantizedWeights` below for
        more details, and possible values. By default, no pre-trained
        weights are used.
    progress (bool, optional): If True, displays a progress bar of the download to stderr.
        Default is True.
    quantize (bool, optional): If True, return a quantized version of the model.
        Default is False.
    **kwargs: parameters passed to the ``torchvision.models.quantization.ShuffleNet_V2_X2_0_QuantizedWeights``
        base class. Please refer to the `source code
        <https://github.com/pytorch/vision/blob/main/torchvision/models/quantization/shufflenetv2.py>`_
        for more details about this class.

.. autoclass:: torchvision.models.quantization.ShuffleNet_V2_X2_0_QuantizedWeights
    :members:

.. autoclass:: torchvision.models.ShuffleNet_V2_X2_0_Weights
    :members:
    :noindex:
r°   )r³   éô   iè  iÐ  i   r®   )r   r   r·   r�   r¸   s       r4   r"   r"   ~  r½   r6   )1Ú	functoolsr   Útypingr   r   r   rO   Útorch.nnr-   r   Útorchvision.modelsr   Útransforms._presetsr
   Ú_apir   r   r   Ú_metar   Ú_utilsr   r   r   r   r   r   Úutilsr   r   r   Ú__all__ÚInvertedResidualr$   ÚShuffleNetV2r   ÚlistÚintrp   r�   r–   r   r   r   r   r   r    r!   r"   r•   r6   r4   Ú<module>rÔ      s  ðÝ ß 'Ñ 'ã Ý Ý Ý +å 6ß 7Ñ 7Ý (ß C÷ó ÷ @Ñ ?ò
€ô ,×"?Ñ"?ô ô"#˜l×7Ñ7ô #ðLØ˜‘Iðà˜c™ðð �kÑ"ð	ð
 ðð ðð ðð ôð6 Ø&ØØtðñ	€ô#¨+ô #ô*#¨+ô #ô*#¨+ô #ô,#¨+ô #ñ, Ð3Ñ4Ùàñ	
ðñ	ð aeØØò	*à�eÐ?ÐA[Ð[Ñ\Ñ]ð*ð ð*ð ð	*ð
 ð*ð ô*ó	ó 5ð*ñZ Ð3Ñ4Ùàñ	
ðñ	ð aeØØò	*à�eÐ?ÐA[Ð[Ñ\Ñ]ð*ð ð*ð ð	*ð
 ð*ð ô*ó	ó 5ð*ñZ Ð3Ñ4Ùàñ	
ðñ	ð aeØØò	*à�eÐ?ÐA[Ð[Ñ\Ñ]ð*ð ð*ð ð	*ð
 ð*ð ô*ó	ó 5ð*ñZ Ð3Ñ4Ùàñ	
ðñ	ð aeØØò	*à�eÐ?ÐA[Ð[Ñ\Ñ]ð*ð ð*ð ð	*ð
 ð*ð ô*ó	ó 5ñ*r6   