a
    h                     @   st  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ed
ddZed
ddZed
ddZed
ddZed
ddZed
ddZed
ddZed
ddZd1eddddZG dd dZG d d! d!Ze Zead2eedd"d#ZG d$d% d%eZeed&d'd(Z ed
d)d*Z!eddd+d,Z"ed
d-d.Z#ed
d/d0Z$dS )3zj
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                   C   s   t jj S )z/Returns a bool indicating if CPU supports AVX2.)torch_C_cpu_is_avx2_supported r   r   @/var/www/auris/lib/python3.9/site-packages/torch/cpu/__init__.pyr   !   s    r   c                   C   s   t jj S )z1Returns a bool indicating if CPU supports AVX512.)r   r   r   _is_avx512_supportedr   r   r   r   r   &   s    r   c                   C   s   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    r   c                   C   s   t jj S )z/Returns a bool indicating if CPU supports VNNI.)r   r   r   Z_is_avx512_vnni_supportedr   r   r   r   _is_vnni_supported0   s    r    c                   C   s   t jj S )z3Returns a bool indicating if CPU supports AMX_TILE.)r   r   r   _is_amx_tile_supportedr   r   r   r   r!   6   s    r!   c                   C   s   t jj S )z3Returns a bool indicating if CPU supports AMX FP16.)r   r   r   _is_amx_fp16_supportedr   r   r   r   r"   ;   s    r"   c                   C   s   t jj S )zInitializes AMX instructions.)r   r   r   	_init_amxr   r   r   r   r#   @   s    r#   c                   C   s   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   E   s    r   )r   r   c                 C   s   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   r   r   r   r   N   s    r   c                   @   sL   e Zd ZdZdeddddZdddd	Zddd
dZddddZdS )r   zH
    N.B. This class only exists to facilitate device-agnostic code
    N)priorityr   c                 C   s   d S Nr   )selfr%   r   r   r   __init__]   s    zStream.__init__r   c                 C   s   d S r&   r   r'   r   r   r   r   wait_stream`   s    zStream.wait_streamc                 C   s   d S r&   r   r'   r   r   r   record_eventc   s    zStream.record_eventc                 C   s   d S r&   r   )r'   eventr   r   r   
wait_eventf   s    zStream.wait_event)r$   )	__name__
__module____qualname____doc__intr(   r*   r,   r.   r   r   r   r   r   X   s
   r   c                   @   sH   e Zd ZedddZdddddZddddZdddd	d
ZdS )r   r   c                 C   s   dS )NTr   r+   r   r   r   queryk   s    zEvent.queryNc                 C   s   d S r&   r   r)   r   r   r   recordn   s    zEvent.recordc                 C   s   d S r&   r   r+   r   r   r   r   q   s    zEvent.synchronizec                 C   s   d S r&   r   r)   r   r   r   waitt   s    z
Event.wait)N)N)r/   r0   r1   boolr4   r5   r   r6   r   r   r   r   r   j   s   r   c                 C   s   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   r   r   r   r   |   s    	r   c                   @   sB   e Zd ZU dZee ed< dd Zdd Ze	e	e	ddd	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                 C   s   || _ t| _d S r&   )r   _default_cpu_streamprev_streamr)   r   r   r   r(      s    zStreamContext.__init__c                 C   s    | j }|d u rd S t| _|ad S r&   )r   r8   r;   )r'   r9   r   r   r   	__enter__   s
    zStreamContext.__enter__N)typevalue	tracebackr   c                 C   s   | j }|d u rd S | jad S r&   )r   r;   r8   )r'   r=   r>   r?   r9   r   r   r   __exit__   s    zStreamContext.__exit__)r/   r0   r1   r2   r   r   __annotations__r(   r<   r   r@   r   r   r   r   r      s
   
	r   )r   r   c                 C   s   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   r   r   r   r      s    r   c                   C   s   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    r   c                 C   s   dS )zzSets the current device, in CPU we do nothing.

    N.B. This function only exists to facilitate device-agnostic code
    Nr   r   r   r   r   r      s    r   c                   C   s   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    r   c                   C   s   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    r   )N)N)%r2   
contextlibr   typingr   r   r   r    r   Z_devicer
   __all__strr3   Z	_device_tr7   r   r   r   r    r!   r"   r#   r   r   r   r   r:   r8   r   r   r   r   r   r   r   r   r   r   r   <module>   s6   	
	