ó
    Eñi=M  ã                   óú  • S SK r S SKrS SKJr  S SKrS SKJr  S\ R                  4S jr	S\ R                  4S jr
S\ R                  4S jrS\SS4S	 jrS\ R                  4S
 jrS\ R                  4S jrS\ R                  4S jrS\\   4S jr    S S\S\S\S-  S\S-  S\S-  S\S\\\4   4S jjr " S S5      r " S S5      r S!S\\-  S\\   S-  S\\\S4   -  4S jjr S"S\S\S\S\4S jjrg)#é    N)ÚAny)Ú_get_device_indexÚreturnc                  ó
  •  SS K n [        R                  " [        U R	                  S5      S   5      5      nUR                  Ul        UR                  Ul        UR                   Ul        UR$                  Ul        UR(                  Ul        U$ ! [
        [        4 ad    [        R                  S:X  a7  [        R                  " S[        R                  R                  S    S35      n N²[        R                  " S5      n NÊf = f)Nr   Úamdhip64Úwin32Ú	amdhip64_ú.dllzlibamdhip64.so)Úrocm_sdkÚctypesÚCDLLÚstrÚfind_librariesÚImportErrorÚ
IndexErrorÚsysÚplatformÚtorchÚversionÚhipÚhipGetErrorStringÚcuGetErrorStringÚhipModuleLoadDataÚcuModuleLoadDataÚhipModuleGetFunctionÚcuModuleGetFunctionÚhipModuleLaunchKernelÚcuLaunchKernelÚhipFuncSetAttributeÚcuFuncSetAttribute)r   Úlibs     ÚN/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/cuda/_utils.pyÚ_get_hip_runtime_libraryr#      sÒ   € ð	0ãä�kŠkœ#˜h×5Ñ5°jÓAÀ!ÑDÓEÓFˆð ×0Ñ0€CÔØ×0Ñ0€CÔØ!×6Ñ6€CÔØ×2Ñ2€CÔØ ×4Ñ4€CÔØ€Jøô œÐ$ó 0Ü�<‰<˜7Ó"Ü—+’+ 	¬%¯-©-×*;Ñ*;¸AÑ*>Ð)?¸tÐDÓEŠCä—+’+Ð.Ó/ŠCð	0ús   ‚5B ÂADÃ)DÄDc                  ó‚   • [         R                  S:X  a  [        R                  " S5      $ [        R                  " S5      $ )Nr   z
nvcuda.dllzlibcuda.so.1)r   r   r   r   © ó    r"   Ú_get_cuda_libraryr'   "   s,   € Ü
‡|�|�wÓÜ�{Š{˜<Ó(Ð(ä�{Š{˜>Ó*Ð*r&   c                  óh   • [         R                  R                  (       a
  [        5       $ [	        5       $ ©N)r   r   r   r#   r'   r%   r&   r"   Ú_get_gpu_runtime_libraryr*   *   s!   € Ü‡}�}××Ü'Ó)Ð)ä Ó"Ð"r&   Úresultc                 ó  • U S:X  a  g [         R                  " 5       n[        5       nUR                  U [         R                  " U5      5        UR
                  b  UR
                  R                  5       OSn[        SU 35      e)Nr   úUnknown CUDA errorúCUDA error: )r   Úc_char_pr*   r   ÚbyrefÚvalueÚdecodeÚRuntimeError)r+   Úerr_strÚlibcudaÚerror_messages       r"   Ú_check_cudar7   2   sn   € Ø�ƒ{ØÜ�oŠoÓ€GÜ&Ó(€GØ×Ñ˜V¤V§\¢\°'Ó%:Ô;à")§-¡-Ñ";ˆ�‰×ÑÔÐAUð ô ˜ m _Ð5Ó
6Ð6r&   c                  ó  •  SS K n [        R                  " [        U R	                  S5      S   5      5      nUR                  Ul        UR                  Ul        UR"                  Ul        UR&                  Ul        UR*                  Ul        UR.                  Ul        UR2                  Ul        UR6                  Ul        UR:                  Ul        UR>                  Ul         U$ ! [
        [        4 a–    [        R                  S:X  ah  SR                  S[        R                  R                  S   S[        R                  R                  S   /5      n[        R                  " SU S35      n GN8[        R                  " S5      n GNQf = f)	Nr   Úhiprtcr   Ú Ú0é   r
   zlibhiprtc.so)!r   r   r   r   r   r   r   r   r   Újoinr   r   r   ÚhiprtcGetErrorStringÚnvrtcGetErrorStringÚhiprtcCreateProgramÚnvrtcCreateProgramÚhiprtcDestroyProgramÚnvrtcDestroyProgramÚhiprtcCompileProgramÚnvrtcCompileProgramÚhiprtcGetCodeSizeÚnvrtcGetCUBINSizeÚhiprtcGetCodeÚnvrtcGetCUBINÚhiprtcGetProgramLogSizeÚnvrtcGetProgramLogSizeÚhiprtcGetProgramLogÚnvrtcGetProgramLogÚhiprtcAddNameExpressionÚnvrtcAddNameExpressionÚhiprtcGetLoweredNameÚnvrtcGetLoweredName)r   r!   Úversion_strs      r"   Ú_get_hiprtc_libraryrS   >   sA  € ð.ãä�kŠkœ#˜h×5Ñ5°hÓ?ÀÑBÓCÓDˆð "×6Ñ6€CÔØ ×4Ñ4€CÔØ!×6Ñ6€CÔØ!×6Ñ6€CÔØ×1Ñ1€CÔØ×)Ñ)€CÔØ!$×!<Ñ!<€CÔØ ×4Ñ4€CÔØ!$×!<Ñ!<€CÔØ!×6Ñ6€CÔØ€Jøô) œÐ$ó .Ü�<‰<˜7Ó"ØŸ'™'Ø”e—m‘m×'Ñ'¨Ñ*¨C´·±×1BÑ1BÀ1Ñ1EÐFóˆKô —+’+  { m°4Ð8Ó9‹Cä—+’+˜nÓ-‹Cð.ús   ‚5C# Ã#B	F	Å/F	ÆF	c                  ó*  • [        [        R                  R                  R	                  S5      S   5      n [
        R                  S:X  a  SU  S3/nOSU  3S/nU H  n [        R                  " U5      s  $    [        S5      e! [         a     M6  f = f)	NÚ.r   r   Únvrtc64_z0_0.dllzlibnvrtc.so.zlibnvrtc.soz Could not find any NVRTC library)
Úintr   r   ÚcudaÚsplitr   r   r   r   ÚOSError)Úmajor_versionÚ
nvrtc_libsÚlib_names      r"   Ú_get_nvrtc_libraryr^   [   s�   € ÜœŸ™×*Ñ*×0Ñ0°Ó5°aÑ8Ó9€MÜ
‡|�|�wÓà�}�o WÐ-ð
‰
ð
 ˜=˜/Ð*Øð
ˆ
ó ˆð	Ü—;’;˜xÓ(Ò(ñ ô
 Ð4Ó
5Ð5øô ó 	Úð	ús   ÁBÂ
BÂBc                  óh   • [         R                  R                  (       a
  [        5       $ [	        5       $ r)   )r   r   r   rS   r^   r%   r&   r"   Ú_get_gpu_rtc_libraryr`   n   s#   € ô ‡}�}××Ü"Ó$Ð$ä!Ó#Ð#r&   c                  ó¸   • SSK Jn Jn  S1nU Vs/ s H  o3U;  d  M
  UPM     nn[        R                  R
                  (       a  UR                  U 5        U$ s  snf )z�
Get HIPCC/NVCC flags that are compatible with NVRTC compilation.

Returns:
    List of HIPCC/NVCC flags that can be safely used with NVRTC.
r   )ÚCOMMON_HIPCC_FLAGSÚCOMMON_NVCC_FLAGSz--expt-relaxed-constexpr)Útorch.utils.cpp_extensionrb   rc   r   r   r   Úextend)rb   rc   Únvrtc_unsupported_flagsÚflagÚcompatible_flagss        r"   Ú_get_gpu_rtc_compatible_flagsri   w   sc   € ÷ Pð 	#ðÐñ +óÚ*�Ð:QÑ.Q�Ñ*ð ð ô ‡}�}××Ø×ÑÐ 2Ô3àÐùòs
   �	A�AÚkernel_sourceÚkernel_nameÚcompute_capabilityÚcuda_include_dirsÚnvcc_optionsÚauto_pchc           
      ób	  ^^• SSK n[        5       mSmS[        SS4UU4S jjnU R                  S5      nUcv  UR                  R                  UR                  R                  5       5      n	UR                  R                  (       a  U	R                   nOU	R                   U	R                   3n/ n
UR                  R                  (       a#  U
R                  SU 3R                  5       5        O"U
R                  SU 3R                  5       5        SS	KJn  U" S
5      nU H%  nU
R                  SU 3R                  5       5        M'     U(       a+  U H%  nU
R                  SU 3R                  5       5        M'     U(       a[  [        UR                  R                  5      S:  a"  [!        SUR                  R                   35      eUc  / nUR                  S5        U(       a)  U H#  nU
R                  UR                  S5      5        M%     [#        5       nU
R%                  U Vs/ s H  nUR                  S5      PM     sn5        ['        U
5      n[(        R*                  U-  " U
6 n[(        R,                  " 5       nU" TR/                  [(        R0                  " U5      UU S3R                  5       SSS5      5        UR                  S5      nU" TR3                  UU5      5        TR5                  UUU5      nUT:w  a“  [(        R6                  " 5       nTR9                  U[(        R0                  " U5      5        [(        R:                  " UR<                  5      nTR?                  UU5        [A        SUR<                  RC                  5        35      e[(        R6                  " 5       nU" TRE                  U[(        R0                  " U5      5      5        [(        R:                  " UR<                  5      nU" TRG                  UU5      5        [(        R*                  " 5       nU" TRI                  UU[(        R0                  " U5      5      5        UR<                  b  UR<                  RC                  5       nOSnTRK                  [(        R0                  " U5      5        URL                  U4$ s  snf )a•  
Compiles a CUDA kernel using NVRTC and returns the PTX code.

Args:
    kernel_source (str): The CUDA kernel source code as a string
    kernel_name (str): The name of the kernel function to compile
    compute_capability (str, None): The compute capability to target (e.g., "86").
                                       If None, will detect from current device.
    cuda_include_dirs (list, None): List of directories containing CUDA headers
    nvcc_options (list, None): Additional options to pass to NVRTC
    auto_pch (bool): Enable automatic precompiled headers (CUDA 12.8+)

Returns:
    Tuple[bytes, str]: The compiled PTX code and mangled kernel name
r   Nr+   r   c                 óö   >• U T:w  ar  [         R                  " 5       nTR                  U [         R                  " U5      5        UR                  b  UR                  R                  5       OSn[        SU 35      eg )Nr-   r.   )r   r/   r?   r0   r1   r2   r3   )r+   r4   r6   ÚNVRTC_SUCCESSÚlibnvrtcs      €€r"   Úcheck_nvrtcÚ#_nvrtc_compile.<locals>.check_nvrtc°   so   ø€ Ø�]Ó"Ü—o’oÓ'ˆGØ×(Ñ(¨´·²¸gÓ1FÔGð —=‘=Ñ,ð —‘×$Ñ$Ô&à)ð ô
  ¨m¨_Ð=Ó>Ð>ð #r&   úutf-8z--offload-arch=z--gpu-architecture=sm_)Úinclude_pathsrX   z-Iz12.8zPCH requires CUDA 12.8+, got z--pchz.cuzKernel compilation failed:
r:   )'Ú
torch.cudar`   rW   ÚencoderX   Úget_device_propertiesÚcurrent_devicer   r   ÚgcnArchNameÚmajorÚminorÚappendrd   rw   r   ÚAssertionErrorri   re   Úlenr   r/   Úc_void_prA   r0   rO   rE   Úc_size_trK   Úcreate_string_bufferr1   rM   r3   r2   rG   rI   rQ   rC   Úraw)rj   rk   rl   rm   rn   ro   r   rt   Úsource_bytesÚpropsÚoptionsrw   Úcuda_include_pathsÚ	cuda_pathÚ	directoryÚoptionÚnvrtc_compatible_flagsrg   Únum_optionsÚoptions_arrayÚprogÚc_kernel_nameÚresÚlog_sizeÚlogÚbinary_sizeÚbinaryÚc_mangled_nameÚmangled_namerr   rs   s                                @@r"   Ú_nvrtc_compiler™   �   sö  ù€ ó0 ô $Ó%€Hð €Mð	?œCð 	? D÷ 	?ð 	?ð !×'Ñ'¨Ó0€Lð Ñ!Ø—
‘
×0Ñ0°·±×1JÑ1JÓ1LÓMˆØ�=‰=××Ø$)×$5Ñ$5Ð#6Ñà$)§K¡K =°·±°Ð!>Ðð €GØ‡}�}××Ø�‰˜Ð);Ð(<Ð=×DÑDÓFÕGà�‰Ð/Ð0BÐ/CÐD×KÑKÓMÔNõ 8á& vÓ.ÐÛ'ˆ	Ø�‰˜˜I˜;Ð'×.Ñ.Ó0Ö1ñ (ö Û*ˆIØ�N‰N˜R 	˜{Ð+×2Ñ2Ó4Ö5ñ +ö Üˆu�}‰}×!Ñ!Ó" VÓ+Ü Ð#@ÀÇÁ×ASÑASÐ@TÐ!UÓVÐVØÑØˆLØ×Ñ˜GÔ$ö Û"ˆFØ�N‰N˜6Ÿ=™=¨Ó1Ö2ñ #ô ;Ó<ÐØ‡N�NÑ5KÓLÒ5K¨T�D—K‘K Ö(Ñ5KÑLÔMô �g“,€KÜ—_‘_ {Ò2°WÐ=€Mô �?Š?Ó€DÙØ×#Ñ#Ü�LŠL˜ÓØØˆm˜3Ð×&Ñ&Ó(ØØØó	
ô	ð  ×&Ñ& wÓ/€MÙ�×/Ñ/°°mÓDÔEð ×
&Ñ
& t¨[¸-Ó
H€Cð ˆmÓä—?’?Ó$ˆØ×'Ñ'¨¬f¯lªl¸8Ó.DÔEÜ×)Ò)¨(¯.©.Ó9ˆØ×#Ñ# D¨#Ô.ÜÐ9¸#¿)¹)×:JÑ:JÓ:LÐ9MÐNÓOÐOô —/’/Ó#€KÙ�×*Ñ*¨4´·²¸kÓ1JÓKÔLÜ×(Ò(¨×):Ñ):Ó;€FÙ�×&Ñ& t¨VÓ4Ô5ô —_’_Ó&€NÙØ×$Ñ$ T¨=¼&¿,º,À~Ó:VÓWôð ×ÑÑ'Ø%×+Ñ+×2Ñ2Ó4‰àˆà× Ñ ¤§¢¨dÓ!3Ô4ð �:‰:�|Ð#Ð#ùòo Ms   È&R,c                   óL   • \ rS rSrS\R
                  SS4S jrS\SS4S jrS	r	g)
Ú_CudaModulei!  Úmoduler   Nc                 ó   • Xl         0 U l        g r)   )Ú_moduleÚ_kernels)Úselfrœ   s     r"   Ú__init__Ú_CudaModule.__init__"  s   € ØŒØ02ˆ�r&   ÚnameÚ_CudaKernelc           	      ó¤  • XR                   ;   a  U R                   U   $ SSKJn  U" 5       n[        R                  " 5       n [        UR                  [        R                  " U5      U R                  UR                  S5      5      5        [        X@R                  5      nXPR                   U'   U$ ! [         a  n[        SU S35      UeS nAff = f)Nr   )r*   rv   zNo kernel named 'z' in this module)rŸ   Útorch.cuda._utilsr*   r   r‚   r7   r   r0   rž   ry   r¤   r3   ÚAttributeError)r    r£   r*   r5   ÚfuncÚkernelÚerrs          r"   Ú__getattr__Ú_CudaModule.__getattr__&  s¹   € Ø—=‘=Ó Ø—=‘= Ñ&Ð&õ 	?á*Ó,ˆä�ŠÓ ˆð	VÜØ×+Ñ+Ü—L’L Ó&¨¯©°d·k±kÀ'Ó6Jóôô
 ! §|¡|Ó4ˆFØ"(�M‰M˜$ÑØˆMøäó 	VÜ Ð#4°T°FÐ:JÐ!KÓLÐRUÐUûð	Vús   ÁA-B0 Â0
CÂ:C
Ã
C)rŸ   rž   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r‚   r¡   r   r«   Ú__static_attributes__r%   r&   r"   r›   r›   !  s/   † ð3˜vŸ™ð 3°4ô 3ðV ð V¨÷ Vr&   r›   c                   ó¼   • \ rS rSrSrS\R                  S\R                  SS4S jr     SS\\	\	\	4   S	\\	\	\	4   S
\
S-  S\	S\S-  SS4S jjrS\	SS4S jrSrg)r¤   i?  zL
Represents a compiled CUDA kernel that can be called with PyTorch tensors.
r¨   rœ   r   Nc                 ó*   • Xl         X l        SU l        g )Nr   )r¨   rœ   Ú_max_shared_mem_bytes)r    r¨   rœ   s      r"   r¡   Ú_CudaKernel.__init__D  s   € ØŒ	ØŒØ%&ˆÕ"r&   ÚgridÚblockÚargsÚ
shared_memÚstreamc                 ó¨  • SSK nUR                  R                  R                  5       nU(       d  / n/ n/ n	U GHv  n
[	        X¦R
                  5      (       až  U
R                  (       d1  U
R                  (       a  U
R                  5       (       d  [        S5      e[        R                  " U
R                  5       5      nUR                  U5        U	R                  [        R                  " U5      5        M¼  [	        U
[        5      (       a>  [        R                   " U
5      nU	R                  [        R                  " U5      5        GM  [	        U
["        5      (       a>  [        R$                  " U
5      nU	R                  [        R                  " U5      5        GMb  ['        S[)        U
5       35      e   [        R                  [+        U	5      -  " 5       n[-        U	5       H,  u  pú[        R.                  " U
[        R                  5      Xï'   M.     Uc  SSKnUR                  R3                  5       nUS:¼  aS  U R4                  S:X  d  X@R4                  :”  a4  U R4                  S:X  a  SOSU R4                   S3n[7        S	U S
U S35      e[9        UR;                  U R<                  US   US   US   US   US   US   UUR>                  US5      5        g)a¶  
Call the compiled CUDA kernel

Args:
    grid (tuple): Grid dimensions (grid_x, grid_y, grid_z)
    block (tuple): Block dimensions (block_x, block_y, block_z)
    args (list): List of arguments to pass to the kernel.
                 PyTorch tensor arguments will be automatically converted to pointers.
    shared_mem (int): Shared memory size in bytes
    stream (torch.cuda.Stream): CUDA stream to use. If None, uses current stream.
r   Nz?All tensor arguments must be CUDA tensors or pinned CPU tensorszUnsupported argument type: é À  znot configuredzonly z bytes configuredzKernel requires z' bytes of shared memory (>= 48KB), but ze. Call kernel.set_shared_memory_config(shared_mem) after compilation and before launching the kernel.é   r<   ) r   rX   Ú_utilsr*   Ú
isinstanceÚTensorÚis_cudaÚis_cpuÚ	is_pinnedÚ
ValueErrorr   r‚   Údata_ptrr   r0   rW   Úc_intÚfloatÚc_doubleÚ	TypeErrorÚtyper�   Ú	enumerateÚcastrx   Úcurrent_streamr´   r3   r7   r   r¨   Ú_as_parameter_)r    r¶   r·   r¸   r¹   rº   r   r5   Úprocessed_argsÚc_argsÚargÚptrrÆ   rÈ   Úc_args_arrayÚiÚconfigured_msgs                    r"   Ú__call__Ú_CudaKernel.__call__I  sT  € ó& 	à—*‘*×#Ñ#×<Ñ<Ó>ˆæØˆDð 13ˆØˆäˆCÜ˜#Ÿ|™|×,Ñ,Ø—{—{¨C¯J¯J¸3¿=¹=¿?¹?Ü$ØYóð ô —o’o c§l¡l£nÓ5�Ø×%Ñ% cÔ*Ø—‘œfŸlšl¨3Ó/Ö0Ü˜C¤×%Ñ%äŸš SÓ)�à—‘œfŸlšl¨5Ó1×2Ü˜C¤×'Ñ'ä!Ÿ?š?¨3Ó/�à—‘œfŸlšl¨8Ó4×5äÐ"=¼dÀ3»i¸[Ð IÓJÐJñ+ ô0 Ÿ™¬#¨f«+Ò5Ó8ˆÜ Ö'‰FˆAÜ$Ÿkšk¨#¬v¯©Ó?ˆL‹Oñ (ð ‰>ãà—Z‘Z×.Ñ.Ó0ˆFð ˜Ó"Ø×&Ñ&¨!Ó+¨z×<VÑ<VÓ/Vð ×-Ñ-°Ó2ñ !à˜T×7Ñ7Ð8Ð8IÐJð ô
 Ø" : ,ð /Ø%Ð&ð '3ð3óð ô 	Ø×"Ñ"Ø—	‘	Ø�Q‘Ø�Q‘Ø�Q‘Ø�a‘Ø�a‘Ø�a‘ØØ×%Ñ%ØØóõ	
r&   Úshared_mem_bytesc                 óz  • US:  a  Xl         g [        5       n[        R                  R	                  5       n[        R
                  R                  (       a  UR                  S:w  a  SOSnO[        USS5      nX:”  a  [        SU SU S35      eS	n[        UR                  U R                  UU5      5        Xl         g )
Nr¼   Úgfx950i   i € Úshared_memory_per_block_optinzRequested shared memory (z bytes) exceeds device limit (z= bytes). Consider reducing block size or shared memory usage.é   )r´   r*   r   rX   rz   r   r   r|   Úgetattrr3   r7   r    r¨   )r    rØ   r5   Údevice_propsÚmax_shared_memÚ+cudaFuncAttributeMaxDynamicSharedMemorySizes         r"   Úset_shared_memory_configÚ$_CudaKernel.set_shared_memory_configª  sÑ   € Ø˜iÓ'à)9Ô&Øä*Ó,ˆô —z‘z×7Ñ7Ó9ˆä�=‰=××ð &×1Ñ1°XÓ=‘À:ñ ô %ØÐ=¸uóˆNð Ó,ÜØ+Ð,<Ð+=ð >!Ø!/Ð 0ð 1GðGóð ð 78Ð3ÜØ×&Ñ&Ø—	‘	Ø;Ø óô	
ð &6Õ"r&   )r´   r¨   rœ   )©r½   r½   r½   rã   Nr   N)r­   r®   r¯   r°   Ú__doc__r   r‚   r¡   ÚtuplerW   Úlistr   rÖ   rá   r±   r%   r&   r"   r¤   r¤   ?  s²   † ñð'˜VŸ_™_ð '°f·o±oð 'È$ô 'ð &/Ø&/Ø ØØ!ñ_
à�C˜˜c�MÑ"ð_
ð �S˜#˜s�]Ñ#ð_
ð �T‰kð	_
ð
 ð_
ð �d‘
ð_
ð 
õ_
ðB(6¸ð (6À÷ (6r&   r¤   ÚptxÚkernel_namesc           
      ó\  • SSK n[        5       n[        U [        5      (       a  U R	                  S5      n [
        R                  " 5       nUR                  R                  5       nU   [        UR                  [
        R                  " U5      U 5      5        SSS5        U(       d  [        U5      $ 0 nU Hc  n[
        R                  " 5       n[        UR                  [
        R                  " U5      XGR	                  S5      5      5        [        X„5      Xg'   Me     U$ ! , (       d  f       N�= f)a  
Loads a CUDA module from PTX code and returns a module object that can access kernels.

Args:
    ptx (bytes or str): The PTX code to load
    kernel_names (list, optional): List of kernel names to extract from the module.
                                  If None, will return a module object with __getattr__.

Returns:
    object: If kernel_names is None, returns a module object with __getattr__ to access kernels.
           If kernel_names is provided, returns a dict mapping kernel names to _CudaKernel objects.
r   Nrv   )rx   r*   r¿   r   ry   r   r‚   rX   rÍ   r7   r   r0   r›   r   r¤   )	rç   rè   r   r5   rœ   rº   Úkernelsr£   r¨   s	            r"   Ú_cuda_load_modulerë   Õ  së   € ó  ô 'Ó(€Gô �#”s×ÑØ�j‰j˜Ó!ˆô �_Š_Ó€Fà�Z‰Z×&Ñ&Ó(€FÚ	Ü�G×,Ñ,¬V¯\ª\¸&Ó-AÀ3ÓGÔH÷ 
ö Ü˜6Ó"Ð"ð €GÛˆÜ�ŠÓ ˆÜØ×'Ñ'Ü—’˜TÓ" F¯K©K¸Ó,@óô	
ô
 $ DÓ1ˆ‹ñ ð €N÷! 
�ús   Á&0DÄ
D+ÚdeviceÚoptionalÚ	allow_cpuc                 ó  • [        U [        5      (       a  U $ [        U [        5      (       a  [        R                  " U 5      n [        U [        R                  5      (       aD  U(       a  U R
                  S;  a  [        SU  35      eOU R
                  S:w  a  [        SU  35      e[        R                  R                  5       (       d5  [        U [        R                  R                  5      (       a  U R                  $ [        XU5      $ )a�  Get the device index from :attr:`device`, which can be a torch.device object, a Python integer, or ``None``.

If :attr:`device` is a torch.device object, returns the device index if it
is a CUDA device. Note that for a CUDA device without a specified index,
i.e., ``torch.device('cuda')``, this will return the current default CUDA
device if :attr:`optional` is ``True``. If :attr:`allow_cpu` is ``True``,
CPU devices will be accepted and ``-1`` will be returned in this case.

If :attr:`device` is a Python integer, it is returned as is.

If :attr:`device` is ``None``, this will return the current default CUDA
device if :attr:`optional` is ``True``.
)rX   Úcpuz(Expected a cuda or cpu device, but got: rX   z!Expected a cuda device, but got: )r¿   rW   r   r   rì   rÊ   rÄ   ÚjitÚis_scriptingrX   ÚidxÚ_torch_get_device_index)rì   rí   rî   s      r"   r   r     sÉ   € ô  �&œ#×ÑØˆÜ�&œ#×ÑÜ—’˜fÓ%ˆÜ�&œ%Ÿ,™,×'Ñ'ÞØ�{‰{ /Ó1Ü Ð#KÈFÈ8Ð!TÓUÐUð 2à�[‰[˜FÓ"ÜÐ@ÀÀÐIÓJÐJÜ�9‰9×!Ñ!×#Ñ#Ü�fœeŸj™j×/Ñ/×0Ñ0Ø—:‘:ÐÜ" 6°YÓ?Ð?r&   )NNNFr)   )FF)r   r   Útypingr   r   Útorch._utilsr   rô   r   r#   r'   r*   rW   r7   rS   r^   r`   ræ   r   ri   Úboolrå   Úbytesr™   r›   r¤   Údictrë   r%   r&   r"   Ú<module>rú      s•  ðÛ Û 
Ý ã õ Fð &§+¡+ô ð.+˜6Ÿ;™;ô +ð# &§+¡+ô #ð	7˜ð 	7 ô 	7ð˜VŸ[™[ô ð:6˜FŸK™Kô 6ð&$˜fŸk™kô $ð t¨C¡yô ð6 &*Ø%)Ø $ØñO$ØðO$àðO$ð ˜d™
ðO$ð ˜d‘{ð	O$ð
 ˜‘+ðO$ð ðO$ð ˆ5�#ˆ:ÑõO$÷dVñ V÷<S6ñ S6ðn 8<ñ-Ø	ˆu‰ð-Ø$(¨¡I°Ñ$4ð-à�4˜˜]Ð*Ñ+Ñ+õ-ðb <Añ@Øð@Øð@Ø48ð@àö@r&   