
    &Vji                        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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j        j        d
dfdZ G d d          Z G d d          Z e            Zead"dej        j        d
efdZ G d de          Zded
efdZd
e fdZ!dej        j        d
dfdZ"d
e#fd Z$d
efd!Z%dS )#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                  H    t           j        j                                        S )z/Returns a bool indicating if CPU supports AVX2.)torch_C_cpu_is_avx2_supported     L/root/voice-cloning/.venv/lib/python3.11/site-packages/torch/cpu/__init__.pyr   r      s    8=++---r   c                  H    t           j        j                                        S )z1Returns a bool indicating if CPU supports AVX512.)r   r   r   _is_avx512_supportedr   r   r   r!   r!   $   s    8=--///r   c                  H    t           j        j                                        S )z6Returns a bool indicating if CPU supports AVX512_BF16.)r   r   r   _is_avx512_bf16_supportedr   r   r   r#   r#   )   s    8=22444r   c                  H    t           j        j                                        S )z/Returns a bool indicating if CPU supports VNNI.)r   r   r   _is_avx512_vnni_supportedr   r   r   _is_vnni_supportedr&   .   s     8=22444r   c                  H    t           j        j                                        S )z3Returns a bool indicating if CPU supports AMX_TILE.)r   r   r   _is_amx_tile_supportedr   r   r   r(   r(   4       8=//111r   c                  H    t           j        j                                        S )z3Returns a bool indicating if CPU supports AMX FP16.)r   r   r   _is_amx_fp16_supportedr   r   r   r+   r+   9   r)   r   c                  H    t           j        j                                        S )zInitializes AMX instructions.)r   r   r   	_init_amxr   r   r   r-   r-   >   s    8=""$$$r   c                      dS )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   C   s	     4r   r	   c                     dS )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                   <    e Zd ZdZd
deddfdZddZddZdd	ZdS )r   zH
    N.B. This class only exists to facilitate device-agnostic code
    priorityr   Nc                     d S Nr   )selfr3   s     r   __init__zStream.__init__[       r   c                     d S r5   r   r6   r   s     r   wait_streamzStream.wait_stream^   r8   r   c                     d S r5   r   r6   s    r   record_eventzStream.record_eventa   r8   r   c                     d S r5   r   )r6   events     r   
wait_eventzStream.wait_eventd   r8   r   )r2   r   N)	__name__
__module____qualname____doc__intr7   r;   r>   rA   r   r   r   r   r   V   s           d               r   r   c                   6    e Zd ZdefdZdddZddZdddZdS )	r   r   c                     dS )NTr   r=   s    r   queryzEvent.queryi   s    tr   Nc                     d S r5   r   r:   s     r   recordzEvent.recordl   r8   r   c                     d S r5   r   r=   s    r   r   zEvent.synchronizeo   r8   r   c                     d S r5   r   r:   s     r   waitz
Event.waitr   r8   r   r5   rB   )rC   rD   rE   boolrJ   rL   r   rO   r   r   r   r   r   h   su        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   z   s
     r   c                   N    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
d	S )r   zvContext-manager that selects a given stream.

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

    
cur_streamc                 ,    || _         t          | _        d S r5   )r   _default_cpu_streamprev_streamr:   s     r   r7   zStreamContext.__init__   s    .r   c                 8    | j         }|d S t          | _        |ad S r5   )r   rR   rW   )r6   rT   s     r   	__enter__zStreamContext.__enter__   s'    [
F +$r   typevalue	tracebackr   Nc                 *    | j         }|d S | j        ad S r5   )r   rW   rR   )r6   rZ   r[   r\   rT   s        r   __exit__zStreamContext.__exit__   s"    [
F *r   )rC   rD   rE   rF   r   r   __annotations__r7   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                      dS )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	    
 1r   c                     dS )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                      dS )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	    
 5r   c                      dS )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	    
 4r   r5   )&rF   
contextlibr   typingr   r   r   r    r	   _devicer   __all__rP   r   r!   r#   r&   r(   r+   r-   r   typesDevicer   r   r   rV   rR   r   r   r   rG   r   r   strr   r   r   r   r   <module>rn      s   
 . - - - - - ' ' ' ' ' ' ' ' ' '                     .D . . . .
0d 0 0 0 0
54 5 5 5 5
5D 5 5 5 52 2 2 2 2
2 2 2 2 2
%4 % % % %
d     * d           $        fhh %	 	5;- 	 	 	 	 	+ + + + +* + + +>!6 !4 ! ! ! !c    u{) d              r   