+
    åûj–‹  ã                   óh  € ^ RI t ^ RIHtHtHtHt ^ RIt^ RIHu H	t
 ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt R R ltR	 R
 ltR R ltR R ltR R ltR#R R lltR R lt ! R R]P2                  4      tR R ltR$tR R ltR R ltR%R R lltR&R R  llt  ! R! R"]P2                  4      t!R# )'é    N)ÚAnyÚDictÚListÚTuple)Únn)ÚKORNIA_CHECKÚKORNIA_CHECK_SHAPE)Ú_l2_normalize)Úget_gaussian_kernel2dc                ó\   € V ^8„  d   QhR\         R\         R\         R\        P                  /# )é   ÚkdÚkyÚkxÚreturn©ÚintÚtorchÚTensor)Úformats   "ÚSC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\siftdesc.pyÚ__annotate__r      s,   € ÷ 4ñ 4œCð 4¤Sð 4¬cð 4´e·l±lñ 4ó    c                ól   € W,          V,          p\         P                  ! V4      P                  W0W4      # )zðReturn neigh2channels conv kernel.

Deliberately not memoised: the result is registered as a buffer, so a shared cache has to clone
on the way out to keep callers from writing into it, and the clone costs more than rebuilding
the identity.
)r   ÚeyeÚview)r   r   r   Únumels   &&& r   Ú_get_reshape_kernelr      s+   € ð •˜2•€EÜ�9Š9�UÓ× Ñ  ¨BÓ3Ð3r   c          
      óº   € V ^8„  d   QhR\         P                  R\         P                  R\        R\        \         P                  \         P                  3,          /# )r   ÚgxÚgyÚepsr   )r   r   Úfloatr   )r   s   "r   r   r   )   sF   € ÷ (ñ (Ü�‰ð(ÜŸ,™,ð(Ü-2ð(ä
Œ5�<‰<œŸ™Ð%Õ&ñ(r   c           	     óz  € V P                   pV\        P                  8X  d!   V P                  4       p VP                  4       pW ,          W,          ,           pV^ 8„  p\        P                  ! V\        P
                  ! WB,           4      \        P                  ! V4      4      p\        P                  ! V\        P                  ! WV,           4      R\        P                  ,          ,           \        P                  ! VR\        P                  ,          4      4      pVP                  V4      VP                  V4      3# )aó  Per-pixel gradient magnitude and orientation in ``[2pi, 4pi)``.

``eps`` keeps ``sqrt`` and ``atan2`` away from their singular point at a zero gradient, where
both have an undefined backward. A float16 input is lifted to float32 for this step: the
1e-10 guard is not representable in float16, and a squared float16 gradient underflows long
before that, so a flat pair of pixels -- ordinary with a 10-bit mantissa -- would send NaN
into the input gradient. The result is cast back. bfloat16 has float32's exponent range, so
both the guard and the squares are representable there and it takes the same expression as
float32 and float64.

A pixel with an exactly zero gradient has no orientation and contributes nothing: its magnitude
is zero rather than the guard's ``sqrt(eps)``, and its orientation is ``2pi`` (what the guarded
``atan2`` returns) with a zero derivative rather than ``atan2``'s ``1 / eps``. Both were guard
artefacts: the ``sqrt(eps)`` magnitude made a flat patch's descriptor a unit vector built from
``eps`` in float32 and a subnormal one in float16, whose ``1 / norm`` gradient overflowed through
the float16 cast into a NaN input gradient. A flat patch now has a zero descriptor and a zero
gradient in every dtype; every other pixel is unchanged.
ç       @)Údtyper   Úfloat16r#   ÚwhereÚsqrtÚ
zeros_likeÚatan2ÚmathÚpiÚ	full_likeÚto)r    r!   r"   r&   ÚsqÚnonzeroÚmagÚoris   &&&     r   Ú_gradient_magnitude_orientationr4   )   sÎ   € ð* �H‰H€EØ”—‘ÔØ�X‰X‹ZˆØ�X‰X‹ZˆØ	��2•7Õ	€BØ�1‰f€GÜ
�+Š+�gœuŸzšz¨"­(Ó3´U×5EÒ5EÀbÓ5IÓ
J€CÜ
�+Š+�gœuŸ{š{¨2°C­xÓ8¸3ÄÇÁ½=ÕHÌ%Ï/Ê/ÐZ\Ð^aÔdh×dkÑdkÕ^kÓJlÓ
m€CØ�6‰6�%‹=˜#Ÿ&™& ›-Ð'Ð'r   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )r   ÚinputÚmoder   )r   r   Ústr)r   s   "r   r   r   I   s.   € ÷ Lñ L¤u§|¡|ð L¼3ð LÄ5Ç<Á<ñ Lr   c                ó
  € \         P                  ! V P                  \        P                  ! V P
                  \        P                  4      4      RR4      pVR	,          VRRR
13,          ,
          pVR,          VRRR
1R3,          ,
          pVR8X  dz   VRRR
1R3,          RVR^R1R3,          ,          ,           VR,          ,           R,          pVRRR
13,          RVR^R13,          ,          ,           VR	,          ,           R,          pM)VR^R1R3,          R,          pVR^R13,          R,          p\        P                  ! VP                  ^4      VP                  ^4      3^4      P                  V P
                  4      # )aä  Return ``spatial_gradient(input, mode)`` for ``"sobel"`` or ``"diff"``, exact on flat pixels.

A guard such as ``sq > 0`` in :func:`_gradient_magnitude_orientation` reads exactness from this result: a nonzero
pixel votes with its direction and gets a derivative of ``1 / |g|``. A convolution result cannot supply that, as it
rounds: a pixel whose exact response is zero can come out nonzero, such as 9.31e-10 on half the Sobel entries of a
constant 0.1 patch on x86 CPU and CUDA. This was found on macOS arm64 CPU, where the ``F.conv2d`` backend for a
tracked float32 batch of 16 or more leaves about 1e-7 on low-contrast patches. All input therefore takes the
differences directly, so that the result does not depend on ``requires_grad``.
Ú	replicate.NºNNNÚsobelr%   g       @)é   r=   r=   r=   ).ºr   NNéþÿÿÿ).r>   r;   éÿÿÿÿ)	ÚFÚpadr/   r   Úpromote_typesr&   Úfloat32ÚcatÚ	unsqueeze)r6   r7   ÚpaddedÚdxÚdyr    r!   s   &&     r   Ú_exact_first_order_gradientrJ   I   sJ  € ô �UŠU�5—8‘8œE×/Ò/°·±¼U¿]¹]ÓKÓLÈlÐ\gÓh€FØ	��˜6 # s¨ s (Õ+Õ	+€BØ	�
Õ	˜f S¨#¨2¨#¨q [Õ1Õ	1€BØˆw„Ø��c�r�c˜1��o  b¨¨a°¨d°A¨Õ&6Õ 6Õ6¸¸J½ÕGÈ3ÕNˆØ��c�r�c��l˜S 2 c¨1¨R¨4 i¥=Õ0Õ0°2°gµ;Õ>À#ÕE‰à��Q�r�T˜1�Õ Õ#ˆØ��Q�r�T�	�]˜SÕ ˆô �9Š9�b—l‘l 1“o r§|¡|°A£Ð7¸Ó;×>Ñ>¸u¿{¹{ÓKÐKr   c          
      ó�   € V ^8„  d   QhR\         P                  R\         P                  R\        R\        R\         P                  /# )r   r    r!   Únum_ang_binsr"   r   ©r   r   r   r#   )r   s   "r   r   r   b   s@   € ÷ ñ Ü�‰ðÜŸ,™,ðÜ69ðÜ@Eðä
‡\�\ñr   c                óF  € \        WV4      w  rE\        V4      V,          R\        P                  ,          ,          p\        P
                  ! V4      pWg,
          pWr,          pV^,           V,          p	RV,
          V,          p
W„,          pV P                  V P                  ^ ,          W P                  R,          V P                  R,          4      pVP                  ^VP                  4       V,          V
4       VP                  ^V	P                  4       V,          V4       V# )a5  Return unnormalised, per-pixel SIFT angular histogram maps.

This is the gradient stage shared by :class:`DenseSIFTDescriptor` and sparse
consumers which pool a scale pyramid themselves.  In particular it deliberately
does *not* materialise the ``num_ang_bins * num_spatial_bins**2`` dense
descriptor tensor.
r%   ç      ð?r?   r@   )
r4   r#   r,   r-   r   ÚfloorÚ	new_zerosÚshapeÚscatter_add_Úlong)r    r!   rL   r"   r2   r3   Úo_bigÚbo0Úw1Úbo1Úw0Ú
histogramss   &&&&        r   Ú%_dense_sift_histograms_from_gradientsr[   b   sÛ   € ô /¨r°sÓ;�H€CÜ�,Ó #Õ%¨¬t¯w©w­Õ7€EÜ
�+Š+�eÓ
€CØ	�€BØ
Õ
€CØ��7�lÕ
"€CØ
��(�cÕ	€BØ	�€Bð —‘˜bŸh™h q�k¨<¿¹À"½ÀrÇxÁxÐPRÅ|ÓT€JØ×Ñ˜A˜sŸx™x›z¨LÕ8¸"Ô=Ø×Ñ˜A˜sŸx™x›z¨LÕ8¸"Ô=ØÐr   c                óp   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  /# )r   r6   rL   r"   r   rM   )r   s   "r   r   r   |   s9   € ÷ dñ d¤%§,¡,ð d¼cð dÌð dÔRW×R^ÑR^ñ dr   c                 óP   € \        V R 4      p\        VR,          VR,          W4      # )Údiff©r;   r;   r   ©r;   r;   r=   )rJ   r[   )r6   rL   r"   Úgradss   &&& r   Ú_dense_sift_histogramsrb   |   s&   € Ü'¨¨vÓ6€EÜ0°°wµÀÀwÅÐQ]ÓcÐcr   c                óD   € V ^8„  d   QhR\         R\        P                  /# )r   Úksizer   r   )r   s   "r   r   r   �   s   € ÷ +ñ +¤3ð +´·±ñ +r   c                óü   € \        V 4      R,          pV\        P                  ! V 4      P                  4       R,           V,
          P                  4       ,
          p\        P                  ! W"4      V^,          ,          # )z–Return a weighted pooling kernel for SIFT descriptor.

Args:
    ksize: kernel_size.

Returns:
    the pooling kernel with shape ``(ksize, ksize)``.

r%   g      à?)r#   r   ÚarangeÚabsÚger)rd   Úks_2Úxc2s   &  r   Úget_sift_pooling_kernelrk   �   sY   € ô ˜“, Õ$€DØ
”%—,’,˜uÓ%×+Ñ+Ó-°Õ3°dÕ:×?Ñ?ÓAÕ
A€CÜ�9Š9�SÓ $¨¥'Õ*Ð*r   c          	      óh   € V ^8„  d   QhR\         R\         R\        \         \         \         3,          /# )r   Ú
patch_sizeÚnum_spatial_binsr   )r   r   )r   s   "r   r   r   �   s0   € ÷ "ñ "¬cð "ÄSð "ÌUÔSVÔX[Ô]`ÐS`ÕMañ "r   c                óº  € W,          p^\        W^,           ,          4      ,          pW0,
          V^,
          V,          ,           ^,          ^ 8w  d
   V^,          pW0,
          V^,
          V,          ,           ^,          pV^ 8”  d4   V ^V,          ,           V^,
          ,
          ^,
          V,          ^,           M^ pV^ 8  g   WQ8w  d   \        RV  RV R24      hW2V3# )a‡  Return the spatial pooling parameters of :class:`SIFTDescriptor`.

The pooling is a convolution with :func:`get_sift_pooling_kernel` of size ``ksize``, stride ``stride`` and zero
padding ``pad`` on every side. Its ``num_spatial_bins`` cells per side are ``stride`` pixels apart and the grid
is centred on the patch centre :math:`(\text{patch\_size} - 1) / 2`, where the descriptor's Gaussian weighting
window is centred: cell :math:`k` is centred at
:math:`(\text{patch\_size} - 1) / 2 + (k - (\text{num\_spatial\_bins} - 1) / 2) \cdot \text{stride}`.

``ksize`` is :math:`2 \lfloor \text{patch\_size} / (\text{num\_spatial\_bins} + 1) \rfloor`, plus one when a
centred grid needs a kernel centred on a pixel rather than between two, as at the default patch size 41.

Args:
    patch_size: the given patch size.
    num_spatial_bins: the given number of spatial bins.

Returns:
    ksize, stride, pad.

zPatch size z; is incompatible with the requested number of spatial bins zd for SIFT descriptor. Usually it happens when patch size is too small for num_spatial_bins specified)r   Ú
ValueError)rm   rn   Ústriderd   rB   Úout_sizes   &&    r   Úget_sift_bin_ksize_stride_padrs   �   sÛ   € ð( Õ0€FØ”S˜¸!Õ';Õ<Ó=Õ=€Eð 	ÕÐ.°Õ2°fÕ<Õ<ÀÕAÀQÔFØ��
ˆØÕ"Ð&6¸Õ&:¸fÕ%DÕDÈÕJ€CØNTÐWXÌj�Z ! c¥'Õ)¨U°Q­YÕ7¸!Õ;ÀÕFÈÖJÐ^_€HØ
ˆQ„w�(Ô.ÜØ˜*˜Ð%`ØÐ ð !-ð-ó
ð 	
ð
 ˜#ÐÐr   c                   ó¦   a a€ ] tR t^µt oRtV3R lR ltRV3R lV 3R llltV3R lV 3R lltV3R lR	 ltV3R
 lR lt	V3R lR lt
RtVtV ;t# )ÚSIFTDescriptoruz  Describe square grayscale patches with SIFT histograms of gradient orientation.

``sift = SIFTDescriptor(patch_size)``, then ``descs = sift(patches)`` takes grayscale patches
``(B, 1, patch_size, patch_size)``, 41 pixels square by default, and returns one descriptor per patch,
``(B, num_ang_bins * num_spatial_bins ** 2)``: ``(B, 128)`` with the default 8 angle bins and 4 x 4 spatial
cells, RootSIFT by default, in kornia's angle-major layout. The patches must already be sampled, scaled and
oriented; to describe LAFs on an image, wrap it in :class:`LAFDescriptor` with the same ``patch_size``. For a
descriptor at every position of an image, use :class:`DenseSIFTDescriptor` instead, and to describe or orient
LAFs without extracting patches, :class:`SIFTDescriptorFromPyramid`.

Convention:
    - The input is a stack of grayscale patches, ``patch_size`` pixels square (41 by default; another size
      raises), with rows along :math:`+y` and columns along :math:`+x`, as
      :func:`~kornia.feature.extract_patches_from_pyramid` samples them from LAFs
      (see :ref:`Local features <local-features-conventions>`).
    - The output is in kornia's angle-major SIFT layout, which
      :func:`~kornia.feature.convert_sift_descriptor_layout` defines and reorders to OpenCV's. In the patch of a
      LAF oriented by :class:`~kornia.feature.LAFOrienter`, the dominant gradient direction it found points along
      :math:`+x`, the centre of angle bin 0.
    - The ``num_spatial_bins`` x ``num_spatial_bins`` grid of spatial cells and the Gaussian weighting window are
      both centred on the patch centre :math:`(\text{patch\_size} - 1) / 2`; ``get_sift_bin_ksize_stride_pad``
      gives the cell spacing and pooling kernel. A patch mirrored upside down therefore has a descriptor that is a
      permutation of the original's; so does a patch mirrored left to right when ``num_ang_bins`` is even, and a
      ``torch.rot90``-rotated one when ``num_ang_bins`` is a multiple of four, as the default 8 is.
    - The descriptor is L2-normalised, clipped at ``clipval`` and L2-normalised again, so an output entry can
      exceed ``clipval``. With ``rootsift=True``, the default, it is then L1-normalised and square-rooted
      (RootSIFT). Either way a row has unit L2 norm, except for a flat patch: it has no gradient and gives an
      all-zero descriptor, or ``1e-5`` in every entry with RootSIFT. OpenCV's ``cv2.SIFT`` returns the
      ``rootsift=False`` descriptor scaled to an L2 norm of about 512 and rounded to integers.
    - An intensity change :math:`a x + b` with :math:`a > 0` gives the same descriptor unless it leaves the patch
      nearly flat, so a patch in ``[0, 1]`` and the same patch in ``[0, 255]`` give one descriptor.

Args:
    patch_size: Input patch size in pixels. Some sizes cannot hold a centred grid of ``num_spatial_bins`` cells,
        such as 7 with 4 bins, and raise ``ValueError`` when the module is built.
    num_ang_bins: Number of angular bins.
    num_spatial_bins: Number of spatial bins per side.
    clipval: clipping value to reduce single-bin dominance
    rootsift: if ``True``, RootSIFT (ArandjeloviÄ‡ et. al, 2012) is computed.

Returns:
    SIFT descriptor of the patches.

Shape:
    - Input: ``(B, 1, patch_size, patch_size)``
    - Output: ``(B, num_ang_bins * num_spatial_bins ** 2)``

See Also:
    - :class:`DenseSIFTDescriptor`: a descriptor at every position of an image, as a map, with no Gaussian
      weighting of the cells.
    - :class:`SIFTDescriptorFromPyramid`: describes, and can orient, LAFs on an image without extracting patches.
    - :func:`convert_sift_descriptor_layout`: reorders the descriptors into OpenCV's layout.
    - :class:`LAFDescriptor`: runs this module on a patch per LAF of an image.
    - :class:`SIFTFeature`: detects DoG keypoints and, with the default ``"patch"`` backend, describes them with
      this module.
    - :class:`MKDDescriptor`: another handcrafted patch descriptor, from kernel embeddings of the gradients.
    - :class:`HardNet`: a learned descriptor of 32 x 32 patches.

Example:
    >>> input = torch.rand(23, 1, 32, 32)
    >>> SIFT = SIFTDescriptor(32, 8, 4)
    >>> descs = SIFT(input) # 23x128

c                ó    <€ V ^8„  d   QhRS[ /# ©r   r   ©r8   )r   Ú__classdict__s   "€r   r   ÚSIFTDescriptor.__annotate__÷   s   ø€ ÷ 
ñ 
™#ñ 
r   c                ó¶   € V P                   P                   R V P                   RV P                   RV P                   RV P
                   RV P                   R2# )ú(num_ang_bins=ú, num_spatial_bins=z, patch_size=ú, rootsift=ú
, clipval=Ú))Ú	__class__Ú__name__rL   rn   rm   ÚrootsiftÚclipval©Úselfs   &r   Ú__repr__ÚSIFTDescriptor.__repr__÷   sk   € à�~‰~×&Ñ&Ð'ð (Ø ×-Ñ-Ð.ð / Ø $× 5Ñ 5Ð6ð 7ØŸ/™/Ð*ð +ØŸ™�ð 'Ø—|‘|�n Að'ð	
r   c                ó<   <€ V ^8„  d   QhRS[ RS[ RS[ RS[RS[RR/# )r   rm   rL   rn   rƒ   r„   r   N©r   Úboolr#   )r   ry   s   "€r   r   rz     sO   ø€ ÷ !Lñ !Láð!Lñ ð!Lñ ð	!Lñ
 ð!Lñ ð!Lð 
ñ!Lr   c           
     ó0  <€ \         S	V `  4        R V n        W n        W0n        WPn        W@n        Wn        V P                  p\        V4      \        P                  ! R4      ,          pV P                  R\        Wf3Ww3R4      RR7       \        W4      w  V n        V n        V n        \#        V P                  R7      P                  4       p\$        P&                  ! ^^VP)                  ^ 4      VP)                  ^4      3V P                  V P                  3V P                   V P                   3RR7      V n        V P*                  P,                  P.                  P1                  VP3                  ^^VP)                  ^ 4      VP)                  ^4      4      4       R# )	ç»½×Ùß|Û=r%   ÚgkTF)Ú
persistent©rd   )Úkernel_sizerq   ÚpaddingÚbiasN)ÚsuperÚ__init__r"   rL   rn   r„   rƒ   rm   r#   r,   r)   Úregister_bufferr   rs   Ú	bin_ksizeÚ
bin_striderB   rk   r   ÚConv2dÚsizeÚpkÚweightÚdataÚcopy_Úreshape)
r†   rm   rL   rn   rƒ   r„   ÚksÚsigmaÚnwr�   s
   &&&&&&   €r   r•   ÚSIFTDescriptor.__init__  s5  ø€ ô 	‰ÑÔØˆŒØ(ÔØ 0ÔØŒØ ŒØ$Œà—/‘/ˆÜ˜R“y¤4§9¢9¨S£>Õ1ˆð 	×Ñ˜TÔ#8¸"¸ÀEÀ>ÐSWÓ#XÐejÐÔkä6SÐT^Ó6qÑ3ˆŒ˜œ¨$¬(ä$¨4¯>©>Ô:×@Ñ@ÓBˆÜ—)’)ØØØŸ™ › R§W¡W¨Q£ZÐ0Ø—O‘O T§_¡_Ð5Ø—X‘X˜tŸx™xÐ(Øô
ˆŒð 	�‰�‰×Ñ×!Ñ! "§*¡*¨Q°°2·7±7¸1³:¸r¿w¹wÀq»zÓ"JÖKr   c                ó¤   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[ S[S[3,          RS[RS[S[,          RS[S[,          RS[S[,          RR	/# )
r   Ú
state_dictÚprefixÚlocal_metadataÚstrictÚmissing_keysÚunexpected_keysÚ
error_msgsr   N)r   r8   r   r‹   r   )r   ry   s   "€r   r   rz   $  sw   ø€ ÷ 
ñ 
á™™c˜•Nð
ñ ð
ñ ™S¡#˜X�ð	
ñ
 ð
ñ ™3•ið
ñ ™c�ð
ñ ™•Ið
ð 
ñ
r   c           	     óH  <€ VR ,           pVP                  V4      p	\        V	\        P                  4      '       EdT   V	P                  V P
                  P                  P                  8w  Ed$   \        ^\        V P                  V P                  ^,           ,          4      ,          4      p
V
P                  V	P                  4      P                  ! ^^.V
P                  O5!  p
V	P                  V
P                  8X  d”   \        P                  ! V	P                  4       V
4      '       di   \        V P                   4      P#                  4       pVP                  ! ^^.VP                  O5!  P                  V	P$                  V	P                  4      W&   \&        SV `Q  WW4WVV4       R# )z	pk.weightN)ÚgetÚ
isinstancer   r   rR   r›   rœ   rk   r   rm   rn   r/   r&   rŸ   ÚequalÚcpur—   r#   Údevicer”   Ú_load_from_state_dict)r†   r¥   r¦   r§   r¨   r©   rª   r«   Úkeyrœ   ÚformerÚcurrentr�   s   &&&&&&&&    €r   r²   Ú$SIFTDescriptor._load_from_state_dict$  s  ø€ ð �{Õ"ˆØ—‘ Ó$ˆÜ�fœeŸl™l×+Ó+°·±ÀÇÁÇÁ×@TÑ@TÕ0TÜ,¨Q´°T·_±_È×H]ÑH]Ð`aÕHaÕ5bÓ1cÕ-cÓdˆFØ—Y‘Y˜vŸ|™|Ó,×4Ò4°Q¸ÐI¸F¿L¹LÓIˆFØ�|‰|˜vŸ|™|Ô+´·²¸F¿J¹J»LÈ&×0QÒ0QÜ1°$·.±.ÓA×GÑGÓI�Ø")§/¢/°!°QÐ"G¸¿¹Ó"G×"JÑ"JÈ6Ï=É=ÐZ`×ZfÑZfÓ"g�
‘Ü‰Ñ%Ø ¸ÐWaö	
r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# rw   ©r   r   )r   ry   s   "€r   r   rz   ?  s   ø€ ÷ /ñ /¡E§L¡Lñ /r   c                óf   € V P                   P                  P                  4       P                  4       # )z˜Return the spatial pooling kernel used for histogram accumulation.

Returns:
    Detached copy of the convolution kernel tensor from the pooling layer.
)r›   rœ   ÚdetachÚcloner…   s   &r   Úget_pooling_kernelÚ!SIFTDescriptor.get_pooling_kernel?  s$   € ð �w‰w�~‰~×$Ñ$Ó&×,Ñ,Ó.Ð.r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# rw   r¸   )r   ry   s   "€r   r   rz   G  s   ø€ ÷ 	(ñ 	(¡e§l¡lñ 	(r   c                óR   € V P                   P                  4       P                  4       # )zþReturn the Gaussian weighting kernel used before orientation pooling.

A float64 input is weighted with the same window built in float64, not with this buffer, which holds it rounded
to float32.

Returns:
    Detached copy of the Gaussian kernel tensor.
)rŽ   rº   r»   r…   s   &r   Úget_weighting_kernelÚ#SIFTDescriptor.get_weighting_kernelG  s   € ð �w‰w�~‰~Ó×%Ñ%Ó'Ð'r   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# ©r   r6   r   r¸   )r   ry   s   "€r   r   rz   R  s#   ø€ ÷ <ñ <™UŸ\™\ð <©e¯l©lñ <r   c                ó¦  € \        VRRV P                   V P                   .4       V P                  P                  P	                  VP
                  4      P	                  VP                  4      pV P                  P                  pVe5   VP	                  VP
                  4      P	                  VP                  4      p\        VR4      pVR
,          pVR,          p\        WVV P                  4      w  rxV P                  p	VP
                  \        P                  8X  dg   \        V P                  4      \        P                   ! R4      ,          p
V P                  p\#        W»3Wª3RVP                  \        P                  R7      p	WyP%                  V4      P'                  V4      P	                  VP                  4      ,          p\        V P(                  4      V,          R\        P*                  ,          ,          p\        P,                  ! V4      pWÍ,
          pWÐP(                  ,          pV^,           V P(                  ,          pRV,
          V,          pWç,          p\        P.                  ! \1        V P(                  4       Uu. uF¼  p\2        P4                  ! VV8H  P	                  VP
                  4      V,          VV8H  P	                  VP
                  4      V,          ,           VVV P                  P6                  V P                  P8                  V P                  P:                  V P                  P<                  4      NK¾  	  up^4      pVP?                  ^4      p\A        V^R7      p\        PB                  ! VR	\        V PD                  4      4      p\A        V^R7      pV PF                  '       d   \I        VV P                  4      pV# u upi )zØCompute SIFT descriptors for square grayscale patches.

Args:
    input: Patch tensor shaped ``(B, 1, patch_size, patch_size)``.

Returns:
    Descriptor tensor of size ``(B, num_ang_bins * num_spatial_bins ** 2)``.
ÚBÚ1r^   r%   T©r±   r&   rO   ©Údimg        r_   r`   )%r	   rm   r›   rœ   r/   r&   r±   r“   rJ   r4   r"   rŽ   r   Úfloat64r#   r,   r)   r   Ú	expand_asÚtype_asrL   r-   rP   rE   ÚrangerA   Úconv2drq   r’   ÚdilationÚgroupsÚflattenr
   Úclampr„   rƒ   Ú	_rootsift)r†   r6   Ú	pk_weightÚpk_biasra   r    r!   r2   r3   rŽ   r¡   r    rU   Úbo0_big_Úwo1_big_Úbo0_bigÚbo1_bigÚwo0_bigÚwo1_bigÚiÚang_binss   &&                   r   ÚforwardÚSIFTDescriptor.forwardR  sÎ  € ô 	˜5 3¨°·±Ð/@ÀdÇoÁoÐEVÐ"XÔYØ—G‘G—N‘N×%Ñ% e§k¡kÓ2×5Ñ5°e·l±lÓCˆ	Ø—'‘'—,‘,ˆØÒØ—j‘j §¡Ó-×0Ñ0°·±Ó>ˆGä+¨E°6Ó:ˆà�7�^ˆØ�7�^ˆä2°2¸4¿8¹8ÓD‰ˆØ�W‰WˆØ�9‰9œŸ™Ô%ä˜$Ÿ/™/Ó*¬T¯YªY°s«^Õ;ˆEØ—‘ˆBÜ&¨ x°%°ÀÈcÏjÉjÔ`e×`mÑ`mÔnˆBØ—L‘L Ó%×-Ñ-¨cÓ2×5Ñ5°c·j±jÓAÕAˆÜ�d×'Ñ'Ó(¨3Õ.°#¼¿¹µ-Õ@ˆä—;’;˜uÓ%ˆØÕ#ˆØ×.Ñ.Õ.ˆØ˜Q•; $×"3Ñ"3Õ3ˆØ˜•> SÕ(ˆØ•.ˆä—9’9ô ˜t×0Ñ0Ô1óñ 2�Aô —’Ø ‘\×%Ñ% e§k¡kÓ2°WÕ<ÀÈ1Á×?PÑ?PÐQV×Q\ÑQ\Ó?]Ð`gÕ?gÕgØØØ—G‘G—N‘NØ—G‘G—O‘OØ—G‘G×$Ñ$Ø—G‘G—N‘Nöñ 2ñð ó
ˆð ×#Ñ# AÓ&ˆô ! ¨qÔ1ˆÜ—;’;˜x¨¬e°D·L±LÓ.AÓBˆÜ  ¨qÔ1ˆØ�=�=ˆ=Ü  ¨4¯8©8Ó4ˆHØˆùò-s   ÊCO)
r—   r˜   r„   r"   rL   rn   rB   rm   r›   rƒ   ©é)   é   é   Tçš™™™™™É?)r‚   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r‡   r•   r²   r¼   rÀ   rÞ   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r�   ry   s   @@r   ru   ru   µ   sO   ù‡ € ñ?÷B
ð 
÷!Lõ !L÷F
ó 
÷6/ð /÷	(ð 	(÷<÷ <ð <r   ru   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )r   Údescr"   r   )r   r   r#   )r   s   "r   r   r   ‘  s)   € ÷ ?ñ ?”E—L‘Lð ?¤uð ?´·±ñ ?r   c                ó^  € V P                   \        P                  8X  d\   \        P                  ! \        P
                  ! V P                  4       ^RR7      V,           4      P                  V P                   4      # \        P                  ! \        P
                  ! V ^RR7      V,           4      # )aI  L1-normalise and take the square root, the RootSIFT step, with a dtype-safe ``eps``.

``sqrt`` has an infinite backward at zero, and most bins of a SIFT histogram are zero, so ``eps`` keeps
the gradient finite. A float16 input cannot carry the 1e-10 guard -- it underflows to zero -- and the
smallest float16 normal, 6.1e-5, is not neutral: every empty bin would read ``sqrt(6.1e-5) = 0.0078``
and push the descriptor norm to ~1.004. The step is therefore computed in float32 for a float16 input
and cast back; float32 and float64 inputs take the same expression as before, unchanged.
gê-�™—q=)Úpr"   )r&   r   r'   r)   rA   Ú	normalizer#   r/   )rî   r"   s   &&r   rÓ   rÓ   ‘  sk   € ð ‡z�z”U—]‘]Ô"Ü�zŠzœ!Ÿ+š+ d§j¡j£l°a¸UÔCÀcÕIÓJ×MÑMÈdÏjÉjÓYÐYÜ�:Š:”a—k’k $¨!°Ô7¸#Õ=Ó>Ð>r   c                ó(   € V ^8„  d   QhR\         RR/# )r   Úlayoutr   Nrx   )r   s   "r   r   r   ¢  s   € ÷ sñ s¬#ð s°$ñ sr   c                 óH   € V \         9  d   \        R V : R\          24      hR# )zUnknown SIFT descriptor layout z; expected one of N)Ú_SIFT_DESCRIPTOR_LAYOUTSrp   )ró   s   &r   Ú_check_sift_descriptor_layoutrö   ¢  s,   € ØÔ-Ô-ÜÐ:¸6¹*ÐDVÔWoÐVpÐqÓrÐrñ .r   c                óR   € V ^8„  d   QhR\         R\         R\        \         ,          /# )r   rL   rn   r   )r   Úlist)r   s   "r   r   r   §  s*   € ÷ pñ p¤ð p´sð p¼tÄC½yñ pr   c                ó¦   € W,          p\        V4       UUu. uF,  p\        V 4       F  qD) V ,          V,          V,           NK  	  K.  	  upp# u uppi )zZFor each OpenCV descriptor position, the kornia position holding the same histogram value.)rÍ   )rL   rn   ÚcellsÚcellÚangles   &&   r   Ú_opencv_orderrý   §  sJ   € àÕ/€EäAFÀuÄÔoÁ¸Ô[`ÐamÖ[nÐRWˆf˜Õ$¨Õ-°×4Ð4Ñ[nÑ4ÁÒoÐoùÓos   —2Ac                óˆ   € V ^8„  d   QhR\         P                  R\        R\        R\        R\        R\         P                  /# )r   ÚdescriptorsÚsourceÚtargetrL   rn   r   )r   r   r8   r   )r   s   "r   r   r   ®  s\   € ÷ Tjñ TjÜ—‘ðTjäðTjô ðTjô ð	Tjô
 ðTjô ‡\�\ñTjr   c           	     ó  a a	€ \        V4       \        V4       V^8  g   V^8  d   \        RV RV 24      hW4,          V,          o	\        S P                  R,          S	8H  V V	3R l4       W8X  d   \	        \        S	4      4      pM@VR8X  d   \        W44      pM-^ .S	,          p\        \        W44      4       F	  w  rxWvV&   K  	  TpS P                  R\        P                  ! VS P                  \        P                  R7      4      # )aœ  Reorder SIFT descriptors between kornia's layout and OpenCV's.

``opencv_descs = convert_sift_descriptor_layout(descs, "kornia", "opencv")`` takes SIFT descriptors with the
descriptor dimension last, ``(*, A * S ** 2)``, and returns the same values reordered into the ``target``
layout, with the input's shape, dtype and device. For the ``(B, A * S ** 2, H_out, W_out)`` map of
:class:`DenseSIFTDescriptor`, move the channels last first and back afterwards:
``convert_sift_descriptor_layout(dense.movedim(1, -1), "kornia", "opencv").movedim(-1, 1)``. A reordering does
not make descriptors sampled by different methods equal.

Both layouts hold the same histogram values, one per angle bin :math:`a` and spatial cell :math:`(y, x)`
of the frame, with :math:`A` = ``num_ang_bins`` and :math:`S` = ``num_spatial_bins``:

- ``"kornia"``, the layout of every kornia SIFT descriptor (:class:`~kornia.feature.SIFTDescriptor`,
  :class:`~kornia.feature.SIFTDescriptorFromPyramid`, the channels of :class:`~kornia.feature.DenseSIFTDescriptor`,
  and :class:`~kornia.feature.SIFTFeature` and :class:`~kornia.feature.SIFTFeatureScaleSpace` with either
  ``descriptor_backend``): angle-major, value
  :math:`(a, y, x)` at index :math:`a S^2 + y S + x`. Bin :math:`a` is centred on the direction
  :math:`2 \pi a / A`, measured from :math:`+x` towards :math:`+y`, with :math:`y` growing downwards as image
  rows do.
- ``"opencv"``, the layout of OpenCV's ``cv2.SIFT``: spatial-major, index :math:`(y S + x) A + a'`, with angles
  measured from :math:`+x` towards :math:`-y`. A gradient in kornia's bin :math:`a` falls in OpenCV's bin
  :math:`a' = -a \bmod A`.

LightGlue's ``"sift"`` weights expect the ``"opencv"`` layout: convert kornia descriptors before passing them to
:class:`~kornia.feature.LightGlueMatcher` with ``"sift"``. The conversion only reorders values, so it applies
equally to SIFT and RootSIFT descriptors and keeps their scale; converting back restores the input exactly.

Args:
    descriptors: SIFT descriptors of shape ``(*, A * S ** 2)``.
    source: layout of ``descriptors``, ``"kornia"`` or ``"opencv"``.
    target: layout to return, ``"kornia"`` or ``"opencv"``.
    num_ang_bins: number of angle bins :math:`A`.
    num_spatial_bins: number of spatial bins :math:`S` per side.

Returns:
    The descriptors in the ``target`` layout, with the input's shape, dtype and device.

Raises:
    ValueError: for a layout other than ``"kornia"`` and ``"opencv"``, or a bin count below 1.
    BaseError: if the last dimension of ``descriptors`` is not ``A * S ** 2``.

See Also:
    - :class:`SIFTDescriptor`: SIFT descriptors of patches, in the ``"kornia"`` layout.
    - :class:`DenseSIFTDescriptor`: a map of SIFT descriptors, with the ``"kornia"`` layout along its channels.
    - :class:`SIFTDescriptorFromPyramid`: SIFT descriptors of LAFs, in the ``"kornia"`` layout.
    - :class:`LightGlueMatcher`: its ``"sift"`` weights expect the ``"opencv"`` layout.

Example:
    >>> descs = SIFTDescriptor(32)(torch.rand(4, 1, 32, 32))
    >>> opencv_descs = convert_sift_descriptor_layout(descs, "kornia", "opencv")
    >>> torch.equal(convert_sift_descriptor_layout(opencv_descs, "opencv", "kornia"), descs)
    True

z3SIFT bin counts must be positive. Got num_ang_bins=r}   c                  ó6   <€ R S RS P                   R,           2# )zBExpected descriptors of size num_ang_bins * num_spatial_bins**2 = z, got r@   )rR   )rÿ   rš   s   €€r   Ú<lambda>Ú0convert_sift_descriptor_layout.<locals>.<lambda>ô  s$   ø€ ØPÐQUÐPVÐV\Ð]h×]nÑ]nÐoqÕ]rÐ\sÑtr   ÚopencvrÇ   r@   )rö   rp   r   rR   rø   rÍ   rý   Ú	enumerateÚindex_selectr   Útensorr±   rT   )
rÿ   r   r  rL   rn   ÚorderÚinverseÚopencv_indexÚkornia_indexrš   s
   f&&&&    @r   Úconvert_sift_descriptor_layoutr  ®  sý   ù€ ôz " &Ô)Ü! &Ô)Ø�aÔÐ+¨aÔ/ÜØAÀ,ÀÐObÐcsÐbtÐuó
ð 	
ð Õ*Ð-=Õ=€DÜØ×Ñ˜"Õ Ñ%õ	
ôð ÔÜ”U˜4“[Ó!‰Ø	�8Ô	Ü˜lÓ=‰ð �#˜•*ˆÜ*3´MÀ,Ó4aÖ*bÑ&ˆLØ$0�LÓ!ñ +càˆØ×#Ñ# B¬¯ª°UÀ;×CUÑCUÔ]b×]gÑ]gÔ(hÓiÐir   c                ó”   € V ^8„  d   QhR\         P                  R\        R\        R\        R\        R\        R\         P                  /# )r   r6   rm   rL   rn   rƒ   r„   r   )r   r   r   r‹   r#   )r   s   "r   r   r     s_   € ÷ `ñ `Ü�<‰<ð`äð`ô ð`ô ð	`ô
 ð`ô ð`ô ‡\�\ñ`r   c                ó(   € \        WW4V4      ! V 4      # )zWCompute the sift descriptor.

See :class:`~kornia.feature.SIFTDescriptor` for details.
)ru   )r6   rm   rL   rn   rƒ   r„   s   &&&&&&r   Úsift_describer    s   € ô ˜*Ð4DÐPWÔXÐY^Ó_Ð_r   c                   óŽ   a a€ ] tR tRt oRtV3R lR ltRV3R lV 3R llltV3R lR ltV3R	 lR
 ltV3R lR lt	Rt
VtV ;t# )ÚDenseSIFTDescriptori  uw  Compute a SIFT descriptor at every position of a grayscale image, as a dense map.

``dsift = DenseSIFTDescriptor()``, then ``descs = dsift(image)`` takes grayscale images ``(B, 1, H, W)`` and
returns a descriptor map ``(B, num_ang_bins * num_spatial_bins ** 2, H_out, W_out)``, ``(B, 128, H_out, W_out)``
with the default bins: ``descs[b, :, i, j]`` is the SIFT descriptor of an upright square of
``num_spatial_bins * spatial_bin_size`` pixels (16 by default) placed as the Convention block gives, so every
output describes one fixed scale and orientation, and ``stride`` sets the spacing of the output grid. To describe
patches you have already sampled, use :class:`SIFTDescriptor` instead, and to describe LAFs at their own scale and
orientation, :class:`SIFTDescriptorFromPyramid`.

Convention:
    - Every output pixel is a SIFT descriptor of the image around the input position given below. Its
      ``num_spatial_bins`` x ``num_spatial_bins`` cells are ``spatial_bin_size`` pixels apart, each cell pooling a
      triangular window of ``spatial_bin_size`` pixels (see ``get_sift_pooling_kernel``), so the cells tile an
      extent of ``num_spatial_bins * spatial_bin_size`` pixels. The cell spacing is that of
      :class:`SIFTDescriptor` and of the VLFeat ``vl_dsift`` grid.
    - Output pixel ``(i, j)`` describes the neighbourhood centred on the input position
      ``x = j * stride - padding + (num_spatial_bins - 1) * spatial_bin_size / 2 - e / 2`` (``y`` likewise from
      ``i``), in pixel-centre coordinates where the first input pixel is at 0, with ``e`` 1 for an even
      ``spatial_bin_size`` and 0 for an odd one. The centre lies on a pixel when
      ``(num_spatial_bins - 1) * spatial_bin_size`` and ``e`` have the same parity, and half way between two
      pixels otherwise.
    - The channels are in kornia's angle-major SIFT layout, channel
      ``a * num_spatial_bins**2 + cy * num_spatial_bins + cx`` for angle bin ``a`` and cell ``(cy, cx)``, the entry
      order of :class:`SIFTDescriptor`; move them last before :func:`convert_sift_descriptor_layout`. Clipping,
      RootSIFT (the default) and the output for a flat neighbourhood are those of :class:`SIFTDescriptor` (see its
      Convention block), but the cells are not weighted by a Gaussian window.

Args:
    num_ang_bins: Number of angular bins. (8 is default)
    num_spatial_bins: Number of spatial bins per descriptor (4 is default). With an odd
        ``num_spatial_bins`` and an odd ``spatial_bin_size``,
        ``padding = (num_spatial_bins - 1) * spatial_bin_size / 2`` keeps the feature map size at ``stride=1``.
    spatial_bin_size: Size of a spatial bin in pixels, and the distance between neighbouring bins (4 is default)
    clipval: clipping value to reduce single-bin dominance
    rootsift: (bool) if True, RootSIFT (ArandjeloviÄ‡ et. al, 2012) is computed
    stride: step between neighbouring outputs in pixels (1 is default)
    padding: zero padding of the pooled bin maps in pixels, on every side (1 is default)

Returns:
    torch.Tensor: DenseSIFT descriptor of the image

Shape:
    - Input: ``(B, 1, H, W)``
    - Output: ``(B, num_ang_bins * num_spatial_bins ** 2, H_out, W_out)``, with
      ``H_out = (H + e + 2 * padding - (num_spatial_bins - 1) * spatial_bin_size - 1) // stride + 1`` and
      ``W_out`` likewise, where ``e`` is 1 for an even ``spatial_bin_size`` and 0 for an odd one. An image for
      which either would be below 1 raises ``RuntimeError``.

See Also:
    - :class:`SIFTDescriptor`: one descriptor per given patch, with the cells weighted by a Gaussian window.
    - :class:`SIFTDescriptorFromPyramid`: descriptors of given LAFs, each at its own scale and orientation.
    - :func:`convert_sift_descriptor_layout`: reorders the channels into OpenCV's layout, once moved last.

Example:
    >>> input =  torch.rand(2, 1, 200, 300)
    >>> SIFT = DenseSIFTDescriptor()
    >>> descs = SIFT(input) # 2x128x191x291

c                ó    <€ V ^8„  d   QhRS[ /# rw   rx   )r   ry   s   "€r   r   Ú DenseSIFTDescriptor.__annotate__R  s   ø€ ÷ 	
ñ 	
™#ñ 	
r   c                óÐ   € V P                   P                   R V P                   RV P                   RV P                   RV P
                   RV P                   RV P                   R2# )r|   r}   z, spatial_bin_size=r~   z	, stride=r   r€   )r�   r‚   rL   rn   Úspatial_bin_sizerƒ   rq   r„   r…   s   &r   r‡   ÚDenseSIFTDescriptor.__repr__R  s{   € à�~‰~×&Ñ&Ð'ð (Ø ×-Ñ-Ð.ð / Ø $× 5Ñ 5Ð6ð 7 Ø $× 5Ñ 5Ð6ð 7ØŸ™�ð 'Ø—k‘k�]ð #Ø—|‘|�n Að'ð	
r   c                óH   <€ V ^8„  d   QhRS[ RS[ RS[ RS[RS[RS[ RS[ RR	/# )
r   rL   rn   r  rƒ   r„   rq   r’   r   NrŠ   )r   ry   s   "€r   r   r  ]  s[   ø€ ÷ .'ñ .'áð.'ñ ð.'ñ ð	.'ñ
 ð.'ñ ð.'ñ ð.'ñ ð.'ð 
ñ.'r   c                ó,  <€ \         SV `  4        R V n        Wn        W n        W0n        WPn        W@n        W`n        Wpn	        \        V P
                  R7      P                  4       pV P                  RVP                  ^^VP                  ^ 4      VP                  ^4      4      4       \        P                   ! ^^VP                  ^ 4      VP                  ^4      3RRVP                  ^ 4      ^,          VP                  ^4      ^,          3R7      p	V	P"                  P$                  P'                  V P(                  4       W�n        \-        WV4      P                  4       p
V P                  RV
4       \        P                   ! VW^,          ,          W"3V P                  V P                  3RV P                  V P                  3V P
                  V P
                  3R7      pVP"                  P$                  P'                  V P.                  4       W°n        R# )	r�   r�   Ú_bin_pooling_kernel_weightF)r‘   rq   r“   r’   Ú_poolingconv_weight)r‘   rq   r“   r’   rÏ   N)r=   r=   )r”   r•   r"   rL   rn   r  r„   rƒ   rq   rB   rk   r#   r–   rŸ   rš   r   r™   rœ   r�   rž   r  Úbin_pooling_kernelr   r  ÚPoolingConv)r†   rL   rn   r  rƒ   r„   rq   r’   r¢   r  ÚPwr  r�   s   &&&&&&&&    €r   r•   ÚDenseSIFTDescriptor.__init__]  s±  ø€ ô 	‰ÑÔØˆŒØ(ÔØ 0ÔØ 0ÔØŒØ ŒØŒØŒô %¨4×+@Ñ+@ÔA×GÑGÓIˆØ×ÑÐ9¸2¿:¹:ÀaÈÈBÏGÉGÐTUËJÐXZ×X_ÑX_Ð`aÓXbÓ;cÔdÜŸYšYØØØŸ™ › R§W¡W¨Q£ZÐ0ØØØ—W‘W˜Q“Z 1•_ b§g¡g¨a£j°A¥oÐ6ô
Ðð 	×!Ñ!×&Ñ&×,Ñ,¨T×-LÑ-LÔMØ"4Ôä  ÐAQÓR×XÑXÓZˆØ×ÑÐ2°BÔ7Ü—i’iØØ¨QÕ.Õ.Ø)Ð<Ø—K‘K §¡Ð-ØØ—X‘X˜tŸx™xÐ(Ø×+Ñ+¨T×-BÑ-BÐCô
ˆð 	×Ñ×Ñ×%Ñ% d×&>Ñ&>Ô?Ø&Ör   c                ó4   <€ V ^8„  d   QhRS[ P                  /# rw   r¸   )r   ry   s   "€r   r   r  �  s   ø€ ÷ ?ñ ?¡E§L¡Lñ ?r   c                óf   € V P                   P                  P                  4       P                  4       # )zfReturn the pooling kernel for dense SIFT binning.

Returns:
    Detached copy of the pooling weights.
)r  rœ   rº   r»   r…   s   &r   r¼   Ú&DenseSIFTDescriptor.get_pooling_kernel�  s(   € ð ×&Ñ&×-Ñ-×4Ñ4Ó6×<Ñ<Ó>Ð>r   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# rÃ   r¸   )r   ry   s   "€r   r   r  •  s'   ø€ ÷ Jñ J©U¯\©\ð J¹e¿l¹lñ Jr   c                ó^   € \        V. RO4       \        WP                  V P                  4      # )zëReturn unnormalised angular histogram maps before spatial pooling.

The result has shape ``(B, num_ang_bins, H, W)``.  It is useful when a
caller shares an image pyramid between orientation assignment and sparse
descriptor extraction.
©rÅ   rÆ   ÚHÚW)r	   rb   rL   r"   )r†   r6   s   &&r   Úget_gradient_histogramsÚ+DenseSIFTDescriptor.get_gradient_histograms•  s&   € ô 	˜5Ò"6Ô7Ü% e×->Ñ->ÀÇÁÓIÐIr   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# rÃ   r¸   )r   ry   s   "€r   r   r  Ÿ  s#   ø€ ÷ 5ñ 5™UŸ\™\ð 5©e¯l©lñ 5r   c                óò  € \        V. RO4       VP                  4       w  r#rEV P                  P                  P	                  VP
                  4      P	                  VP                  4      pV P                  P                  pVe5   VP	                  VP
                  4      P	                  VP                  4      pV P                  P                  P	                  VP
                  4      P	                  VP                  4      pV P                  P                  p	V	e5   V	P	                  VP
                  4      P	                  VP                  4      p	V P                  V4      p
\        P                  ! \        V P                  4       Uu. uFŽ  p\        P                  ! V
RW»^,           13,          P!                  4       VVV P                  P"                  V P                  P$                  V P                  P&                  V P                  P(                  4      NK�  	  up^4      p\        P                  ! VVV	V P                  P"                  V P                  P$                  V P                  P&                  V P                  P(                  4      p\+        V^R7      P-                  ^ \/        V P0                  4      4      p\+        V^R7      pV P2                  '       d   \5        WàP6                  4      pV# u upi )zêCompute dense SIFT descriptors over a full image grid.

Args:
    input: Grayscale image tensor with shape ``(B, 1, H, W)``.

Returns:
    Dense descriptor map tensor with channel dimension
    ``num_ang_bins * num_spatial_bins**2``.
r;   rÈ   r&  )r	   rš   r  rœ   r/   r&   r±   r“   r  r)  r   rE   rÍ   rL   rA   rÎ   Ú
contiguousrq   r’   rÏ   rÐ   r
   rÒ   r#   r„   rƒ   rÓ   r"   )r†   r6   Ú_BÚ_CHÚ_WÚ_HÚbin_pooling_weightÚbin_pooling_biasÚpoolingconv_weightÚpoolingconv_biasrZ   rÜ   rÝ   Úout_no_normÚouts   &&             r   rÞ   ÚDenseSIFTDescriptor.forwardŸ  sS  € ô 	˜5Ò"6Ô7àŸ*™*›,‰ˆ�Ø!×4Ñ4×;Ñ;×>Ñ>¸u¿{¹{ÓK×NÑNÈuÏ|É|Ó\ÐØ×2Ñ2×7Ñ7ÐØÒ'Ø/×2Ñ2°5·;±;Ó?×BÑBÀ5Ç<Á<ÓPÐØ!×-Ñ-×4Ñ4×7Ñ7¸¿¹ÓD×GÑGÈÏÉÓUÐØ×+Ñ+×0Ñ0ÐØÒ'Ø/×2Ñ2°5·;±;Ó?×BÑBÀ5Ç<Á<ÓPÐØ×1Ñ1°%Ó8ˆ
ô —9’9ô ˜t×0Ñ0Ô1óñ 2�Aô —’Ø˜q !¨!¥e )˜|Õ,×7Ñ7Ó9Ø&Ø$Ø×+Ñ+×2Ñ2Ø×+Ñ+×3Ñ3Ø×+Ñ+×4Ñ4Ø×+Ñ+×2Ñ2öñ 2ñð ó
ˆô  —h’hØØØØ×Ñ×#Ñ#Ø×Ñ×$Ñ$Ø×Ñ×%Ñ%Ø×Ñ×#Ñ#ó
ˆô ˜K¨QÔ/×5Ñ5°a¼¸t¿|¹|Ó9LÓMˆÜ˜C QÔ'ˆØ�=�=ˆ=Ü˜C§¡Ó*ˆCØˆ
ùò9s   ÆBK4)
r  r  r„   r"   rL   rn   rB   rƒ   r  rq   )râ   rã   rã   Trä   r=   r=   )r‚   rå   ræ   rç   rè   r‡   r•   r¼   r)  rÞ   ré   rê   rë   rì   s   @@r   r  r    sE   ù‡ € ñ;÷z	
ð 	
÷.'õ .'÷`?ð ?÷Jð J÷5÷ 5ð 5r   r  )é   )Úkorniar  )râ   rã   rà   )"r,   Útypingr   r   r   r   r   Útorch.nn.functionalr   Ú
functionalrA   Úkornia.core.checkr   r	   Úkornia.core.utilsr
   Úkornia.filtersr   r   r4   rJ   r[   rb   rk   rs   ÚModuleru   rÓ   rõ   rö   rý   r  r  r  © r   r   Ú<module>rC     s˜   ðó$ ß )Ó )ã ß Ð Ý ç >Ý +Ý 0õ4õ(õ@Lõ2õ4d÷
+õ"ôJY�R—Y‘Yô Yõx?ð 0Ð õsõ
p÷Tj÷n`ô@˜"Ÿ)™)ö @r   