+
    Cåûjø  ã                   óÂ   a € R t0 t R t^ RIt^RIHtHt ]P                  ]P                  3tRt	Rs
] ^ k R R ltR R ltR R	 ltR
 R ltR R ltR R ltR R ltR# )aõ  
Python override for aten::linalg_polar (polar decomposition A = U @ H).

This override is a CUDA-only accelerator: when nvmath-python is available and
the cuSOLVER runtime exposes Xpolar, it computes the decomposition with the
QR-based Dynamically Weighted Halley (QDWH) algorithm. For every other case --
CPU, ROCm, complex inputs, missing/old nvmath, or unsupported shapes -- the
cond returns False and the router falls through to the structured aten kernel,
which computes the same decomposition via the SVD. That fallthrough is a
correct, fully-functional kernel (it also backs compile/export), so this
override never needs to provide its own CPU/SVD path.

Both the functional (linalg_polar) and out= (linalg_polar.out) overloads are
overridden so the two call forms use the same algorithm. Only single 2-D
matrices are accelerated: cuSOLVER Xpolar has no batched API, so a batched
input would require a Python loop that is slower than the batched SVD kernel;
batched inputs therefore fall through to aten.
N)Únvmath_utilsÚregistryi¨/  c                ó$   € V ^8„  d   QhR\         /# )é   Úreturn)Úbool)Úformats   "ÚXC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\_native\ops\polar\impl.pyÚ__annotate__r
   *   s   € ÷ ñ ”tñ ó    c                  ó4  € \         fŒ   \        P                  P                  e   R M\        P
                  ! 4       p \        P                  P                  R J ;'       d5    \        P                  ! 4       R J ;'       d    V R J;'       d
    V \        8¬  s \         # ©N)Ú_nvmath_availableÚtorchÚversionÚhipr   Úcusolver_versionÚnvmath_unavailable_reasonÚ_MIN_CUSOLVER_VERSION)r   s    r	   Ú_check_nvmathr   *   s�   € äÒ ô
 —M‘M×%Ñ%Ò1‰D´|×7TÒ7TÓ7Vð 	ô �M‰M×Ñ Ð%÷ 1ð 1Ü×6Ò6Ó8¸DÐ@÷1ð 1à˜tÐ#÷1ð 1ð Ô0Ñ0ð	 	ô Ðr   c                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\        /# ©r   ÚAÚUÚHr   ©r   ÚTensorr   )r   s   "r	   r
   r
   <   s4   € ÷ ñ ”E—L‘Lð ¤U§\¡\ð ´e·l±lð Ätñ r   c                 óú  € V P                   w  r4VP                  V P                  8H  ;'       dÎ    VP                  V P                  8H  ;'       d­    VP                  V P                  8H  ;'       dŒ    VP                  V P                  8H  ;'       dk    \        VP                   4      W438H  ;'       dJ    \        VP                   4      WD38H  ;'       d)    VP	                  4       ;'       d    VP	                  4       # r   )ÚshapeÚdtypeÚdeviceÚtupleÚis_contiguous)r   r   r   ÚmÚns   &&&  r	   Ú_out_matchesr%   <   sÜ   € ð �7‰7�D€Aà	�‰�1—7‘7Ñ÷ 	ð 	Ø�G‰G�q—w‘wÑ÷	ð 	à�H‰H˜Ÿ™Ñ ÷	ð 	ð �H‰H˜Ÿ™Ñ ÷	ð 	ô �!—'‘'‹N˜q˜fÑ$÷		ð 	ô
 �!—'‘'‹N˜q˜fÑ$÷	ð 	ð �O‰OÓ÷	ð 	ð �O‰OÓð	r   c                óD   € V ^8„  d   QhR\         P                  R\        /# ©r   r   r   r   )r   s   "r	   r
   r
   O   s   € ÷ ñ œŸ™ð ¼$ñ r   c                 ó†  € V P                   \        9  d   R # V P                  4       ^8w  g<   V P                  ^ 4      V P                  ^4      8  g   V P                  ^4      ^ 8X  d   R # \	        4       '       g   R # VP                  R4      VP                  R4      rCVf   Ve   Ve   Ve   \        WV4      '       g   R # R# )Fr   r   T)r   Ú_XPOLAR_DTYPESÚdimÚsizer   Úgetr%   )r   ÚargsÚkwargsr   r   s   &*,  r	   Ú_polar_cond_cudar/   O   s�   € ð 	‡w�w”nÔ$ÙØ‡u�uƒw�!„|�q—v‘v˜a“y 1§6¡6¨!£9Ô,°·±°q³	¸Q´ÙÜ�?Š?Ùð �:‰:�c‹?˜FŸJ™J s›O€qØ‚}˜šØŠ9˜š	¬°a¸A×)>Ò)>ÙÙr   c                ó<   € V ^8„  d   QhR\         P                  RR/# )r   r   r   z(tuple[torch.Tensor, torch.Tensor] | None)r   r   )r   s   "r	   r
   r
   d   s   € ÷ ñ ”5—<‘<ð Ð$Nñ r   c                 óT   € ^RI Hp  V! V 4      w  r#pW#3#   \         d    Rs R# i ; i)é   )Úpolar_xpolarFN)Únvmath_implr3   Ú	Exceptionr   )r   r3   r   r   Ú_s   &    r	   Ú_run_xpolarr7   d   s:   € õ *ðÙ˜q“/‰ˆˆaØˆtˆøÜô ð "ÐÚð	ús   ˆ –'¦'c                óŽ   € V ^8„  d   QhR\         P                  R\        \         P                  \         P                  3,          /# r'   ©r   r   r!   )r   s   "r	   r
   r
   t   s0   € ÷ *ñ *œŸ™ð *¬¬u¯|©|¼U¿\¹\Ð/IÕ)Jñ *r   c                 óÎ   € \        V 4      pVf4   \        P                  P                  P                  P                  V 4      # Vw  r#VP                  4       VP                  4       3# r   )r7   r   ÚopsÚatenÚlinalg_polarÚdefaultÚ
contiguous)r   Úresultr   r   s   &   r	   Ú_polar_impl_cudarA   t   sM   € Ü˜‹^€FØ‚~Ü�y‰y�~‰~×*Ñ*×2Ñ2°1Ó5Ð5à�D€AØ�<‰<‹>˜1Ÿ<™<›>Ð)Ð)r   c          
      óÎ   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\        \         P                  \         P                  3,          /# r   r9   )r   s   "r	   r
   r
   }   sJ   € ÷ 	ñ 	Ü‡|�|ð	Ü Ÿ<™<ð	Ü,1¯L©Lð	ä
Œ5�<‰<œŸ™Ð%Õ&ñ	r   c                óÜ   € \        V 4      pVf6   \        P                  P                  P                  P                  WVR7      # Vw  rEVP                  V4       VP                  V4       W3# )N)r   r   )r7   r   r;   r<   r=   ÚoutÚcopy_)r   r   r   r@   ÚU_qdwhÚH_qdwhs   &$$   r	   Ú_polar_out_impl_cudarH   }   sZ   € ô ˜‹^€FØ‚~Ü�y‰y�~‰~×*Ñ*×.Ñ.¨q¸Ð.Ó;Ð;Ø�N€FØ‡G�GˆF„OØ‡G�GˆF„OØˆ4€Kr   c                ó   € V ^8„  d   QhRR/# )r   r   N© )r   s   "r	   r
   r
   ‰   s   € ÷ ñ ˜dñ r   c            	      óö   € \         P                  P                  P                  4       '       g   R # \        P
                  ! RRRR\        \        R7       \        P
                  ! RRRR\        \        R7       R # )NÚnativer<   r=   ÚCUDA)ÚcondÚimplzlinalg_polar.out)	r   ÚbackendsÚcudaÚis_builtr   Úregister_op_overrider/   rA   rH   rJ   r   r	   Úregister_to_dispatchrT   ‰   sb   € ô �>‰>×Ñ×'Ñ'×)Ò)ÙÜ×!Ò!ØØØØÜÜõô ×!Ò!ØØØØÜÜ!÷r   c                ó8   € V ^8„  d   Qh/ ^ \         9   d   R;R&   # )r   zbool | Noner   ©Ú__conditional_annotations__)r   s   "r	   r
   r
      s    € ÷ ñ ÷L (Ò '�=Ñ 'òMr   )rW   Ú__doc__r   Ú r   r   Úfloat32Úfloat64r)   r   r   r   r%   r/   r7   rA   rH   rT   r
   rV   s   @r	   Ú<module>r\      s]   øðöó& ç &ð —-‘- §¡Ð/€ð Ð ð $(Ð Ó 'õõ$õ&õ*õ *õ	÷r   