
    ȅi                        S r SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  / S	Qr
S
\4S jrS
\4S jrS
\4S jrS
\4S jrS
\4S jrS
\4S jrS
\4S jrS
\4S jrS"S\R(                  R*                  S
S4S jjr " S S5      r " S S5      r\" 5       r\qS"S\R(                  R*                  S
\4S jjr " S S\5      rS\S
\4S jrS
\4S jrS\R(                  R*                  S
S4S jr S
\!4S  jr"S
\4S! jr#g)#zj
This package implements abstractions found in ``torch.cuda``
to facilitate writing device-agnostic code.
    )AbstractContextManager)AnyN   device   )amp)is_availableis_initializedsynchronizecurrent_devicecurrent_streamstream
set_devicedevice_countStreamStreamContextEventreturnc                  R    [         R                  R                  R                  5       $ )z/Returns a bool indicating if CPU supports AVX2.)torch_C_cpu_is_avx2_supported     L/home/james-whalen/.local/lib/python3.13/site-packages/torch/cpu/__init__.pyr   r      s    88==++--r   c                  R    [         R                  R                  R                  5       $ )z1Returns a bool indicating if CPU supports AVX512.)r   r   r   _is_avx512_supportedr   r   r   r   r   $   s    88==--//r   c                  R    [         R                  R                  R                  5       $ )z6Returns a bool indicating if CPU supports AVX512_BF16.)r   r   r   _is_avx512_bf16_supportedr   r   r   r!   r!   )   s    88==2244r   c                  R    [         R                  R                  R                  5       $ )z/Returns a bool indicating if CPU supports VNNI.)r   r   r   _is_avx512_vnni_supportedr   r   r   _is_vnni_supportedr$   .   s     88==2244r   c                  R    [         R                  R                  R                  5       $ )z3Returns a bool indicating if CPU supports AMX_TILE.)r   r   r   _is_amx_tile_supportedr   r   r   r&   r&   4       88==//11r   c                  R    [         R                  R                  R                  5       $ )z3Returns a bool indicating if CPU supports AMX FP16.)r   r   r   _is_amx_fp16_supportedr   r   r   r)   r)   9   r'   r   c                  R    [         R                  R                  R                  5       $ )zInitializes AMX instructions.)r   r   r   	_init_amxr   r   r   r+   r+   >   s    88==""$$r   c                      g)z}Returns a bool indicating if CPU is currently available.

N.B. This function only exists to facilitate device-agnostic code

Tr   r   r   r   r
   r
   C   s     r   r   c                     g)zWaits for all kernels in all streams on the CPU device to complete.

Args:
    device (torch.device or int, optional): ignored, there's only one CPU device.

N.B. This function only exists to facilitate device-agnostic code.
Nr   r   s    r   r   r   L       r   c                   L    \ rS rSrSrSS\SS4S jjrSS jrSS jrSS	 jr	S
r
g)r   V   z@
N.B. This class only exists to facilitate device-agnostic code
priorityr   Nc                     g Nr   )selfr1   s     r   __init__Stream.__init__[       r   c                     g r3   r   r4   r   s     r   wait_streamStream.wait_stream^   r7   r   c                     g r3   r   r4   s    r   record_eventStream.record_eventa   r7   r   c                     g r3   r   )r4   events     r   
wait_eventStream.wait_eventd   r7   r   r   )r   N)__name__
__module____qualname____firstlineno____doc__intr5   r:   r>   rB   __static_attributes__r   r   r   r   r   V   s)     d r   r   c                   H    \ rS rSrS\4S jrS	S
S jjrS
S jrS	S
S jjrSr	g)r   h   r   c                     g)NTr   r=   s    r   queryEvent.queryi   s    r   Nc                     g r3   r   r9   s     r   recordEvent.recordl   r7   r   c                     g r3   r   r=   s    r   r   Event.synchronizeo   r7   r   c                     g r3   r   r9   s     r   wait
Event.waitr   r7   r   r   r3   rE   )
rF   rG   rH   rI   boolrP   rS   r   rX   rL   r   r   r   r   r   h   s"    t  r   r   c                     [         $ )zReturns the currently selected :class:`Stream` for a given device.

Args:
    device (torch.device or int, optional): Ignored.

N.B. This function only exists to facilitate device-agnostic code

)_current_streamr   s    r   r   r   z   s
     r   c                   P    \ rS rSr% Sr\S-  \S'   S rS rS\	S\	S	\	S
S4S jr
Srg)r      znContext-manager that selects a given stream.

N.B. This class only exists to facilitate device-agnostic code

N
cur_streamc                 &    Xl         [        U l        g r3   )r   _default_cpu_streamprev_streamr9   s     r   r5   StreamContext.__init__   s    .r   c                 >    U R                   nUc  g [        U l        Uqg r3   )r   r\   rb   )r4   r_   s     r   	__enter__StreamContext.__enter__   s#    [[
 +$r   typevalue	tracebackr   c                 <    U R                   nUc  g U R                  qg r3   )r   rb   r\   )r4   rg   rh   ri   r_   s        r   __exit__StreamContext.__exit__   s!    [[
 **r   )rb   r   )rF   rG   rH   rI   rJ   r   __annotations__r5   re   r   rk   rL   r   r   r   r   r      s>     /%+S + + + +r   r   r   c                     [        U 5      $ )zWrapper around the Context-manager StreamContext that
selects a given stream.

N.B. This function only exists to facilitate device-agnostic code
)r   )r   s    r   r   r      s       r   c                      g)zxReturns number of CPU devices (not cores). Always 1.

N.B. This function only exists to facilitate device-agnostic code
r   r   r   r   r   r   r      s    
 r   c                     g)zrSets the current device, in CPU we do nothing.

N.B. This function only exists to facilitate device-agnostic code
Nr   r   s    r   r   r      r.   r   c                      g)zqReturns current device for cpu. Always 'cpu'.

N.B. This function only exists to facilitate device-agnostic code
cpur   r   r   r   r   r      s    
 r   c                      g)zxReturns True if the CPU is initialized. Always True.

N.B. This function only exists to facilitate device-agnostic code
Tr   r   r   r   r   r      s    
 r   r3   )$rJ   
contextlibr   typingr   r    r   _devicer	   __all__rZ   r   r   r!   r$   r&   r)   r+   r
   typesDevicer   r   r   ra   r\   r   r   r   rK   r   r   strr   r   r   r   r   <module>r|      sA  
 .     .D .
0d 0
54 5
5D 52 2
2 2
%4 %
d ** d  $  h %	5;;-- 	 	+* +>!6 !4 !c u{{)) d   r   