+
    åûj�  ã                   ó    a € R t0 t ^ RIHt ^ RIt^ RIHt ]P
                  P                  P                  4       t] ^ k R R lt	]3R R llt
R# )	é    )ÚIterableN)Únnc                óR   € V ^8„  d   QhR\         \        P                  ,          RR/# )é   ÚlayersÚreturnN)r   r   ÚModule)Úformats   "ÚRC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\feature\_layout.pyÚ__annotate__r      s#   € ÷ +ñ +¤X¬b¯i©iÕ%8ð +¸Tñ +ó    c                ój   € V  F,  p\        V\        P                  4      '       g   K%  RVn        K.  	  R# )a]  Mark the ``nn.Conv2d`` layers among ``layers`` for a scripted layer loop that calls :func:`_patch_conv_layout`.

``_mark_patch_convolutions(layers)`` sets ``_patch_conv_input = True`` on each ``nn.Conv2d`` in ``layers`` (not on
nested ones). A ``forward`` that loops over its layers sets the layout before each layer that passes
``isinstance(layer, nn.Conv2d)``, else before one with ``getattr(layer, "_patch_conv_input", False)``. Eager needs
only the ``isinstance``. TorchScript resolves it against the one ``Conv2d`` class type it compiled first in the
process, and gives every ``Conv2d`` with other constants a mangled type that fails it, so a scripted loop would
skip the layout before some or all of its convolutions, depending on what had been scripted before it, and convolve
in a different layout from eager. TorchScript reads the attribute of each submodule instead. The networks call this
from ``__prepare_scriptable__``, which ``torch.jit.script`` runs on every submodule before compiling, so the mark
also reaches a convolution swapped in after construction and a model unpickled from an earlier kornia.
TN)Ú
isinstancer   ÚConv2dÚ_patch_conv_input)r   Úlayers   & r   Ú_mark_patch_convolutionsr      s'   € ó ˆÜ�eœRŸY™Y×'Ô'Ø&*ˆEÖ#ó r   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )r   ÚxÚcpu_has_onednnr   )ÚtorchÚTensorÚbool)r
   s   "r   r   r   -   s,   € ÷ !ñ !œ%Ÿ,™,ð !¼ð !ÔSX×S_ÑS_ñ !r   c                ó¦  € V P                   P                  pVR8X  d(   V'       d    V P                  \        P                  8X  gm   VR8X  d0   V P                  \        P                  \        P
                  39   g7   VR8X  dP   V P                  \        P
                  \        P                  39   d!   V P                  \        P                  R7      # V # )a×  Return a patch network's convolution input in the memory format its device convolves fastest in.

The patch descriptor and shape networks (HardNet, HardNet8, SOSNet, TFeat, HyNet, AffNet, OriNet) call this where
their convolutions start. It changes the strides only, never the values; the networks return the same numbers in
either layout up to rounding, because a backend may pick other convolution kernels for channels-last (bitwise equal
on MPS; within float32 rounding on x86 oneDNN).

- MPS, float32 and float16: channels-last. The convolution bodies run 1.04-1.38x faster on an Apple M1 with torch
  2.14, and extracting 2048 patches and describing them with HardNet 1.07x (float32) and 1.11x (float16).
- CUDA, float16 and bfloat16: channels-last. On an RTX 4090 with torch 2.14 the forwards on 2048 patches run
  1.08-1.44x faster; on 512 patches the result is mixed (0.83-1.30x across runs, the losses in float16).
- CPU float32 with oneDNN: channels-last, which avoids oneDNN's activation reorders: 1.2-1.5x on an x86 i7-14700K,
  except HardNet8, which gains at the default thread count and is 0.95x on 8 threads. A CPU build without oneDNN,
  such as the macOS arm64 wheels, convolves with NNPACK, which takes only the default layout, so the input is left
  alone instead of paying a copy that changes nothing.
- Everything else keeps the input's layout. CUDA float32 is among them: under cuDNN's default TF32 convolutions,
  six of the seven bodies are 0.87-1.00x in channels-last at 2048 patches and more.

Args:
    x: convolution input ``(B, C, H, W)``.
    cpu_has_onednn: whether CPU convolutions run on oneDNN. Leave the default, which asks the torch build.

Returns:
    ``x``, as a channels-last copy where that layout is faster.
ÚcpuÚmpsÚcuda)Úmemory_format)	ÚdeviceÚtypeÚdtyper   Úfloat32Úfloat16Úbfloat16ÚtoÚchannels_last)r   r   r   s   && r   Ú_patch_conv_layoutr'   -   s„   € ð4 �X‰X�]‰]€Fà	�5ŒŸ^°·±¼5¿=¹=Ô0HØ�eŒO §¡¬E¯M©M¼5¿=¹=Ð+IÔ IØ�fÔ §¡¬U¯]©]¼E¿N¹NÐ,KÔ!Kà�t‰t¤%×"5Ñ"5ˆtÓ6Ð6Ø€Hr   c                ó@   € V ^8„  d   Qh/ ^ \         9   d
   \        ;R&   # )r   Ú_CPU_HAS_ONEDNN)Ú__conditional_annotations__r   )r
   s   "r   r   r      s   € × $Ñ $÷ =Ò <”Ñ <ò %r   )r*   Úcollections.abcr   r   r   ÚbackendsÚmkldnnÚis_availabler)   r   r'   r   )r*   s   @r   Ú<module>r/      sG   øð÷$ %Ò $ã Ý ð Ÿ™×-Ñ-×:Ñ:Ó<€Ó <õ+ð$ @O÷ !ñ !r   