
    rh                     z   d Z ddlmZ ddlmZmZmZ ddlZddlm	Z
 ddlmZ g d	Zee
eedf   Zd
efdZd
efdZd
efdZd
efdZd
efdZd
efdZd
efdZd
efdZd"ded
dfdZ G d d      Z G d d      Z e       Zead"ded
efdZ G d de      Zded
efdZ d
efdZ!ded
dfdZ"d
efd Z#d
efd!Z$y)#zj
This package implements abstractions found in ``torch.cuda``
to facilitate writing device-agnostic code.
    )AbstractContextManager)AnyOptionalUnionN   device   )amp)is_availableis_initializedsynchronizecurrent_devicecurrent_streamstream
set_devicedevice_countStreamStreamContextEventreturnc                  R    t         j                  j                  j                         S )z/Returns a bool indicating if CPU supports AVX2.)torch_C_cpu_is_avx2_supported     e/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/torch/cpu/__init__.pyr   r   !   s    88==++--r   c                  R    t         j                  j                  j                         S )z1Returns a bool indicating if CPU supports AVX512.)r   r   r   _is_avx512_supportedr   r   r   r!   r!   &   s    88==--//r   c                  R    t         j                  j                  j                         S )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    t         j                  j                  j                         S )z/Returns a bool indicating if CPU supports VNNI.)r   r   r   _is_avx512_vnni_supportedr   r   r   _is_vnni_supportedr&   0   s     88==2244r   c                  R    t         j                  j                  j                         S )z3Returns a bool indicating if CPU supports AMX_TILE.)r   r   r   _is_amx_tile_supportedr   r   r   r(   r(   6       88==//11r   c                  R    t         j                  j                  j                         S )z3Returns a bool indicating if CPU supports AMX FP16.)r   r   r   _is_amx_fp16_supportedr   r   r   r+   r+   ;   r)   r   c                  R    t         j                  j                  j                         S )zInitializes AMX instructions.)r   r   r   	_init_amxr   r   r   r-   r-   @   s    88==""$$r   c                       y)zReturns 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   E   s     r   r	   c                      y)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   N       r   c                   :    e Zd ZdZd	deddfdZd
dZd
dZd
dZy)r   zH
    N.B. This class only exists to facilitate device-agnostic code
    priorityr   Nc                      y Nr   )selfr2   s     r   __init__zStream.__init__]       r   c                      y r4   r   r5   r   s     r   wait_streamzStream.wait_stream`   r7   r   c                      y r4   r   r5   s    r   record_eventzStream.record_eventc   r7   r   c                      y r4   r   )r5   events     r   
wait_eventzStream.wait_eventf   r7   r   )r   N)	__name__
__module____qualname____doc__intr6   r:   r=   r@   r   r   r   r   r   X   s)     d r   r   c                   4    e Zd ZdefdZdddZddZdddZy)	r   r   c                      y)NTr   r<   s    r   queryzEvent.queryk   s    r   Nc                      y r4   r   r9   s     r   recordzEvent.recordn   r7   r   c                      y r4   r   r<   s    r   r   zEvent.synchronizeq   r7   r   c                      y r4   r   r9   s     r   waitz
Event.waitt   r7   r   r4   rB   )rC   rD   rE   boolrJ   rL   r   rO   r   r   r   r   r   j   s    t r   r   c                     t         S )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   |   s
     r   c                   F    e Zd ZU dZee   ed<   d Zd Zde	de	de	dd	fd
Z
y	)r   zvContext-manager that selects a given stream.

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

    
cur_streamc                 (    || _         t        | _        y r4   )r   _default_cpu_streamprev_streamr9   s     r   r6   zStreamContext.__init__   s    .r   c                 <    | j                   }|y t        | _        |ay r4   )r   rR   rW   )r5   rT   s     r   	__enter__zStreamContext.__enter__   s#    [[
 +$r   typevalue	tracebackr   Nc                 :    | j                   }|y | j                  ay r4   )r   rW   rR   )r5   rZ   r[   r\   rT   s        r   __exit__zStreamContext.__exit__   s!    [[
 **r   )rC   rD   rE   rF   r   r   __annotations__r6   rY   r   r^   r   r   r   r   r      s?       /%+S + + + +r   r   r   c                     t        |       S )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                       y)zReturns 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                      y)zzSets 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      r0   r   c                       y)zyReturns 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                       y)zReturns 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   r4   )%rF   
contextlibr   typingr   r   r   r    r	   _devicer   __all__strrG   	_device_trP   r   r!   r#   r&   r(   r+   r-   r   r   r   r   rV   rR   r   r   r   r   r   r   r   r   r   r   <module>rm      s;  
 . ' '     '3T)*	.D .
0d 0
54 5
5D 52 2
2 2
%4 %
d 	 T  $  h %	9 	 	+* +>!6 !4 !c y T   r   